1. Go to this page and download the library: Download amashukov/ton-wallet-php library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
amashukov / ton-wallet-php example snippets
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)
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);
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