tetthys / wallet
Minimal, asset-agnostic wallet contract for crypto assets (BTC, ETH, tokens, etc.).
Installs: 3
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/tetthys/wallet
Requires
- php: ^8.1
Requires (Dev)
- pestphp/pest: ^3.0
- phpstan/phpstan: ^1.10
README
Minimal, asset-agnostic wallet contract for crypto assets (BTC, ETH, tokens, etc.).
Provides a clean and minimal WalletInterface
to abstract wallet operations such as
creating addresses, validating them, querying balances, and sending transfers.
โจ Features
-
Minimal API surface
Only the essentials: create address, validate, query balances, transfer. -
Asset-agnostic
Works for coins (BTC/ETH) and tokens (ERC-20, etc.). -
Safe amount handling
All amounts are passed as decimal strings to avoid floating-point errors. -
Extensible via options
transferMany()
accepts optional parameters (fee_rate
,nonce
,gas_limit
, โฆ). -
Testability
Ships withpestphp/pest
integration andphpstan
support.
๐ฆ Installation
composer require tetthys/wallet
For development:
composer install
composer test
composer analyse
๐ Usage
use Tetthys\Wallet\Contracts\WalletInterface; /** @var WalletInterface $wallet */ // Create a new address $addr = $wallet->createAddress('customer:123'); // Validate if (!$wallet->validateAddress($addr)) { throw new \RuntimeException("Invalid address"); } // Query balances $spendable = $wallet->getAvailableBalance(); // "0.015" $received = $wallet->getReceivedAmount($addr); // "0.010" // Transfer to many $txid = $wallet->transferMany( [ ['to' => 'addr1...', 'amount' => '0.004'], ['to' => 'addr2...', 'amount' => '0.001', 'memo' => 'invoice#42'], ], [ 'fee_rate' => 'fast', 'subtract_fee_from' => [0], ] );
โ ๏ธ Exceptions
All exceptions extend \RuntimeException
:
AddressCreationException
BalanceQueryException
DepositQueryException
AddressValidationException
TransferException
๐งช Testing
composer test
Runs the Pest test suite inside the package.
๐ Static Analysis
composer analyse
Runs PHPStan at max level on src/
.
๐ Project Structure
tetthys/wallet
โโโ src/
โ โโโ Contracts/
โ โ โโโ WalletInterface.php
โ โโโ Exceptions/
โ โโโ AddressCreationException.php
โ โโโ BalanceQueryException.php
โ โโโ DepositQueryException.php
โ โโโ AddressValidationException.php
โ โโโ TransferException.php
โโโ tests/
โ โโโ WalletInterfaceTest.php
โโโ composer.json
โโโ README.md
๐ License
MIT License. See LICENSE file.