amashukov / ton-php
Standalone TON (The Open Network) SDK for PHP — TLB Cell/BOC primitives, Ed25519 + TON-flavoured mnemonic, Wallet v4r2 + address parser, and a typed toncenter v2 client. Umbrella package pulling the full pure-PHP TON stack.
Requires
- php: >=8.3
- ext-bcmath: *
- ext-gmp: *
- ext-sodium: *
- amashukov/ton-cell-php: ^0.1.0
- amashukov/ton-crypto-php: ^0.1.0
- amashukov/ton-wallet-php: ^0.1.0
- amashukov/toncenter-client-php: ^0.1.0
Requires (Dev)
- amashukov/rector-php-rules: ^0.1.0
- friendsofphp/php-cs-fixer: ^3.50
- phpstan/phpstan: ^2.0
- phpunit/phpunit: ^11.0
- rector/rector: ^2.0
README
Pure-PHP TON (The Open Network) SDK — TLB Cell/BOC primitives, Ed25519 wallets, mnemonic, and a typed toncenter client in one composer require.
amashukov/ton-php is a standalone TON SDK for PHP — a single umbrella package that pulls the whole pure-PHP TON stack: TLB Cell / Builder / Slice with a canonical BOC encoder, Ed25519 KeyPair with TON-flavoured mnemonic derivation, a WalletV4R2 contract wrapper with an Address parser, and a typed toncenter v2 JSON-RPC client. Zero blockchain-library dependencies, no Symfony, no native extensions beyond the standard gmp / sodium / bcmath trio. Install it and the full TON wallet + toncenter stack is on your autoloader.
Features
- Canonical BOC — TLB
Cell/Builder/Slicewith a byte-exact bag-of-cells encoder (matches@ton/core). - Ed25519 crypto —
KeyPairsigning/verification plus TON-flavoured PBKDF2Mnemonicderivation (not BIP-39). - Wallet v4r2 —
WalletV4R2contract wrapper,InternalMessagebuilder, and a full TONAddressparser (UQ/EQ, raw, bounceable flags). - Typed toncenter client — toncenter v2 over any PSR-18 transport, with typed value objects instead of raw arrays.
- Composable ports —
ToncenterWalletRpcimplements the wallet'sWalletRpcInterface, so a wallet reads its seqno and broadcasts a signed transfer through toncenter with no glue. - One install — the full TON stack ships through a single
composer require.
Why amashukov/ton-php
olifanton/ton is the best-known PHP TON SDK (~300★), but it ships partial wallet coverage and no canonical bag-of-cells encoder, so cells you serialise may not round-trip byte-for-byte against @ton/core. amashukov/ton-php gives you a byte-exact canonical BOC encoder, a complete WalletV4R2 + Address surface, and a typed toncenter client — the entire stack behind one composer require, each layer separately versioned and individually installable.
Installation
composer require amashukov/ton-php
Usage
Each layer keeps its own namespace; import what you need:
use Amashukov\TonCell\Builder; use Amashukov\TonWallet\WalletV4R2; use Amashukov\Toncenter\ToncenterClient; use Amashukov\Toncenter\ToncenterWalletRpc; // Build cells, derive a wallet, broadcast through toncenter — see each // sub-package README for the full API.
The packages compose cleanly: Amashukov\Toncenter\ToncenterWalletRpc implements the Amashukov\TonWallet\WalletRpcInterface port, so a wallet can read its seqno and broadcast a signed transfer through toncenter with no glue.
Requirements
- PHP 8.3+
ext-gmp(bigint cell / address math)ext-sodium(Ed25519)ext-bcmath- A PSR-18 HTTP client + PSR-17 factories for the toncenter client (e.g.
amashukov/http-client-php+nyholm/psr7)
Related packages
| Package | Layer |
|---|---|
| amashukov/ton-cell-php | TLB Cell / Builder / Slice + canonical BOC encoder |
| amashukov/ton-crypto-php | Ed25519 KeyPair + TON-flavoured PBKDF2 Mnemonic |
| amashukov/ton-wallet-php | WalletV4R2 wrapper, InternalMessage builder, Address parser |
| amashukov/toncenter-client-php | Typed toncenter v2 client over any PSR-18 transport |
| amashukov/http-client-php | PSR-18 cURL HTTP client |
| amashukov/eth-php | Sister umbrella SDK for Ethereum / EVM |
| amashukov/blockchain-context-bundle | Symfony 7 bundle wiring the TON + EVM stacks |
Quality
- PHPStan level 9 across the whole stack.
- php-cs-fixer with the
@PER-CSruleset. - GitHub Actions CI on every push.
- Parity tests pin the BOC encoder byte-for-byte against
@ton/core.
License
MIT — see LICENSE. Each bundled package is MIT-licensed in its own repository.