RPC Interface
The BSV SV Node JSON-RPC API allows developers to interact with the BSV blockchain through a set of remote procedure calls. This document outlines the available commands and their usage.
Last updated
Was this helpful?
The BSV SV Node JSON-RPC API allows developers to interact with the BSV blockchain through a set of remote procedure calls. This document outlines the available commands and their usage.
Last updated
Was this helpful?
The JSON-RPC API provides a way to communicate with the BSV SV Node to perform various operations such as querying blockchain data, managing transactions, and retrieving network information.
JSON-RPC is a remote procedure call (RPC) protocol encoded in JSON. It allows for calling methods on a server from a client and receiving responses in a structured manner.
More information and example apps can be found in the .
To use the JSON-RPC API, you need to configure your BSV SV Node to accept JSON-RPC commands. This involves setting up the node with the appropriate RPC credentials and network settings.
Enable RPC: Ensure that the bitcoin.conf
file has the following settings:
Restart Node: Restart your BSV SV Node to apply the changes.
Requests to the JSON-RPC API are typically made via HTTP POST. Below is an example of how to structure a request:
Here is an example of a curl command to get blockchain info:
You can also use the installed bitcoin-cli
to run these commands from the node's command line
The full list of available commands can be generated with the help
command
And you can get more information about a specific method using the help <command>
call.
A full list of methods is also available in RPC Methods. The most commonly used methods are:
getinfo: Returns an object containing various state info.
help: Lists all commands, or provides help for a specified command.
getblockchaininfo: Provides information about the current state of the blockchain.
getblockhash: Returns the hash of the block at a specified height.
getblock: Returns the block details for a specified hash.
getrawtransaction: Returns raw transaction data for a given transaction ID.
sendrawtransaction: Submits a raw transaction to the network.
getmininginfo: Provides information about the current state of mining, including network hash rate, difficulty, and mining configuration.
getminingcandidate: Retrieves a candidate block for mining, including transactions and other necessary information to start mining.
submitminingsolution: Submits a solution for a mined block to the network, attempting to add it to the blockchain.
Errors in the JSON-RPC API are returned with an error
object. This object contains a code and a message indicating the nature of the error.
-32600: Invalid Request
-32601: Method Not Found
-32602: Invalid Params
-32603: Internal Error
-32700: Parse Error