This document describes the JSON-RPC API exposed by the Ferrous node. The server is implemented in rpc/server.rs and uses the types from rpc/methods.rs.
- Protocol version: JSON-RPC 2.0
- Transport: HTTP
- Default address:
127.0.0.1:8332(as configured by the example node)
Each request is a JSON object with:
jsonrpc:"2.0"method: RPC method nameparams: array of positional parametersid: client-provided identifier
Responses:
- On success:
{"jsonrpc":"2.0","result":<value>,"id":<id>}
- On error:
{"jsonrpc":"2.0","error":{"code":<int>,"message":<string>},"id":<id>}
Implemented methods:
getblockchaininfogetmininginfomineblocksgetblockgetblockhashgetbestblockhashgetnewaddressgetbalancegetwalletinfoencryptwalletimportseedgetshamirshareslistunspentlistaddressessendtoaddresssendrawtransactiongeneratetoaddressgetnetworkinfoaddnodegetpeerinfogetconnectioncountgetnetworkhealthgetrecoverystatusforcereconnectresetnetworkstop
Error codes:
-32601: Method not found-32603: Internal error (includes validation/mining errors)-32700: Parse error (invalid JSON)
Returns basic information about the current blockchain state.
{
"jsonrpc": "2.0",
"method": "getblockchaininfo",
"params": [],
"id": 1
}result is a GetBlockchainInfoResponse:
{
"jsonrpc": "2.0",
"result": {
"chain": "ferrous",
"blocks": 123,
"headers": 123,
"bestblockhash": "f3c0..."
},
"id": 1
}Fields:
chain: String identifier ("ferrous").blocks: Height of the active tip.headers: Same asblocks(no header-only mode).bestblockhash: Hex-encoded hash of the tip block header.
Returns the block hash for a given height.
params is an array with a single integer: height.
{
"jsonrpc": "2.0",
"method": "getblockhash",
"params": [30000],
"id": 1
}result is a hex string:
{
"jsonrpc": "2.0",
"result": "a68819f243db24659316e301cfb038fe4b62b75055cd30e3b958b23c272e1400",
"id": 1
}Returns the current mining/network statistics.
{
"jsonrpc": "2.0",
"method": "getmininginfo",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"blocks": 104888,
"chain": "ferrous",
"difficulty": 0.0030110102769936487,
"networkhashps": 86214.60445071748
},
"id": 1
}Returns a new wallet address string.
{
"jsonrpc": "2.0",
"method": "getnewaddress",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"address": "Frr1ExampleAddressString"
},
"id": 1
}Returns the wallet balance.
{
"jsonrpc": "2.0",
"method": "getbalance",
"params": [],
"id": 1
}result is a JSON object:
{
"jsonrpc": "2.0",
"result": {
"balance": 0.0
},
"id": 1
}Returns the wallet UTXO set view.
{
"jsonrpc": "2.0",
"method": "listunspent",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"utxos": [
{
"txid": "f3c0...",
"vout": 0,
"amount": 50.0,
"confirmations": 101,
"script_pubkey": "76a914..."
}
]
},
"id": 1
}Returns all wallet addresses.
{
"jsonrpc": "2.0",
"method": "listaddresses",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"addresses": [
"Frr1ExampleAddressString"
]
},
"id": 1
}Creates and broadcasts a transaction paying amount to address.
params is an array with two elements: destination address string and amount.
{
"jsonrpc": "2.0",
"method": "sendtoaddress",
"params": ["Frr1ExampleAddressString", 1.25],
"id": 1
}result is a JSON object containing only the transaction ID. The transaction is submitted to the mempool and included in the next mined block.
{
"jsonrpc": "2.0",
"result": {
"txid": "9b1a..."
},
"id": 1
}Decodes a hex-encoded raw transaction, validates its structure, and submits it to the mempool.
params is an array with a single hex string.
{
"jsonrpc": "2.0",
"method": "sendrawtransaction",
"params": ["0100000001..."],
"id": 1
}result is the transaction ID as a hex string:
{
"jsonrpc": "2.0",
"result": "9b1a...",
"id": 1
}- If the hex is invalid:
"Invalid hex" - If the transaction fails to decode:
"Failed to decode transaction" - If the transaction fails structure checks:
"Invalid transaction: <details>" - If the mempool rejects it:
"Mempool rejected: <details>"
Returns information about the current wallet state.
{
"jsonrpc": "2.0",
"method": "getwalletinfo",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"encrypted": false,
"has_seed": true,
"receive_addresses": 1,
"change_addresses": 0,
"balance_sats": 5000000000
},
"id": 1
}Fields:
encrypted: Whether the wallet file is encrypted with ChaCha20-Poly1305.has_seed: Whether a BIP39 seed is present (enabling deterministic key derivation and Shamir backup).receive_addresses: Number of receive addresses generated so far.change_addresses: Number of change addresses generated so far.balance_sats: Wallet balance in satoshis (frsats).
Encrypts the wallet file using ChaCha20-Poly1305 with a PBKDF2-HMAC-SHA512 key derivation (210,000 iterations). The node must be restarted after encryption to load the encrypted wallet.
params is an array with a single string: the passphrase.
{
"jsonrpc": "2.0",
"method": "encryptwallet",
"params": ["my-strong-passphrase"],
"id": 1
}{
"jsonrpc": "2.0",
"result": "Wallet encrypted. Restart node to load encrypted wallet.",
"id": 1
}- If the wallet is already encrypted:
"Wallet is already encrypted"
Imports a BIP39 mnemonic phrase, rederives all wallet keys, and saves the wallet. Only 24-word (256-bit entropy) mnemonics are supported. BIP39 passphrase is not yet supported.
params is an array: [mnemonic, passphrase?]. Passphrase must be omitted or empty.
{
"jsonrpc": "2.0",
"method": "importseed",
"params": ["word1 word2 ... word24"],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"address_count": 1
},
"id": 1
}Fields:
address_count: Number of receive addresses derived after import.
- If the mnemonic is invalid:
"Invalid mnemonic: <details>" - If the entropy is not 32 bytes:
"Expected 32-byte entropy (256-bit mnemonic), got <n>" - If a non-empty passphrase is supplied:
"BIP39 passphrase not yet supported. Import using empty passphrase only."
Splits the wallet's BIP39 seed entropy into M-of-N Shamir shares using GF(256) arithmetic. Any M shares can recover the seed; fewer than M shares reveal nothing.
params is an array: [m, n] where 2 ≤ m ≤ n ≤ 10.
{
"jsonrpc": "2.0",
"method": "getshamirshares",
"params": [2, 3],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"shares": [
{"index": 1, "share": "a3f0..."},
{"index": 2, "share": "7c12..."},
{"index": 3, "share": "e841..."}
],
"m": 2,
"n": 3
},
"id": 1
}Fields:
shares: Array of{index, share}objects.indexis 1-based;shareis hex-encoded.m: Minimum number of shares required to recover the seed.n: Total number of shares produced.
- If no seed is present:
"No seed to split" - If M/N parameters are invalid:
"Shamir split failed: <details>"
Mines nblocks blocks, paying the coinbase reward to address.
params is an array: [nblocks, address].
{
"jsonrpc": "2.0",
"method": "generatetoaddress",
"params": [10, "Frr1ExampleAddressString"],
"id": 1
}result is a MineBlocksResponse:
{
"jsonrpc": "2.0",
"result": {
"blocks": ["000000...", "000000..."]
},
"id": 1
}Returns network configuration and runtime info.
{
"jsonrpc": "2.0",
"method": "getnetworkinfo",
"params": [],
"id": 1
}Returns the number of current P2P connections.
{
"jsonrpc": "2.0",
"method": "getconnectioncount",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": 1,
"id": 1
}Forces a network reset.
{
"jsonrpc": "2.0",
"method": "resetnetwork",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"result": "network reset initiated"
},
"id": 1
}Mines one or more new blocks on top of the current tip and returns their hashes. This method is intended for regtest/testnet usage.
params is an array with a single integer: number of blocks to mine.
{
"jsonrpc": "2.0",
"method": "mineblocks",
"params": [10],
"id": 1
}result is a MineBlocksResponse:
{
"jsonrpc": "2.0",
"result": {
"blocks": [
"000000...",
"000000..."
]
},
"id": 1
}Fields:
blocks: Array of hex-encoded block header hashes, in the order mined.
- If
paramsis missing or malformed:code = -32603,message = "Invalid params: expected [nblocks]"
- If
nblocksis 0 or greater than 1000:code = -32603,message = "nblocks must be between 1 and 1000"
- Mining failures:
code = -32603,message = "Mining failed: <details>"
Returns information about a block by its hash.
params is an array with a single string: block hash in hex.
{
"jsonrpc": "2.0",
"method": "getblock",
"params": ["000000..."],
"id": 1
}result is a GetBlockResponse:
{
"jsonrpc": "2.0",
"result": {
"hash": "000000...",
"height": 42,
"version": 1,
"merkleroot": "4a5e...",
"time": 1700000000,
"nonce": 123456,
"bits": "1d00ffff",
"tx": [
"f3c0...",
"9b1a..."
]
},
"id": 1
}Fields:
hash: Hex-encoded block header hash.height: Block height (genesis is 0).version: Block version.merkleroot: Hex-encoded Merkle root oftxids.time: Block timestamp (UNIX seconds).nonce: Block nonce.bits: Difficulty target in compact hex format.tx: Array of hex-encoded transactiontxids in the block.
- If
paramsis missing or malformed:code = -32603,message = "Invalid params: expected [blockhash]"
- If
blockhashis not valid hex:code = -32603,message = "Invalid hex"
- If
blockhashis not 32 bytes:code = -32603,message = "Invalid hash length"
- If the block is not found:
code = -32603,message = "Block not found"
Returns data about each connected network peer.
{
"jsonrpc": "2.0",
"method": "getpeerinfo",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"count": 1,
"peers": ["45.77.153.141:8333"]
},
"id": 1
}Returns the current status of the network recovery manager.
{
"jsonrpc": "2.0",
"method": "getrecoverystatus",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": {
"partition_detected": false,
"last_block_age": 120,
"recovery_attempts": 0
},
"id": 1
}Manually triggers a full network reconnection (disconnects all peers and restarts discovery).
{
"jsonrpc": "2.0",
"method": "forcereconnect",
"params": [],
"id": 1
}Returns the hash of the current best block.
{
"jsonrpc": "2.0",
"method": "getbestblockhash",
"params": [],
"id": 1
}result is a hex string:
{
"jsonrpc": "2.0",
"result": "000000...",
"id": 1
}Requests the server to shut down after responding.
{
"jsonrpc": "2.0",
"method": "stop",
"params": [],
"id": 1
}{
"jsonrpc": "2.0",
"result": "stopping",
"id": 1
}The server will exit after sending this response.
$body = @{
jsonrpc = "2.0"
method = "mineblocks"
params = @(10)
id = 1
} | ConvertTo-Json
Invoke-RestMethod -Uri http://127.0.0.1:8332 -Method Post -Body $body -ContentType "application/json"curl -X POST http://127.0.0.1:8332 \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"getblockchaininfo","params":[],"id":1}'