XTE and XTCASH documentation

XTE and XTCASH documentation

  • Getting Started
  • About
  • FAQ
  • Guides
  • For Developers

›API Documentation

For Developers

  • Developer Resources
  • Local Testnet
  • API Documentation

    • Daemon JSON RPC API
    • Daemon HTTP RPC API
    • Wallet RPC API
    • XTEservice Wallet RPC API
    • RPC Errors
Edit

Daemon JSON RPC API

The daemon JSON RPC is a HTTP server which provides JSON 2.0 RPC interface for interacting with a daemon and a block explorer.

Currently we support the following official client bindings:

  • NodeJS
  • PHP
  • Python
  • Go

Installation

NodeJS
PHP
Python
Go
npm i traaittcash-rpc
composer require trrxitte/traaittcash-rpc-php
pip3 install traaittcash
go get github.com/trrxitte/traaittcash-rpc-go

Interacting with the API

API endpoint example

http://localhost:14486/json_rpc

Configuration and Instantiation

To start the Daemon JSON RPC API server at http://localhost:11898/json_rpc, run:

XTCASHnetwork --rpc-bind-port=14486

To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0 switch.

XTCASHnetwork --rpc-bind-ip=0.0.0.0 --rpc-bind-port=14486

To enable block explorer API access (like for getblocks, gettransactionpool, etc.), use the --enable-blockexplorer switch.

XTCASHnetwork --enable-blockexplorer

The above given switches can be combined to achieve remote access with block explorer methods as shown below.

XTCASHnetwork --enable-blockexplorer --rpc-bind-ip=0.0.0.0 --rpc-bind-port=14486

This would make the RPC server accessible at

http://<your ip address>:14486/json_rpc

and, locally at

http://localhost:14486/json_rpc

To make a JSON RPC request to your Daemon RPC you should use a GET request that looks like this:

http://<service address>:<service port>/json_rpc

ParameterDescription
<service address>IP of Daemon RPC, if it is located on local machine it is either 127.0.0.1 or localhost
<service port>Daemon RPC port, by default it is bound to 14486 port, but it can be manually bound to any port you want
NodeJS
PHP
Python
Go
const XTCASHnetwork = require('traaittcash-rpc').XTCASHnetwork

const daemon = new XTCASHnetwork({
host: '0.0.0.0', // ip address or hostname of the traaittXTCASH network host
port: 14486, // what port is the RPC server running on
timeout: 2000, // request timeout
ssl: false // whether we need to connect using SSL/TLS
})
<?php
use traaittXTCASH\XTCASHnetwork;

$config = [
'rpcHost' => 'http://localhost',
'rpcPort' => 14486,
];

$xtcashnetwork = new XTCASHnetwork($config);
from traaittcash import XTCASHnetwork

rpc_host = 'localhost'
rpc_port = 14486
xtcashnetwork = XTCASHnetwork(rpc_host, rpc_port)
import (
"fmt"
trpc "github.com/trrxxitte/traaittcash-rpc-go"
)

rpcHost := "localhost"
rpcPort := 14486

daemon := trpc.XTCASHnetwork{
URL: rpcHost,
Port: rpcPort}

getblockcount

getblockcount() method returns the current chain height.

No Input.

Output

ArgumentDescriptionFormat
countCurrent chain heightint
statusStatus of requeststring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0", "method":"getblockcount", "params":{}}' http://localhost:14486/json_rpc
daemon.getBlockCount().then((blockCount) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $xtcashnetwork->getBlockCount();
echo $response;
response = xtcashnetwork.get_block_count()
print(response)
response := daemon.GetBlockCount()
fmt.Println(response)

Expected Output

{
    "jsonrpc":"2.0",
    "result":{
        "count":560915,
        "status":"OK"
    }
}

getblockhash

getblockhash() method returns block hash for a given height off by one.

Input

ArgumentMandatoryDescriptionFormat
heightYesThe height of the block whose previous hash is to be retrieved.int

Output

ArgumentDescriptionFormat
resultHash of previous blockint
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"on_getblockhash","params":[123456]}' http://localhost:14486/json_rpc
daemon.getBlockHash({
height: 500000
}).then((blockHash) => {
// do something
}).catch((error) => {
// do something
})
<?php
$height = 123456;
$response = $xtcashnetwork->getBlockHash($height);
echo $response;
height = 123456
response = xtcashnetwork.get_block_hash(height)
print(response)
height := 123456
response := daemon.GetBlockHash(height)
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":"4bd7d..."
}

