Search by

amashukov / bitcoin-cash-php

Andrey Mashukov

Bitcoin Cash SDK for PHP — CashAddr codec with token-aware CashTokens types and a typed Bitcoin Cash Node (BCHN) JSON-RPC client. Umbrella package pulling the pure-PHP Bitcoin Cash stack.

Package info

github.com/AndreyMashukov/bitcoin-cash-php

pkg:composer/amashukov/bitcoin-cash-php

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-10-23 09:07 UTC

This package is auto-updated.

Last update: 2026-10-23 09:48:48 UTC


README

Pure-PHP Bitcoin Cash SDK — CashAddr codec with token-aware CashTokens types and a typed Bitcoin Cash Node JSON-RPC client in one composer require.

CI PHPStan L9 Latest Version Downloads PHP License Stars

amashukov/bitcoin-cash-php is a standalone Bitcoin Cash SDK for PHP — an umbrella package that pulls the Bitcoin Cash primitives a PHP service needs to receive and send BCH through its own node: a CashAddr codec that understands the token-aware CashTokens address types, and a typed JSON-RPC client that speaks the Bitcoin Cash Node (BCHN) dialect with exact satoshi amounts. Pure PHP, no Symfony, no blockchain-library dependencies.

Features

  • CashAddr — encode / decode with the BCH polymod checksum, bitcoincash / bchtest / bchreg prefixes, P2PKH, P2SH, P2SH32 and the token-aware z / r types as a typed enum.
  • BCHN JSON-RPC — wallet, UTXO, PSBT (ALL|FORKID), raw transactions with typed prevouts, testmempoolaccept / sendrawtransaction with allowhighfees, estimatefee in sat/byte and DSProof scores.
  • Exact money — satoshis as integers, CashToken amounts as decimal strings; no float anywhere on the path.
  • One install — both layers through a single composer require, each versioned in its own repository.

Why amashukov/bitcoin-cash-php

Most PHP Bitcoin libraries target Bitcoin Core and break on Bitcoin Cash in small ways: they send estimatesmartfee, a max fee rate to sendrawtransaction, an address type to getnewaddress, or they read JSON amounts as floats. This stack follows the BCHN reference signatures, understands CashTokens data and the token-aware CashAddr types, and keeps PHPStan level 9 across the surface.

Installation

composer require amashukov/bitcoin-cash-php

Usage

Each layer keeps its own namespace; import what you need:

use Amashukov\CashAddr\CashAddress;
use Amashukov\CashAddr\CashAddrNetwork;
use Amashukov\BchnRpc\BchnRpcClient;
use Amashukov\BchnRpc\Vo\BchAmount;
use Amashukov\BchnRpc\Vo\PsbtOutput;

// Validate the destination, then build, sign and broadcast through the
// node — see each sub-package README for the full API.
$to = CashAddress::fromString($userInput, CashAddrNetwork::Mainnet);
if ($to->type->isTokenAware()) {
    // refuse or route to a token-aware flow
}

Requirements

  • PHP 8.3+ on a 64-bit build
  • A PSR-18 HTTP client + PSR-17 factories for the RPC client (e.g. amashukov/http-client-php + nyholm/psr7)
  • A Bitcoin Cash Node with the JSON-RPC server enabled

Related packages

Package Layer
amashukov/cashaddr-php CashAddr codec + typed address value object
amashukov/bchn-rpc-client-php Typed BCHN JSON-RPC client over PSR-18
amashukov/http-client-php PSR-18 cURL HTTP client
amashukov/eth-php Sister umbrella SDK for Ethereum / EVM
amashukov/ton-php Sister umbrella SDK for TON (The Open Network)

Quality

  • PHPStan level 9 across the whole stack.
  • php-cs-fixer with the @PER-CS ruleset.
  • GitHub Actions CI on every push.
  • The CashAddr codec runs the full specification and CashTokens test vectors.

License

MIT — see LICENSE. Each bundled package is MIT-licensed in its own repository.