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.
Installation
Interacting with the API
API endpoint example
Configuration and Instantiation
To start the Daemon JSON RPC API server at http://localhost:11898/json_rpc
, run:
kryptokrona --rpc-bind-port=11898
To make the server accessible from another computer, use the --rpc-bind-ip 0.0.0.0
switch.
kryptokrona --rpc-bind-ip=0.0.0.0 --rpc-bind-port=11898
To enable block explorer API access (like for getblocks
, gettransactionpool
, etc.), use the --enable-blockexplorer
switch.
kryptokrona --enable-blockexplorer
The above given switches can be combined to achieve remote access with block explorer methods as shown below.
kryptokrona --enable-blockexplorer --rpc-bind-ip=0.0.0.0 --rpc-bind-port=11898
This would make the RPC server accessible at
http://<your ip address>:11898/json_rpc
and, locally at
http://localhost:11898/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
<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 11898 port, but it can be manually bound to any port you want
getblockcount
getblockcount()
method returns the current chain height.
No Input.
Output
count
Current chain height
int
status
Status of request
string
Expected Output
getblockhash
getblockhash()
method returns block hash for a given height off by one.
Input
height
Yes
The height of the block whose previous hash is to be retrieved.
int
Output
result
Hash of previous block
int
Expected Output:
getblocktemplate
getblocktemplate(reserve_size, addr)
method returns blocktemplate with an empty "hole" for nonce.
Input
reserve_size
Yes
Size of the reserve to be specified
int
wallet_address
Yes
Valid kryptokrona wallet address
String
Output
blocktempate_blob
Blocktemplate with empty "hole" for nonce
string
difficulty
Difficulty of the network
int
height
Chain height of the network
int
reserved_offset
Offset reserved
int
status
Status of the network
string
Expected Output:
submitblock
submitblock(block_blob)
method submits mined block.
Input
block_blob
Yes
Block blob of the mined block
string
Output
status
Status of request
string
Expected Output:
getlastblockheader
getlastblockheader
method returns the block header of the last block.
No Input
Output
block_size
size of the block
int
depth
height away from the known top block
int
difficulty
difficulty of the last block
int
hash
hash of the last block
string
height
height of the last block
int
major_version
-
int
minor_version
-
int
nonce
-
int
num_txs
Number of transactions in the block
int
orphan_status
whether the last block was an orphan or not
bool
prev_hash
hash of the previous block
string
reward
reward of the block
str
timestamp
the time at which the block is occured on chain since Unix epoch
int
status
status of the request
string
Expected Output:
getblockheaderbyhash
getblockheaderbyhash()
returns block header by given block hash
Input
hash
Yes
Hash of the block
string
Output
block_size
size of the block
int
depth
height away from the known top block
int
difficulty
difficulty of the requested block
int
hash
hash of the requested block
string
height
height of the requested block
int
major_version
-
int
minor_version
-
int
nonce
-
int
num_txs
Number of transactions in the block
int
orphan_status
whether the requested block was an orphan or not
bool
prev_hash
hash of the previous block
string
reward
reward of the block
str
timestamp
the time at which the block is occured on chain since Unix epoch
int
status
status of the request
string
Expected Output:
getblockheaderbyheight
getblockheaderbyheight()
method returns block header by given block height
Input
height
Yes
Height of the block
int
Output
block_size
size of the block
int
depth
height away from the known top block
int
difficulty
difficulty of the requested block
int
hash
hash of the requested block
string
height
height of the requested block
int
major_version
-
int
minor_version
-
int
nonce
-
int
num_txs
Number of transactions in the block
int
orphan_status
whether the requested block was an orphan or not
bool
prev_hash
hash of the previous block
string
reward
reward of the block
str
timestamp
the time at which the block is occured on chain since Unix epoch
int
status
status of the request
string
Expected Output:
getcurrencyid
getcurrencyid()
method returns unique currency identifier.
No Input
Output
currency_id_blob
unique currency identifier
string
Expected Output:
getblocks
getblocks()
method returns information on the last 30 blocks from height (inclusive)
Input
height
Yes
height of the last block to be included in the result.
int
Output
status
status of the request
string
blocks
Array of
Expected Output:
getblock
getblock()
method returns information on a single block
Input
hash
Yes
hash of the block
string
Output
alreadyGeneratedCoins
total number of coins generated in the network upto that block
string
alreadyGeneratedTransactions
total number of transactions present in the network upto that block
int
baseReward
calculated reward
int
block_size
size of the block
int
depth
height away from the known top block
int
difficulty
difficulty of the requested block
int
effectiveSizeMedian
fixed constant for max size of block
int
hash
hash of the requested block
string
height
height of the requested block
int
major_version
-
int
minor_version
-
int
nonce
-
int
orphan_status
whether the requested block was an orphan or not
bool
penalty
penalty in block reward determined for deviation
float
prev_hash
hash of the previous block
string
reward
total reward of the block after removing penalty
str
sizeMedian
calculated median size from last 100 blocks
int
timestamp
the time at which the block is occured on chain since Unix epoch
int
totalFeeAmount
total fees for the transactions in the block
int
transactions
Array of transactions in the block
array
transactionsCumulativeSize
total sum of size of all transactions in the block
int
status
status of the request
string
Transaction Attributes:
amount_out
output amount of the transaction
int
fee
fees for the transaction
int
hash
hash of the transaction
string
size
size of the transaction
int
Expected Output:
gettransaction
gettransaction()
method returns information on single transaction.
Input
hash
Yes
hash of the transaction
string
Output
block
details of the block in which transaction is present
json object
status
status of the request
string
tx
sub-transactions in the transaction
json object
txDetails
details of the transaction
json object
Block attributes:
cumul_size
size of the block
int
difficulty
difficulty of the block
int
hash
hash of the block
string
height
height of the block
int
timestamp
the time at which the block is occured on chain since Unix epoch
int
tx_count
number of transactions in the block
int
Transaction Details attributes:
amount_out
total amount present in the transaction
int
fee
total fees of the transaction
int
hash
hash of the transaction
string
mixin
mixin of the transaction
int
paymentId
payment Id of the transaction
string
size
total size of the transaction
int
Transaction attributes:
extra
Transaction extra which can be any information in hex
string
unlock_time
delay in unlocking the amount
int
version
-
int
vin
array of input transactions
array
vout
array of output transactions
array
Expected Output:
gettransactionpool
gettransactionpool()
returns the list of transaction hashes present in mempool
No Input
Output
status
status of the request
string
transactions
array of transactions in mempool
array
Transactions attributes:
amount_out
output amount of the transaction
int
fee
fees for the transaction
int
hash
hash of the transaction
string
size
size of the transaction
int
Expected Output:
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.
Also of note, kryptokrona developers have altered and adapted 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