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

0.0.1 2025-09-18 17:13 UTC

This package is auto-updated.

Last update: 2025-10-18 17:28:10 UTC


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 with pestphp/pest integration and phpstan 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.