PHP code example of jeyroik / toncenter-php-sdk
1. Go to this page and download the library: Download jeyroik/toncenter-php-sdk 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/ */
jeyroik / toncenter-php-sdk example snippets
$address = new Address([Address::FIELD__HASH => 'EQA6VbfxOrYGXvQw-VEpqeFKD1YDtX7JkQmENXOTV93Am0Yr']);
$address->loadInformation();
echo $address->getBalance(); // 15684203405
echo $address->getBalanceAsToncoins(); // 15,684203405
echo $address->getLastTransation()->getHash();
$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;
}
bash
toncenter-php-sdk$ export TONC__TOKEN=<your token>