Daemon JSON RPC API
Daemon JSON RPC is a HTTP server which provides JSON 2.0 RPC interface for interacting with Daemon and Block Explorer.
Daemon JSON RPC is a HTTP server which provides JSON 2.0 RPC interface for interacting with Daemon and Block Explorer.
To start the Daemon JSON RPC API server at http://localhost:43000/json_rpc
run:
./ultranoteid --rpc-bind-port=43000
To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0
switch.
./ultranoteid --rpc-bind-ip=0.0.0.0 --rpc-bind-port=43000
To make a JSON RPC request to your Daemon RPC you should use a POST request that looks like this:
http://localhost:43000/json_rpc
Parameter | Description |
---|---|
|
IP of Daemon RPC, if it is located on local machine it is either 127.0.0.1 or localhost |
Once the rpc service is installed you should be able to send post requests to the and address looking like:
http://<service address>:<service port>/json_rpc
Then, To start using the offered functions, you need to create an object as follows:
require_once( 'ultranote-rpc-php.php' );
$config = [
'rpcUrl' => 'http://localhost:8060/json_rpc',
'rpcUser' => 'theusername',
'rpcPassword' => 'thepassword' ]; $coin = new XuniCoin($config);
Parameter | Description |
---|---|
|
The link to the RPC service |
|
The username of the RPC service (leave empty if none) |
|
The Password of the RPC service (leave empty if none) |
Returns the blockCount of the deamon, usefull to check if the daemon is syncronized.
$coin->getStatus()->blockCount;
39375
Create a new wallet. $coin->createAddress();
'Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3'
Create a new wallet. $address = ''Xuniik72MxR2Cn29BzvV...'; $coin->deleteAddress($address);
true
Parameter | Description |
---|---|
|
The address to delete |
Returns the balance of the given address
$address = 'Xuniik72MxR2Cn29BzvV...'; $coin->deleteAddress($address);
135.32
Parameter | Description |
---|---|
|
The address to check |
Returns the unconfirmed transactions concerning the given address, can be used to check if there are new transactions in the pool. $address =
'Xuniik72MxR2Cn29BzvV...'; $coin->getUnconfirmedTransactionHashes($address);
{'7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb',
'7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb'}
Parameter | Description |
---|---|
|
The address to check |
Returns all the 'N' transactions that happened starting a given block. $firstBlockIndex = 39075; $blockCount=2;
$coin->getTransactions($firstBlockIndex,$blockCount);
{(
[blockHash] => '5acd33b287a2ed31f7a15e34f06a199739577c5cd83ce593170c6c2b034662d2'
[transactions] => {} ), (
[blockHash] => '327e11cec4ffc46bb669477fba434e3c60f36c9ffc0c223c52f30d7b3ff96e73'
[transactions] => {} )}
Parameter | Description |
---|---|
|
The first block to start from |
|
The number of blocks to analyse for transactions |
Returns the details of a given transaction. $transactionHash = '9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7';
$coin->getTransaction($transactionHash);
( [amount] => -1100000 [blockIndex] => 356658 [confirmations] => 87 [extra] =>
'0184fc63971f7a884edd6c79d30bf96b1958bcae9b9413fa29da9d033b187fe275' [fee] => 100000 [isBase] => [paymentId] => [state] => 0 [timestamp] => 1556123357 [transactionHash] =>
'4730d061536e6333dcfcc983b11dd87b1412101f139ca60a5c459032b0efc643' [transfers] =>{(
[address] => 'Xuniik72MxR2Cn29BzvV...'
[amount] => 1000000
[type] => 0
),(
[address] => 'Xuniik72MxR2Cn29BzvV...'
[amount] => 5900000
[type] => 2
),(
[address] => 'Xuniik72MxR2Cn29BzvV...'
[amount] => -7000000
[type] => 0
)
)} [unlockTime] => 0 )
Parameter | Description |
---|---|
|
The hash of the transaction you are interested in |
Sends an ammount of Xun from one address to an other. $from = 'Xuniik72MxR2Cn29BzvV...'; $to='Xuniik72MxR2Cn29BzvV...'; $ammount=1100000;
$coin->sendTransaction($from,$to,$ammount);
'a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828'
Parameter | Description |
---|---|
|
The address of the sender of the currency |
|
The address of the recipient of the currency |
|
Ammount of currency to send |
Same as the sendTransaction function, with more options. $params = [
"addresses"=>["Xuniik72MxR2Cn29BzvV..."],
"anonymity"=> 2,
"fee"=> 100000,
"transfers"=>[
[
"amount"=>1000000,
"address"=>"Xuniik72MxR2Cn29BzvV..."
],
[
"amount"=>3000000,
"address"=>"Xun3cs87FJL5r..."
] ]]; $coin->sendTransactionAdvanced($params);
'a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828'
Parameter | Description |
---|---|
|
Array of Addresses, Addresses which should be charged. Be careful, If you didn't specify addresses the daemon can charge all wallets to collets needed amount. |
|
The anonymity level of the transaction |
|
The fee that you are willing to pay for the transaction |
|
Array of Arrays, Contains couples [ammount, address] of all the transfers you want to execute within the transaction |
Re-sync cointainer starting from 0 block.
Save current container state. Do it before making reserve copies or reboots.
Once the rpc service is installed you should be able to send post requests to the and address looking like:
http://<service address>:<service port>/json_rpc
Returns the blockCount of the deamon, usefull to check if the daemon is syncronized.
curl -d '{"method":"getStatus", "params": {},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"blockCount":30375,
"knownBlockCount":30375,
"lastBlockHash":"ffa6dda0facc4a7ea903b0cededd897d2f281ac09eb6f50b9fed840dfe5073b5",
"peerCount":22
}
}
Create a new wallet.
curl -d '{"method":"createAddress","params": {},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"address":"Xuniik72MxR2Cn29BzvV..."
}
}
Delete wallet.
curl -d '{"method":"deleteAddress","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{}
}
Parameter | Description |
---|---|
|
The address to delete |
Create a new wallet.
curl -d '{"method":"getBalance","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"availableBalance":0,
"lockedAmount":0
}
}
Parameter | Description |
---|---|
|
The address to check |
Returns the unconfirmed transactions concerning the given address, can be used to check if there are new transactions in the pool.
curl -d '{"method":"getUnconfirmedTransactionHashes","params": {"address":"Xuniik72MxR2Cn29BzvV..."},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"transactionHashes":[
"7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb",
"7031309d4a0d87241c3700cafaeeefc04b226dc3387cedef4e93226aa76f21cb"
]
}
}
Parameter | Description |
---|---|
|
The address to check |
Returns all the 'N' transactions that happened starting a given block.
curl -d '{"method":"getTransactions","params": {"firstBlockIndex": 53888, "blockCount": 5},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"items":[
{"blockHash":"ca9179c4e02017adcd538efb3874b1857b4121814c7d15ec15f8fc0a93481466","transactions":[{}]},
{"blockHash":"ca9179c4e02017adcd538efb3874b1857b4121814c7d15ec15f8fc0a93481466","transactions":[{}]}
]
}
}
Parameter | Description |
---|---|
|
The first block to start from |
|
The number of blocks to analyse for transactions |
Returns the details of a given transaction.
curl -d '{"method":"getTransaction","params": {"transactionHash":"9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7"},"jsonrpc": "2.0", "id": "1"}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"transaction":{
"amount":-1000,
"blockIndex":4294967295,
"extra":"015371f8a3cdae5b7ec5fd8e79e3f1d524f8f4d9d884d6c74b81d63e4076b04b1201",
"fee":0,
"isBase":false,
"paymentId":"",
"state":2,
"timestamp":0,
"transactionHash":"9fb36d4bb905ef360c877ce8eba9c9dafc81da27cae85bd4727af46c5ba75ef7",
"transfers":[
{
"address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3",
"amount":1000,
"type":0
},
{
"address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3",
"amount":899000,
"type":2
},
{
"address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3",
"amount":-900000,
"type":0
}
],
"unlockTime":0
}
}
}
Parameter | Description |
---|---|
|
The hash of the transaction you are interested in |
Sends an ammount of Xun from one address to an other.
curl -d '{
"method":"sendTransaction",
"params": {
"addresses":["XuniiZtBPE7e..."],
"anonymity": 2,
"fee": 10000,
"transfers":[
{
"amount":900000,
"address":"XuniiqFybMCT..."
}
]
},
"jsonrpc": "2.0",
"id": "1"
}' http://"username":"password"@localhost:8070/json_rpc
{
"id":"1",
"jsonrpc":"2.0",
"result":{
"transactionhash":"a599cbd0616c60e0ea75aaaac1c79dd8ba23e1ab50eeed6fc48206ec13fd8828..."
}
}
Parameter | Description |
---|---|
|
Array of Addresses, Addresses which should be charged. Be careful, If you didn't specify addresses the daemon can charge all wallets to collets needed amount. |
|
The anonymity level of the transaction |
|
The fee that you are willing to pay for the transaction |
|
Array of Arrays, Contains couples [ammount, address] of all the transfers you want to execute within the transaction |
Re-sync cointainer starting from 0 block.
curl -d '{"jsonrpc":"2.0","id":1, "method":"reset","params":{"scanHeight":100000}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{}
}
Save current container state. Do it before making reserve copies or reboots.
curl -d '{"jsonrpc":"2.0","id":1, "method":"save","params":{}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{}
}
Returns your view key.
curl -d '{"jsonrpc":"2.0","id":1,"method":"getViewKey","params":{}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{
"viewSecretKey":"xxxxx..."
}
}
Returns your spend keys.
curl -d '{"jsonrpc":"2.0","id":1,"params":{"address":"Xuniik72MxR2Cn29BzvVcsPmPn2NxNPGHfpYocW7CrjhLVs928LUmgfBJnVJE1xoHy8fdL3dVcLzF49J9Y8SsryHYMWMX4BySs3"}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{
"spendSecretKey":"xxxxx...",
"spendPublicKey":"xxxxx..."
}
}
Returns an array of block hashes for a specified block range.
curl -d '{"jsonrpc":"2.0","id":1,"method":"getBlockHashes","params":{"firstBlockIndex":0,"blockCount":3}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{
"blockHashes":[
"7fb97...",
"8c973...",
"2ef06..."
]
}
}
sendFusionTransaction method allows you to send a fusion transaction, by taking funds from selected addresses and transferring them to the destination address
If there aren't any outputs that can be optimized, sendFusionTransaction will return an error.
You can use estimateFusion to check the outputs, available for the optimization.
curl -d '{"jsonrpc":"2.0","id":1,"method":"sendFusionTransaction","params":{"threshold":1000,"anonymity":2,"address":["XuniihE4LneQDtUjFTiP..."],"destinationAddress":"XuniihE4LneQDtUjFTiP..."}}' http://localhost:8070/json_rpc
{
"id":1,
"jsonrpc":"2.0",
"result":{
"transactionHash":"93faed..."
}
}
Didn't find an answer to your question?