1. Go to this page and download the library: Download ftab/php-dogecoinrpc 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/ */
ftab / php-dogecoinrpc example snippets
composer.phar
composer.phar install
/**
* Don't forget to include composer autoloader by uncommenting line below
* if you're not already done it anywhere else in your project.
**/
//
/**
* Don't forget to include composer autoloader by uncommenting line below
* if you're not already done it anywhere else in your project.
**/
// ttp
'host' => 'localhost', // optional, default localhost
'port' => 22555, // optional, default 22555
'user' => 'rpcuser', //
/**
* Get block info.
*/
$block = $dogecoind->getBlock('1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691');
$block('hash')->get(); // 1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691
$block['height']; // 0 (array access)
$block->get('tx.0'); // 5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69
$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 = $dogecoind->sendToAddress('DATfurydmRTZ6vJnBtaibHJYMdx9JYjL4n', 100);
$txid = $result->get();
/**
* Get transaction amount.
*/
$result = $dogecoind->listSinceBlock();
$dogecoin = $result->sum('transactions.*.amount');
$dogetoshi = \ftab\Dogecoin\to_dogetoshi($dogecoin);
$dogecoind->getBlockAsync(
'1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691',
function ($response) {
// success
},
function ($exception) {
// error
}
);
/**
* Get block info.
*/
$block = $dogecoind->request('getBlock', '1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691');
$block('hash'); // 1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691
$block['height']; // 0 (array access)
$block->get('tx.0'); // 5b2a3f53f605d62c53e62932dac6925e3d74afa5a4b459745c36d42d0ed26a69
$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 = $dogecoind->request('sendtoaddress', 'DATfurydmRTZ6vJnBtaibHJYMdx9JYjL4n', 60);
$txid = $result->get();
$dogecoind->requestAsync(
'getBlock',
'1a91e3dace36e2be3bf030a65679fe821aa1d6ef92e7c9902eb318182c355691',
function ($response) {
// success
},
function ($exception) {
// error
}
);