1. Go to this page and download the library: Download azartpay/azart-rpc-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/ */
azartpay / azart-rpc-php example snippets
composer.phar
composer.phar update
use AzartPay\Azart\Client as AzartClient;
$azartd = new AzartClient('http://rpcuser:rpcpassword@localhost:9798/');
/**
* Get block info.
*/
$block = $azartd->getBlock('000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9');
$block('hash')->get(); // 000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9
$block['height']; // 0 (array access)
$block->get('tx.0'); // 44701bbc011bdd471b75fa83e42acc8e067759a69cdeef723df57181a33e5467
$block->count('tx'); // 1
$block->has('version'); // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0); // check if response contains value
$block->values(); // array of values
$block->keys(); // array of keys
$block->random(1, 'tx'); // random block txid
$block('tx')->random(2); // two random block txid's
$block('tx')->first(); // txid of first transaction
$block('tx')->last(); // txid of last transaction
/**
* Send transaction.
*/
$result = $azartd->sendToAddress('AqUM31KtkxgbMwYrrpUi6RVjaftK3Mv5mG', 0.1);
$txid = $result->get();
/**
* Get transaction amount.
*/
$result = $azartd->listSinceBlock();
$totalAmount = $result->sum('transactions.*.amount');
$totalSatoshi = AzartClient::toSatoshi($totalAmount);
use AzartPay\Azart\AzartdResponse;
$promise = $azartd->getBlockAsync(
'000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9',
function (AzartdResponse $success) {
//
},
function (\Exception $exception) {
//
}
);
$promise->wait();
/**
* Get block info.
*/
$block = $azartd->request('getBlock', '000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9');
$block('hash'); // 000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9
$block['height']; // 0 (array access)
$block->get('tx.0'); // 44701bbc011bdd471b75fa83e42acc8e067759a69cdeef723df57181a33e5467
$block->count('tx'); // 1
$block->has('version'); // key must exist and CAN NOT be null
$block->exists('version'); // key must exist and CAN be null
$block->contains(0); // check if response contains value
$block->values(); // get response values
$block->keys(); // get response keys
$block->first('tx'); // get txid of the first transaction
$block->last('tx'); // get txid of the last transaction
$block->random(1, 'tx'); // get random txid
/**
* Send transaction.
*/
$result = $azartd->request('sendtoaddress', ['AqUM31KtkxgbMwYrrpUi6RVjaftK3Mv5mG', 0.06]);
$txid = $result->get();
use AzartPay\Azart\AzartdResponse;
$promise = $azartd->requestAsync(
'getBlock',
'000009b9903dae4466d48db6c264d711ac554492da34cd0bfa4c0b6d230f29c9',
function (AzartdResponse $success) {
//
},
function (\Exception $exception) {
//
}
);
$promise->wait();
javascript
"pay/azart-rpc-php": "2.0.3"
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.