1. Go to this page and download the library: Download extraton/php-ton-client 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/ */
// Create new instance with custom configuration and default path to TON SDK library
$tonClient = new TonClient($config);
// Create new instance TonClient with custom path to TON SDK library
$binding = new Binding('PATH_TO_TON_SDK_LIBRARY');
$tonClient = new TonClient($config, $binding);
// Get TON SDK version
$result = $tonClient->version();
echo "TON SDK version: " , $result->getVersion() . PHP_EOL;
class Filters implements Params
{
public const EQ = 'eq';
public const GE = 'ge';
public const GT = 'gt';
public const IN = 'in';
public const LE = 'le';
public const LT = 'lt';
public const NE = 'ne';
public const NOT_IN = 'notIn';
...
class OrderBy implements Params
{
public const ASC = 'ASC';
public const DESC = 'DESC';
...
// Build query
$query = (new ParamsOfSubscribeCollection('transactions'))
->addResultField('id', 'block_id', 'balance_delta')
->addFilter('balance_delta', Filters::GT, '0x5f5e100');
// Get result with handle and start watching
$result = $net->subscribeCollection($query);
echo "Handle: {$result->getHandle()}." . PHP_EOL;
$counter = 0;
// Iterate generator
foreach ($result->getIterator() as $event) {
$counter++;
echo "Event counter: {$counter}, event data:" . PHP_EOL;
var_dump($event->getResult());
if ($counter > 25) {
echo 'Manual stop watching.' . PHP_EOL;
$result->stop(); // or call: $net->unsubscribe($result->getHandle());
}
}
echo 'Finished.' . PHP_EOL;