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.

Maintainers

Package info

github.com/AndreyMashukov/ton-php

pkg:composer/amashukov/ton-php

Statistics

Installs: 75

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-05-24 06:26 UTC

This package is auto-updated.

Last update: 2026-05-24 12:47:32 UTC


README

Pure-PHP TON (The Open Network) SDK — TLB Cell/BOC primitives, Ed25519 wallets, mnemonic, and a typed toncenter client in one composer require.

CI PHPStan L9 Latest Version Downloads PHP License Stars

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 / Slice with a byte-exact bag-of-cells encoder (matches @ton/core).
  • Ed25519 cryptoKeyPair signing/verification plus TON-flavoured PBKDF2 Mnemonic derivation (not BIP-39).
  • Wallet v4r2WalletV4R2 contract wrapper, InternalMessage builder, and a full TON Address parser (UQ/EQ, raw, bounceable flags).
  • Typed toncenter client — toncenter v2 over any PSR-18 transport, with typed value objects instead of raw arrays.
  • Composable portsToncenterWalletRpc implements the wallet's WalletRpcInterface, 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-CS ruleset.
  • 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.