BTCD

JSON-RPC API Reference

getbestblockhash

Returns the hash of the of the best (most recent) block in the longest blockchain.

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getbestblockhash","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1575643105384.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns - hex (string) the block hash hex encoded

{"result":"0000000000000000000102223b59a9c5168064e34b7c74bdfcde0f50a684264c","error":null,"id":"1"}

getblock

Gets a block with a particular header hash from the local block database either as a JSON object or as a serialized block.

  • If verbosity is 0, returns a string that is serialized, hex-encoded data for block 'hash'.

  • If verbosity is 1, returns an Object with information about block .

  • If verbosity is 2, returns an Object with information about block and information about each transaction.

Parameters

  1. blockhash [required)

    • String representing the hash of a Block.

  2. verbosity [numeric, optional, default=1]

    • 0 for hex encoded data

    • 1 for a json object

    • 2 for json object with transaction data

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getblock","params":["00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09"]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet.nodes.deploy.radar.dev/?apikey=YOUR_API_KEY'

Response

Returns - data (string) A string that is serialized, hex-encoded data for block 'hash'.

{"result":{"hash":"00000000c937983704a73af28acdec37b049d214adbda81d7e2a3dd146f6ed09","confirmations":612923,"strippedsize":216,"size":216,"weight":864,"height":1000,"version":1,"versionHex":"00000001","merkleroot":"fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33","tx":["fe28050b93faea61fa88c4c630f0e1f0a1c24d0082dd0e10d369e13212128f33"],"time":1232346882,"nonce":2595206198,"bits":"1d00ffff","difficulty":1,"previousblockhash":"0000000008e647742775a230787d66fdf92c46a48c896bfbc85cdc8acc67e87d","nextblockhash":"00000000a2887344f8db859e372e7e4bc26b23b9de340f725afbf2edb265b4c6"},"error":null,"id":"1"}

getblockcount

Returns the number of blocks in the local best block chain.

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getblockcount","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1575643105384.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns - n (numeric) The current block count

{"result":608744,"error":null,"id":"1"}

getblockhash

Returns the header hash of a block at the given height in the local best block chain.

Parameters

  1. Height [required]

    • Numeric height index

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getblockhash","params":[501458]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1575643105384.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns - "hash" (string) The block hash

{"result":"000000000000000000456c9ddf35b858d5a4787ad680ae18f3c513e343fd847c","error":null,"id":"1"}

getblockheader

Gets a block header with a particular header hash from the local block database either as a JSON object or as a serialized block header.

Parameters

  1. hash [required]

    • The block hash

  2. verbose [optional, default=true]

    • True for a json object.

    • False for the hex encoded data.

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getblockheader","params":["00000000000000000011f493c1410166d0800d222dca8787e651c131ce530e4d"]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns

Result (for verbose = true):

  • "hash" : "hash", (string) the block hash (same as provided)

  • "confirmations": n, (numeric) The number of confirmations, or -1 if the block is not on the main chain

  • "height" : n, (numeric) The block height or index

  • "version" : n, (numeric) The block version

  • "versionHex" : "00000000", (string) The block version formatted in hexadecimal

  • "merkleroot" : (string) The merkle root

  • "time" : ttt, (numeric) The block time in seconds since epoch (Jan 1 1970 GMT)

  • "mediantime" : ttt, (numeric) The median block time in seconds since epoch (Jan 1 1970 GMT)

  • "nonce" : n, (numeric) The nonce

  • "bits" : "1d00ffff", (string) The bits

  • "difficulty" : (numeric) The difficulty

  • "chainwork" : "0000...1f3" (string) Expected number of hashes required to produce the current chain (in hex)

  • "nTx" : n, (numeric) The number of transactions in the block.

  • "previousblockhash" : "hash", (string) The hash of the previous block

  • "nextblockhash" : "hash", (string) The hash of the next block

Result (for verbose=false):

  • "data" (string) A string that is serialized, hex-encoded data for block 'hash'.