getblocktemplate

getblocktemplate(reserve_size, addr) method returns blocktemplate with an empty "hole" for nonce.

Input

ArgumentMandatoryDescriptionFormat
reserve_sizeYesSize of the reserve to be specifiedint
wallet_addressYesValid TurtleCoin wallet addressString

Output

ArgumentDescriptionFormat
blocktempate_blobBlocktemplate with empty "hole" for noncestring
difficultyDifficulty of the networkint
heightChain height of the networkint
reserved_offsetOffset reservedint
statusStatus of the networkstring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"getblocktemplate","params":{"reserve_size":200,"wallet_address":"cashxxxx..."}}' http://localhost:14486/json_rpc
daemon.getBlockTemplate({
reserveSize: 200,
walletAddress: 'cashv1pacKFJk9QgSmzk2LJWn14JGmTKzReFLz1RgY3K9Ryn7783RDT2TretzfYdck5GMCGzXTuwKfePWQYViNs4avKpnUbrwf'
}).then((blockTemplate) => {
// do something
}).catch((error) => {
// do something
})
<?php
$reserveSize = 200;
$address = 'cashxxxx...';
$response = $xtcashnetwork->getBlockTemplate($reserveSize, $address);
echo $response;
reserve_size = 200
wallet_address = 'cashxxxx...'

response = xtcashnetwork.get_block_template(reserve_size, wallet_address)
print(response)
reserveSize := 200
walletAddress := "cashxxxx..."

response := daemon.GetBlockTemplate(reserveSize, walletAddress)
fmt.Println(response)

Expected Output:

{
    "jsonrpc": "2.0",
    "result": {
        "blocktemplate_blob": "0100de...",
        "difficulty": 65563,
        "height": 123456,
        "reserved_offset": 395,
        "status": "OK"
    }
}

submitblock

submitblock(block_blob) method submits mined block.

Input

ArgumentMandatoryDescriptionFormat
block_blobYesBlock blob of the mined blockstring

Output

ArgumentDescriptionFormat
statusStatus of requeststring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"submitblock","params":["0100b...."]}' https://localhost:14486/json_rpc
daemon.submitBlock({
blockBlob: '...'
}).then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$blockBlob = '0100b...';
$response = $xtcashnetwork->submitBlock($blockBlob);
echo $response;
block_blob = '0100b...'
response = xtcashnetwork.submit_block(block_blob)
print(response)
blockBlob := "0100b..."
response := daemon.SubmitBlock(blockBlob)
fmt.Println(response)

Expected Output:

{
    "jsonrpc": "2.0",
    "result": {
        "status" : "OK"
    }
}

getlastblockheader

getlastblockheader method returns the block header of the last block.

No Input

Output

ArgumentDescriptionFormat
block_sizesize of the blockint
depthheight away from the known top blockint
difficultydifficulty of the last blockint
hashhash of the last blockstring
heightheight of the last blockint
major_version-int
minor_version-int
nonce-int
num_txsNumber of transactions in the blockint
orphan_statuswhether the last block was an orphan or notbool
prev_hashhash of the previous blockstring
rewardreward of the blockstr
timestampthe time at which the block is occured on chain since Unix epochint
statusstatus of the requeststring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"getlastblockheader","params":{}}' http://localhost:14486/json_rpc
daemon.getLastBlockHeader().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $xtcashnetwork->getLastBlockHeader();
echo $response;
response = xtcashnetwork.get_last_block_header()
print(response)
response := daemon.GetLastBlockHeader()
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "block_header":{
            "block_size":86171,
            "depth":0,
            "difficulty":431119113,
            "hash":"b746b...",
            "height":561342,
            "major_version":4,
            "minor_version":0,
            "nonce":715846563,
            "num_txes":4,
            "orphan_status":false,
            "prev_hash":"b8e02...",
            "reward":2930801,
            "timestamp":1529750993
        },
        "status":"OK"
    }
}

getblockheaderbyhash

