PHPackages                             amashukov/ton-wallet-php - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. amashukov/ton-wallet-php

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

amashukov/ton-wallet-php
========================

TON Wallet v4r2 contract wrapper + internal-message builder + address parser/serializer in pure PHP. Offline transfer assembly; pluggable RPC for seqno + broadcast.

v0.1.0(2w ago)0215↑92.3%2MITPHPPHP &gt;=8.3CI failing

Since May 24Pushed 1w agoCompare

[ Source](https://github.com/AndreyMashukov/ton-wallet-php)[ Packagist](https://packagist.org/packages/amashukov/ton-wallet-php)[ RSS](/packages/amashukov-ton-wallet-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (2)Used By (2)

amashukov/ton-wallet-php
========================

[](#amashukovton-wallet-php)

Pure-PHP TON Wallet v4r2 — address derivation, transfer assembly, and a TON address parser for The Open Network.

[![CI](https://camo.githubusercontent.com/137c7ad509847b1f18f225a868694bdde9090451448c894a43d056d57c57d50b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f416e647265794d617368756b6f762f746f6e2d77616c6c65742d7068702f63692e796d6c3f6272616e63683d6d61696e266c6162656c3d4349)](https://github.com/AndreyMashukov/ton-wallet-php/actions)[![PHPStan L9](https://camo.githubusercontent.com/d47206f06ca9e2fd39598b669fe074f71d07aab96242a1f35d2409751c454fb3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f416e647265794d617368756b6f762f746f6e2d77616c6c65742d7068702f7374616e2e796d6c3f6272616e63683d6d61696e266c6162656c3d5048505374616e2532304c39)](https://github.com/AndreyMashukov/ton-wallet-php/actions)[![Latest Version](https://camo.githubusercontent.com/56f5de576a6b85746aaf32782a2b94a6dce4f3d470160b7e8b2066d6942dd1a9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616d617368756b6f762f746f6e2d77616c6c65742d706870)](https://packagist.org/packages/amashukov/ton-wallet-php)[![Downloads](https://camo.githubusercontent.com/9db55c1d3cc0d1ade6907c75eb5b0946818467f0cb7d3b33e79b920fa5251f9e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616d617368756b6f762f746f6e2d77616c6c65742d706870)](https://packagist.org/packages/amashukov/ton-wallet-php)[![PHP](https://camo.githubusercontent.com/ecda00e3f905bf7cf5ab29de4a9d0c708826c054b3a4e49bd72ca638e5fc1c28/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f616d617368756b6f762f746f6e2d77616c6c65742d7068702f706870)](https://packagist.org/packages/amashukov/ton-wallet-php)[![License](https://camo.githubusercontent.com/82ff338fa503f6a0471deb53fca13989d391dddc9dae73d350c2da3a821061a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f616d617368756b6f762f746f6e2d77616c6c65742d706870)](LICENSE)[![Stars](https://camo.githubusercontent.com/481456d2e2328bd72f9aff54ea9263702314524a428e5b10afe3d95984c7a893/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f416e647265794d617368756b6f762f746f6e2d77616c6c65742d7068703f7374796c653d736f6369616c)](https://github.com/AndreyMashukov/ton-wallet-php)

A pure-PHP implementation of the **TON Wallet v4r2 contract** for [The Open Network (TON)](https://ton.org): derive the wallet address, assemble signed transfers with the standard `InternalMessage` envelope, and parse / serialize TON addresses in every form. Address derivation matches `@ton/ton`'s `WalletContractV4` byte-for-byte, so a wallet built here lands at the same on-chain address as the JavaScript SDK. Broadcasting is decoupled behind a tiny RPC interface, so the same wallet object signs offline and ships through any backend.

Features
--------

[](#features)

- **Wallet v4r2 address derivation** — `WalletV4R2::address()` reproduces the exact state-init hash `@ton/ton` computes; same keys, same address.
- **Offline transfer assembly** — `createTransfer()` builds and signs the external-in message body without any network I/O; broadcast is a separate step.
- **1..4 messages per transfer** — batch up to four outgoing `InternalMessage`s in a single signed external message, with a per-message `sendMode`.
- **Full TON address parser** — `Address::parse()` handles user-friendly `UQ…` / `EQ…` (bounceable + non-bounceable, mainnet + testnet, url-safe + standard base64) and raw `workchain:hex` forms, with CRC16 validation.
- **Address re-serialization** — emit any parsed address in any target form via `Address::toString()` flags or `toTonscanFormat()`.
- **Pluggable RPC** — implement `WalletRpcInterface` (`getSeqno` + `sendBoc`) once and broadcast through toncenter, a custom node, or a test double.

Why amashukov/ton-wallet-php
----------------------------

[](#why-amashukovton-wallet-php)

`olifanton/ton` covers parts of the TON wallet surface, but this package keeps the wallet contract, the transfer builder, and the address parser as small `final readonly` value objects with PHPStan level 9 across the board, and pins address derivation to a cross-checked `@ton/ton` parity vector. Broadcasting is never baked in — you bring the transport.

Installation
------------

[](#installation)

```
composer require amashukov/ton-wallet-php
```

Usage
-----

[](#usage)

### Derive the wallet address

[](#derive-the-wallet-address)

```
use Amashukov\TonCrypto\Mnemonic;
use Amashukov\TonWallet\WalletV4R2;

$keys   = Mnemonic::toKeyPair('word1 word2 ... word24');
$wallet = new WalletV4R2($keys);

echo $wallet->address()->toString();                   // user-friendly UQ… (non-bounceable)
echo $wallet->address()->toString(userFriendly: false); // raw 0:abc…  (for RPC calls)
```

### Build and broadcast a transfer

[](#build-and-broadcast-a-transfer)

`InternalMessage` values are decimal-string nano-TON. `validUntil` is a UNIX timestamp after which an unconfirmed external message is dropped by the network.

```
use Amashukov\TonWallet\Address;
use Amashukov\TonWallet\InternalMessage;
use Amashukov\TonWallet\WalletV4R2;

$wallet = new WalletV4R2($keys);

$messages = [
    new InternalMessage(
        dest:  Address::parse('UQ...'),
        value: '1000000000',   // 1 TON in nano-TON
        bounce: false,
    ),
];

// One-shot: read seqno, sign, broadcast — through your WalletRpcInterface.
$wallet->sendTransfer($rpc, $messages, validUntil: time() + 60);
```

### Sign offline, broadcast later

[](#sign-offline-broadcast-later)

```
use Amashukov\TonCell\Boc;

$seqno = 0; // read out-of-band, or via $wallet->getSeqno($rpc)
$body  = $wallet->createTransfer($seqno, time() + 60, $messages);
$ext   = $wallet->wrapExternalInMessage($body);

$signedBocBase64 = Boc::encodeBase64($ext); // hand to any broadcaster
```

### Parse and re-serialize an address

[](#parse-and-re-serialize-an-address)

```
use Amashukov\TonWallet\Address;

$addr = Address::parse('EQDrjaLahLkMB-hMCmkzOyBuHJ139ZUYmPHu6RRBKnbdLIYI');

$addr->wc;                                  // 0
$addr->toString(userFriendly: false);       // 0:eb8d…  raw workchain:hex
$addr->toTonscanFormat();                    // bounceable url-safe EQ…
Address::isValid('not-an-address');          // false
```

Requirements
------------

[](#requirements)

- PHP 8.3+
- `ext-sodium` (Ed25519 signing)
- `ext-bcmath`

Related packages
----------------

[](#related-packages)

PackageRole[amashukov/ton-cell-php](https://github.com/AndreyMashukov/ton-cell-php)TLB Cell / Builder / BOC layer (dependency)[amashukov/ton-crypto-php](https://github.com/AndreyMashukov/ton-crypto-php)Mnemonic + Ed25519 KeyPair (dependency)[amashukov/toncenter-client-php](https://github.com/AndreyMashukov/toncenter-client-php)Typed toncenter v2 client + ready `WalletRpcInterface` adapter[amashukov/ton-php](https://github.com/AndreyMashukov/ton-php)TON meta-package[amashukov/blockchain-context-bundle](https://github.com/AndreyMashukov/blockchain-context-bundle)Symfony bundle wiring the whole familyQuality
-------

[](#quality)

- **PHPStan level 9**, clean.
- **php-cs-fixer** `@PER-CS` ruleset.
- **GitHub Actions CI** on every push.
- Address derivation pinned against a `@ton/ton` `WalletContractV4` parity vector.

License
-------

[](#license)

MIT — see [LICENSE](LICENSE).

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance98

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

17d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4b3e86ca79a82515b23e0239b1d3616c747e59b64c40e169d538d5c759c9bbc4?d=identicon)[Andrey Mashukov](/maintainers/Andrey%20Mashukov)

---

Top Contributors

[![AndreyMashukov](https://avatars.githubusercontent.com/u/24682497?v=4)](https://github.com/AndreyMashukov "AndreyMashukov (4 commits)")

---

Tags

addressblockchainphpthe-open-networktonwalletwallet-v4r2addresswalletblockchaintonthe open networkwallet-v4r2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/amashukov-ton-wallet-php/health.svg)

```
[![Health](https://phpackages.com/badges/amashukov-ton-wallet-php/health.svg)](https://phpackages.com/packages/amashukov-ton-wallet-php)
```

###  Alternatives

[pkpass/pkpass

PHP PKPass class for iOS Wallet

9823.3M10](/packages/pkpass-pkpass)[olifanton/interop

Olifanton interop library

1071.8k3](/packages/olifanton-interop)[olifanton/ton

PHP library for The Open Network blockchain

9056.6k2](/packages/olifanton-ton)[mlocati/ip-lib

Handle IPv4, IPv6 addresses and ranges

3127.0M58](/packages/mlocati-ip-lib)[eo/passbook

iOS Passbook for PHP

2681.6M3](/packages/eo-passbook)[markrogoyski/ipv4-subnet-calculator

Network calculator for subnet mask and other classless (CIDR) network information.

177839.3k13](/packages/markrogoyski-ipv4-subnet-calculator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