{"result":{"hash":"00000000000000000011f493c1410166d0800d222dca8787e651c131ce530e4d","confirmations":304,"height":615100,"version":1073733632,"versionHex":"3fffe000","merkleroot":"7a47a9b07175fd4f3fc88a85ef6ec6af630db1cdc10dc1797f41c7573c0a431a","time":1580330831,"nonce":755430800,"bits":"171232ff","difficulty":15466098935554.652,"previousblockhash":"000000000000000000094155c733eb267917cc8230e5c0ec07807029960e3861","nextblockhash":"0000000000000000000300bedb272f0fd32196f3b7899083644ea2b5a18afeaa"},"error":null,"id":"1"}

getdifficulty

Returns the proof-of-work difficulty as a multiple of the minimum difficulty.

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getdifficulty","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns - numeric

{"result":15466098935554.652,"error":null,"id":"1"}

getinfo

Returns a JSON object containing various state info.

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getinfo","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Since btcd does NOT contain wallet functionality, wallet-related fields are not returned. See getinfo in btcwallet for a version which includes that information.

Response

Returns:

  • "version": n, (numeric) the version of the server

  • "protocolversion": n, (numeric) the latest supported protocol version

  • "blocks": n, (numeric) the number of blocks processed

  • "timeoffset": n, (numeric) the time offset

  • "connections": n, (numeric) the number of connected peers

  • "proxy": "host:port", (string) the proxy used by the server

  • "difficulty": n.nn, (numeric) the current target difficulty

  • "testnet": true or false, (boolean) whether or not server is using testnet

  • "relayfee": n.nn, (numeric) the minimum relay fee for non-free transactions in BTC/KB

{"result":{"version":120000,"protocolversion":70002,"blocks":615407,"timeoffset":-71,"connections":6,"proxy":"","difficulty":15466098935554.652,"testnet":false,"relayfee":0.00001,"errors":""},"error":null,"id":"1"}

getnettotals

Returns a JSON object containing network traffic statistics.

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getnettotals","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns:

  • "totalbytesrecv": n, (numeric) total bytes received

  • "totalbytessent": n, (numeric) total bytes sent

  • "timemillis": n (numeric) number of milliseconds since 1 Jan 1970 GMT

{"result":{"totalbytesrecv":5318198493,"totalbytessent":705927681,"timemillis":1580505225015},"error":null,"id":"1"}

getnetworkhashps

Returns the estimated network hashes per second for the block heights provided by the parameters.

Parameters

1. blocks (numeric, optional, default=120) - The number of blocks, or -1 for blocks since last difficulty change

2. height (numeric, optional, default=-1) - Perform estimate ending with this height or -1 for current best chain block height

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getnetworkhashps","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns: numeric

{"result":1444334443653517785,"error":null,"id":"1"}

getrawmempool

Returns an array of hashes for all of the transactions currently in the memory pool. The verbose flag specifies that each transaction is returned as a JSON object.

Since btcd does not perform any mining, the priority related fields startingpriority and currentpriority that are available when the verbose flag is set are always 0.

Parameters

  1. verbose (boolean, optional, default=false)

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getrawmempool","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns: "transactionhash", (string) hash of the transaction

{"result":["744a8944ca041d661ade045c15c9d16097ab1d042b85c26ddeaefff72491bfae","1dd0b5ed08e981efa0f6ae7170cfacadf61c5663366088b33d2e825d900aad7c"],"error":null,"id":"1"}

getrawtransaction

Returns information about a transaction given its hash.

Parameters

  1. transaction hash (string, required) - the hash of the transaction

  2. verbose (int, optional, default=0) - specifies the transaction is returned as a JSON object instead of hex-encoded string

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"getrawtransaction","params":["7569ab6817f4027380ca0afd2d49ba64aefff4c75c49070bd1af54cce3ed3035"]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns:

  • "data" (string) hex-encoded bytes of the serialized transaction