getblockheaderbyhash() returns block header by given block hash

Input

ArgumentMandatoryDescriptionFormat
hashYesHash of the blockstring

Output

ArgumentDescriptionFormat
block_sizesize of the blockint
depthheight away from the known top blockint
difficultydifficulty of the requested blockint
hashhash of the requested blockstring
heightheight of the requested blockint
major_version-int
minor_version-int
nonce-int
num_txsNumber of transactions in the blockint
orphan_statuswhether the requested block was an orphan or notbool
prev_hashhash of the previous blockstring
rewardreward of the blockstr
timestampthe time at which the block is occured on chain since Unix epochint
statusstatus of the requeststring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"getblockheaderbyhash","params":{"hash":"30706..."}}' http://localhost:14486/json_rpc
daemon.getBlockHeaderByHash({
hash: '7d6db7b77232d41c19d898e81c85ecf08c4e8dfa3434f975a319f6261a695739'
}).then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$hash = '30706...';
$response = $xtcashnetwork->getBlockHeaderByHash($hash);
echo $response;
hash = '30706...'
response = xtcashnetwork.get_block_header_by_hash(hash)
print(response)
hash := "30706..."
response := daemon.GetBlockHeaderByHash(hash)
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "block_header":{
            "block_size":11640,
            "depth":437898,
            "difficulty":70050782,
            "hash":"30706...",
            "height":123456,
            "major_version":3,
            "minor_version":0,
            "nonce":3177228614,
            "num_txes":3,
            "orphan_status":false,
            "prev_hash":"4bd7d...",
            "reward":2969487,
            "timestamp":1516631879
        },
    "status":"OK"
    }
}

getblockheaderbyheight

getblockheaderbyheight() method returns block header by given block height

Input

ArgumentMandatoryDescriptionFormat
heightYesHeight of the blockint

Output

ArgumentDescriptionFormat
block_sizesize of the blockint
depthheight away from the known top blockint
difficultydifficulty of the requested blockint
hashhash of the requested blockstring
heightheight of the requested blockint
major_version-int
minor_version-int
nonce-int
num_txsNumber of transactions in the blockint
orphan_statuswhether the requested block was an orphan or notbool
prev_hashhash of the previous blockstring
rewardreward of the blockstr
timestampthe time at which the block is occured on chain since Unix epochint
statusstatus of the requeststring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"getblockheaderbyheight","params":{"height":123456}}' http://localhost:14486/json_rpc
daemon.getBlockHeaderByHeight({
height: 502345
}).then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$height = 123456;
$response = $xtcashnetwork->getBlockHeaderByHeight($height);
echo $response;
height = 123456
response = xtcashnetwork.get_block_header_by_height(height)
print(response)
height := 123456
response := daemon.GetBlockHeaderByHeight(height)
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "block_header":{
            "block_size":11640,
            "depth":437898,
            "difficulty":70050782,
            "hash":"30706...",
            "height":123456,
            "major_version":3,
            "minor_version":0,
            "nonce":3177228614,
            "num_txes":3,
            "orphan_status":false,
            "prev_hash":"4bd7d...",
            "reward":2969487,
            "timestamp":1516631879
        },
    "status":"OK"
    }
}

getcurrencyid

getcurrencyid() method returns unique currency identifier.

No Input

Output

ArgumentDescriptionFormat
currency_id_blobunique currency identifierstring
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"getcurrencyid","params":{}}' http://localhost:14486/json_rpc
daemon.getCurrencyId().then((result) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $xtcashnetwork->getCurrencyId();
echo $response;
response = xtcashnetwork.get_currency_id()
print(response)
response := daemon.GetCurrencyID()
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "currency_id_blob":"7fb97..."
    }
}

getblocks

getblocks() method returns information on the last 30 blocks from height (inclusive)

Input

ArgumentMandatoryDescriptionFormat
heightYesheight of the last block to be included in the result.int

Output

