jeyroik / toncenter-php-sdk
PHP SDK for toncenter.com
Installs: 317
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/jeyroik/toncenter-php-sdk
Requires
- guzzlehttp/guzzle: 7.*
Requires (Dev)
- phpstan/phpstan: 0.*
- phpunit/phpunit: ^9
This package is auto-updated.
Last update: 2025-09-20 18:30:32 UTC
README
PHP SDK for toncenter
SDK allow to work with https://toncenter.com/api/v2/
usage
Set your token (there is rps limit 1 without token)
toncenter-php-sdk$ export TONC__TOKEN=<your token>
You can get your token in the @tonapibot to get access with higher limits.
Working with address
$address = new Address([Address::FIELD__HASH => 'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0Yr']); $address->loadInformation(); echo $address->getBalance(); // 15684203405 echo $address->getBalanceAsToncoins(); // 15,684203405 echo $address->getLastTransation()->getHash();
Working with transactions
$repo = new TransactionRepository(); $transaction = $repo->one( 'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0yr', // by which address need to search transactions [ ITransaction::FIELD__IN_MESSAGE => [ ITransactionInMessage::FIELD__SOURCE => ['=', 'EQCtiv7PrMJImWiF2L5oJCgPnzp-VML2CAt5cbn1VsKAxLiE'], ITransactionInMessage::FIELD__VALUE => ['>', '9600000000'], //9.6 toncoins ITransactionInMessage::FIELD__MESSAGE_DATA => [ ITransactionMessageData::FIELD__TEXT => ['like', 'ZWZ'] ] ], ITransaction::FIELD__FEE => ['in', [1192940]] ] ); echo $transaction->getId()->getHash() . PHP_EOL; $transactions = $repo->all( 'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0yr', [ ITransaction::FIELD__IN_MESSAGE => [ ITransactionInMessage::FIELD__SOURCE => ['=', 'EQCtiv7PrMJImWiF2L5oJCgPnzp-VML2CAt5cbn1VsKAxLiE'], ] ] ); foreach($transactions as $transaction) { echo $transaction->getId()->getHash() . PHP_EOL; }
Enabled conditions
=
equal!=
not equal>
greater>=
greater or equal<
lower<=
lower or equalin
equal to one among a given listnin
not equal to none of all given listlike
containsnlike
not contains