{"result":"010000000001010000000000000000000000000000000000000000000000000000000000000000ffffffff5b03b5620941d78c7636544aa841d78c76353bfb492f315448617368263538434f494e2ffabe6d6daf4f06b7347174707dbeed5c8c0590cc70551b15fe4cf86419396db8354bc3cb8000000000000000fe00a3c1ed52000000000000ffffffff03d18a7c4b000000001976a9142220867b1e79c403fafe339a809a65ed01cb697988ac0000000000000000266a24aa21a9edc33ec183914c3b14296521ce9c65b5dbeecceb29fdb671281f33c2b64e5d801b0000000000000000266a24b9e11b6db220e057292f2b09255e542992c53b47925776758477dec93f83c44d13bd7b2d0120000000000000000000000000000000000000000000000000000000000000000000000000","error":null,"id":"1"}

help

Returns a list of all commands or help for a specified command.

Parameters

1. command (string, optional) - the command to get help for

JSON-RPC over HTTPS POST

curl \
--data '{"jsonrpc":"2.0","id":"1","method":"help","params":[]}' \
--header 'Content-Type: application/json' \
'https://btcdmainnet1579216656532.nodes.deploy.radar.tech/?apikey=YOUR_API_KEY'

Response

Returns - string

{"result":"addnode \"addr\" \"add|remove|onetry\"\ncreaterawtransaction [{\"txid\":\"value\",\"vout\":n},...] {\"address\":amount,...} (locktime)\ndebuglevel \"levelspec\"\ndecoderawtransaction \"hextx\"\ndecodescript \"hexscript\"\nestimatefee numblocks\ngenerate numblocks\ngetaddednodeinfo dns (\"node\")\ngetbestblock\ngetbestblockhash\ngetblock \"hash\" (verbose=true verbosetx=false)\ngetblockchaininfo\ngetblockcount\ngetblockhash index\ngetblockheader \"hash\" (verbose=true)\ngetblocktemplate ({\"mode\":\"value\",\"capabilities\":[\"capability\",...],\"longpollid\":\"value\",\"sigoplimit\":sigoplimit,\"sizelimit\":sizelimit,\"maxversion\":n,\"target\":\"value\",\"data\":\"value\",\"workid\":\"value\"})\ngetcfilter \"hash\" filtertype\ngetcfilterheader \"hash\" filtertype\ngetconnectioncount\ngetcurrentnet\ngetdifficulty\ngetgenerate\ngethashespersec\ngetheaders [\"blocklocator\",...] \"hashstop\"\ngetinfo\ngetmempoolinfo\ngetmininginfo\ngetnettotals\ngetnetworkhashps (blocks=120 height=-1)\ngetpeerinfo\ngetrawmempool (verbose=false)\ngetrawtransaction \"txid\" (verbose=0)\ngettxout \"txid\" vout (includemempool=true)\nhelp (\"command\")\nnode \"connect|remove|disconnect\" \"target\" (\"perm|temp\")\nping\nsearchrawtransactions \"address\" (verbose=1 skip=0 count=100 vinextra=0 reverse=false [\"filteraddr\",...])\nsendrawtransaction \"hextx\" (allowhighfees=false)\nsetgenerate generate (genproclimit=-1)\nstop\nsubmitblock \"hexblock\" ({\"workid\":\"value\"})\nuptime\nvalidateaddress \"address\"\nverifychain (checklevel=3 checkdepth=288)\nverifymessage \"address\" \"signature\" \"message\"\nversion","error":null,"id":"1"}

Disabled Methods

Certain methods are disabled within DEPLOY Node clients for various reasons. Below is a list of methods that are not enabled on DEPLOY nodes by default. If you need access to any of the following methods on BTCD, please send us an email at support@deploy.radar.tech

List of disabled btcd methods:

  • createrawtransaction

  • decoderawtransaction

  • decodescript

  • addnode

  • getaddednodeinfo

  • getchaintips

  • getchaintxstats

  • getmempoolancestors

  • getmempooldescendants

  • getmempoolentry

  • getmempoolinfo

  • gettxout

  • gettxoutproof

  • gettxoutsetinfo

  • getmemoryinfo

  • getrpcinfo

  • preciousblock

  • pruneblockchain

  • savemempool

  • scantxoutset

  • verifychain

  • verifytxoutput