ArgumentDescriptionFormat
statusstatus of the requeststring
blocksArray of
cumul_sizesize of the blockint
difficultydifficulty of the blockint
hashhash of the blockstring
heightheight of the blockint
timestampthe time at which the block is occured on the chain since Unix epochint
tx_countnumber of transactions in the blockint
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"f_blocks_list_json","params":{"height":500000}}' http://localhost:14486/json_rpc
daemon.getBlocks({
height: 500000
}).then((blocks) => {
// do something
}).catch((error) => {
// do something
})
<?php
$height = 500000;
$response = $xtcashnetwork->getBlocks($height);
echo $response;
height = 500000
response = xtcashnetwork.get_blocks(height)
print(response)
height := 500000
response := daemon.GetBlocks(height)
fmt.Println(response)

Expected Output:

{
    "jsonrpc": "2.0",
    "result": {
        "blocks":[
            {
                "cumul_size": 22041,
                "difficulty": 285124963,
                "hash": "62f00...",
                "height": 500000,
                "timestamp": 1527834137,
                "tx_count": 4
            }
        ],
        "status": "OK"
    }
}

getblock

getblock() method returns information on a single block

Input

ArgumentMandatoryDescriptionFormat
hashYeshash of the blockstring

Output

ArgumentDescriptionFormat
alreadyGeneratedCoinstotal number of coins generated in the network upto that blockstring
alreadyGeneratedTransactionstotal number of transactions present in the network upto that blockint
baseRewardcalculated rewardint
block_sizesize of the blockint
depthheight away from the known top blockint
difficultydifficulty of the requested blockint
effectiveSizeMedianfixed constant for max size of blockint
hashhash of the requested blockstring
heightheight of the requested blockint
major_version-int
minor_version-int
nonce-int
orphan_statuswhether the requested block was an orphan or notbool
penaltypenalty in block reward determined for deviationfloat
prev_hashhash of the previous blockstring
rewardtotal reward of the block after removing penaltystr
sizeMediancalculated median size from last 100 blocksint
timestampthe time at which the block is occured on chain since Unix epochint
totalFeeAmounttotal fees for the transactions in the blockint
transactionsArray of transactions in the blockarray
transactionsCumulativeSizetotal sum of size of all transactions in the blockint
statusstatus of the requeststring

Transaction Attributes:

ArgumentDescriptionFormat
amount_outoutput amount of the transactionint
feefees for the transactionint
hashhash of the transactionstring
sizesize of the transactionint
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"f_block_json","params":{"hash":"980ff..."}}' http://localhost:14486/json_rpc
daemon.getBlock({
hash: 'f11580d74134ac34673c74f8da458080aacbe1eccea05b197e9d10bde05139f5'
}).then((block) => {
// do something
}).catch((error) => {
// do something
})
<?php
$hash = '980ff...';
$response = $xtcashnetwork->getBlock($hash);
echo $response;
hash = '980ff...'
response = xtcashnetwork.get_block(hash)
print(response)
hash := "980ff..."
response := daemon.GetBlock(hash)
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "block":{
            "alreadyGeneratedCoins":"1659188157030",
            "alreadyGeneratedTransactions":1097221,
            "baseReward":2930784,
            "blockSize":384,
            "depth":1,
            "difficulty":264289473,
            "effectiveSizeMedian":100000,
            "hash":"980ff...",
            "height":561537,
            "major_version":4,
            "minor_version":0,
            "nonce":60779,
            "orphan_status":false,
            "penalty":0.0,
            "prev_hash":"c37f8...",
            "reward":2930784,
            "sizeMedian":265,
            "timestamp":1529757254,
            "totalFeeAmount":0,
            "transactions":[
                {
                    "amount_out":2930784,
                    "fee":0,
                    "hash":"c0a2d...",
                    "size":265
                }
            ],
            "transactionsCumulativeSize":265
        },
        "status":"OK"
    }
}

gettransaction

gettransaction() method returns information on single transaction.

Input

ArgumentMandatoryDescriptionFormat
hashYeshash of the transactionstring

Output

ArgumentDescriptionFormat
blockdetails of the block in which transaction is presentjson object
statusstatus of the requeststring
txsub-transactions in the transactionjson object
txDetailsdetails of the transactionjson object

Block attributes:

ArgumentDescriptionFormat
cumul_sizesize of the blockint
difficultydifficulty of the blockint
hashhash of the blockstring
heightheight of the blockint
timestampthe time at which the block is occured on chain since Unix epochint
tx_countnumber of transactions in the blockint

Transaction Details attributes:

ArgumentDescriptionFormat
amount_outtotal amount present in the transactionint
feetotal fees of the transactionint
hashhash of the transactionstring
mixinmixin of the transactionint
paymentIdpayment Id of the transactionstring
sizetotal size of the transactionint

Transaction attributes:

ArgumentDescriptionFormat
extraTransaction extra which can be any information in hexstring
unlock_timedelay in unlocking the amountint
version-int
vinarray of input transactionsarray
voutarray of output transactionsarray
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"f_transaction_json","params":{"hash":"702ad..."}}' http://localhost:14486/json_rpc
daemon.getTransaction({
hash: '702ad5bd04b9eff14b080d508f69a320da1909e989d6c163c18f80ae7a5ab832'
}).then((transaction) => {
// do something
}).catch((error) => {
// do something
})
<?php
$hash = '702ad...';
$response = $xtcashnetwork->getTransaction($hash);
echo $response;
hash = '702ad...'
response = xtcashnetwork.get_transaction(hash)
print(response)
hash := "702ad..."
response := daemon.GetTransaction(hash)
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "block":{
            "cumul_size":22041,
            "difficulty":106780143,
            "hash":"62f00...",
            "height":500000,
            "timestamp":1527834137,
            "tx_count":4
        },
        "status":"OK",
        "tx":{
            "extra":"019e4...",
            "unlock_time":500040,
            "version":1,
            "vin":[
                {
                    "type":"ff",
                    "value":{
                        "height":500000
                    }
                }
            ],
            "vout":[
                {
                    "amount":80,
                    "target":{
                        "data":{
                            "key":"5ce69..."
                        },
                        "type":"02"
                    }
                }
            ]
        },
        "txDetails":{
            "amount_out":2936280,
            "fee":0,
            "hash":"702ad...",
            "mixin":0,
            "paymentId":"",
            "size":266
        }
    }
}

gettransactionpool

gettransactionpool() returns the list of transaction hashes present in mempool

No Input

Output

ArgumentDescriptionFormat
statusstatus of the requeststring
transactionsarray of transactions in mempoolarray

Transactions attributes:

ArgumentDescriptionFormat
amount_outoutput amount of the transactionint
feefees for the transactionint
hashhash of the transactionstring
sizesize of the transactionint
Shell
NodeJS
PHP
Python
Go
curl -d '{"jsonrpc":"2.0","method":"f_on_transactions_pool_json","params":{}}' http://localhost:14486/json_rpc
daemon.getTransactionPool().then((transactions) => {
// do something
}).catch((error) => {
// do something
})
<?php
$response = $xtcashnetwork->getTransactionPool();
echo $response;
response = xtcashnetwork.get_transaction_pool()
print(response)
response := daemon.GetTransactionPool()
fmt.Println(response)

Expected Output:

{
    "jsonrpc":"2.0",
    "result":{
        "status":"OK",
        "transactions":[
            {
                "amount_out":8990,
                "fee":10,
                "hash":"a5e88...",
                "size":541
            }
        ]
    }
}

License

Creative Commons License

The content in this document was originally written by the Bytecoin (BCN) Developers. It is licensed under the CC BY SA 3.0 license. The source material can be found at the Bytecoin Wiki.

TRRXITTE Int., incorporate has adapted the TurtleCoin developers, altered and adapted version of the content to suit our implementation of the API. This was done independently of the Bytecoin development team. They neither endorse or acknowledge our changes. Feel free to adopt or change our content as per the CC BY SA 3.0 license requirements.

Last updated on 4.7.2024
← PreviousDaemon HTTP RPC API →
  • Installation
  • Interacting with the API
    • API endpoint example
    • Configuration and Instantiation
  • getblockcount
  • getblockhash
  • getblocktemplate
  • submitblock
  • getlastblockheader
  • getblockheaderbyhash
  • getblockheaderbyheight
  • getcurrencyid
  • getblocks
  • getblock
  • gettransaction
  • gettransactionpool
  • License
XTE and XTCASH documentation
Docs
Getting StartedAboutGuidesDeveloper Resources
Community
Generalx.com
More
GitHubStar
Copyright © 2024 TRRXITTE Int., incorporate
Docs released under the MIT License
cryptocurrencies released under the GNU General Public V3 License