Rootstock RPC API Methods
Find below a list of methods available on the Rootstock RPC Service. See how to setup the Rootstock RPC Service.
eth_accounts
- Method:
eth_accounts- Returns a list of addresses owned by the client. Since Rootstock RPC Service does not store keys, this will always return empty.
- Params: None
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_accounts",
"params":[],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": []
}
eth_blockNumber
- Method:
eth_blockNumber- Returns the number of the most recent block.
- Params: None
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_blockNumber",
"params":[],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x4bdcfb"
}
eth_call
- Method:
eth_call- Executes a new message call immediately without creating a transaction on the blockchain.
- Params:
transaction: object, the transaction call object which contains the following fields:- from: String, the address from which the transaction is sent
- to: String, required, the address to which the transaction is addressed
- gas: String, the integer of gas provided for the transaction execution
- gasPrice: String, the integer of the
gasPriceused for each paid gas, encoded as a hexadecimal - value: String, the integer of value sent with this transaction encoded as hexadecimal
- data: string, the hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation
blockNumber: String, required. The block number (in hex) at which to execute the call, OR one of the following block tags:- latest: the most recent block the client has available.
- earliest: the lowest numbered block the client has available.
- pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from a local mempool. Intuitively, you can think of these as blocks that have not been mined yet.
stateOverride: Object, optional. Overrides account state for the call. Available only by request; if unsupported, omit this parameter. Each key is an address; each value is an object that can include:- balance: String, hex. Override the account balance.
- nonce: String, hex. Override the account nonce.
- code: String, hex. Override the account contract code.
- stateDiff: Object. Map of storage slot (hex) to value (hex). Override specific storage slots for the account.
- state: Object. Same shape as stateDiff; replaces the full storage for the account.
- Example:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_call",
"params":[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"latest"
],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x"
}
State override (optional)
You can override account state for the call by passing a third parameter, stateOverride. This is useful to simulate different balances, storage, or code without changing chain state. Support for this parameter depends on your RPC Service Subscription.
Example: balanceOf() without state override
Request:
{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0xa423e580dbe727151e98576d770fd3538677801c",
"data": "0x70a082310000000000000000000000003b32a6463bd0837fbf428bbc2a4c8b4c022e5077"
},
"latest"
],
"id": 0
}
Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x00000000000000000000000000000000000000000000003154c9729d05780000"
}
The result is the balance in hex. Convert to decimal to get the human-readable value (e.g. 0x...3154c9729d05780000 → 910000000000000000000).
Example: balanceOf() with state override
Request (same call with a stateOverride that sets a storage slot for the contract):
{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [
{
"to": "0xa423e580dbe727151e98576d770fd3538677801c",
"data": "0x70a082310000000000000000000000003b32a6463bd0837fbf428bbc2a4c8b4c022e5077"
},
"latest",
{
"0xa423e580dbe727151e98576d770fd3538677801c": {
"stateDiff": {
"0x8d1e5f9a8a0b1c7a6dff2f1c7c17a0f4a9a5a7d4df90cfe45bcb6b0d6fa7c7f4": "0x7E37BE2022C0914B2680000000"
}
}
}
],
"id": 0
}
Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x00000000000000000000000000000000000000000000003154c9729d05780000"
}
Convert the result hex to decimal as needed (e.g. 910000000000000000000).
eth_chainId
- Method:
eth_chainId- Returns the number of the network, in hexadecimal value.
- Params: None
- Responses:
0x1f-> Rootstock Testnet0x1e-> Rootstock Mainnet
- Example:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_chainId",
"params":[],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x1f"
}
eth_estimateGas
- Method:
eth_estimateGas- Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain.
- Params:
- transaction: object, the transaction call object which contains the following fields:
- from: String, the address from which the transaction is sent
- to: String, required, the address to which the transaction is addressed
- gas: String, the integer of gas provided for the transaction execution
gasPrice: String, the integer of gasPrice used for each paid gas encoded as hexadecimalvalue: String, the integer of value sent with this transaction encoded as hexadecimaldata: string, the hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation
blockNumber: String, optional. The block number (in hex) at which to estimate gas, OR one of the following block tags:- latest: the most recent block the client has available.
- earliest: the lowest numbered block the client has available.
- pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool. Intuitively, you can think of these as blocks that have not been mined yet.
- transaction: object, the transaction call object which contains the following fields:
- Example:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_estimateGas",
"params":[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"latest"
],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x5cec"
}
Note that when eth_estimateGas is called, the node simulates the transaction execution without broadcasting it to the network.
The simulation runs through the entire transaction process as if it were being executed, including checking for sufficient balance, contract code execution, etc.
During the simulation, the method calculates the exact amount of gas that would be consumed by the transaction if it were to be executed on the blockchain. The estimated gas amount is returned, helping users set an appropriate gas limit for the actual transaction.
Prior to Arrowhead 6.5.0, there was a difference in Rootstock compared to Ethereum:
- If one of the steps of the simulated transaction fails, the node would return the gas estimation needed for the transaction
- On Ethereum, the node would return an error instead of the gas estimation.
Starting with Arrowhead 6.5.0:
- Rootstock behaves the same way as Ethereum for simulated transaction failures.
- If a simulated transaction step fails, the node will now return an error, mirroring Ethereum's response.
You can see this behavior on the following example, where we call eth_estimateGas for a transaction that would be executed from an address without enough balance.
Example:
{
"jsonrpc":"2.0",
"method":"eth_estimateGas",
"params":[
{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"value": "0x9184e72a",
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"},
"latest"
],
"id":0
}
Response on Rootstock:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x5498"
}
Response on Ethereum:
{
"jsonrpc": "2.0",
"id": 0,
"error": {
"code": -32000,
"message": "insufficient funds for transfer"
}
}
eth_gasPrice
- Method:
eth_gasPrice- Returns the current price per gas in wei (hexadecimal).
- Params: None
- Example:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_gasPrice",
"params":[],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x3e252e0"
}
eth_getBalance
- Method:
eth_getBalance- Returns the balance of the account of a given address (hexadecimal).
- Note: eth_getBalance only returns the balance of the native chain currency (rBTC) and does not include any ERC20 token balances for the given address.
- Params:
- Address: String, required - 20 Bytes (type: account)
- Block: String: optional, either the hexadecimal value of a blockNumber, OR a blockHash, OR one of the following block tags:
- Latest: the most recent block the client has available.
- Earliest: the lowest numbered block the client has available.
- Pending: A sample next block built by the client on top of latest and containing the set of transactions usually taken from local mempool. Intuitively, you can think of these as blocks that have not been mined yet.
- if not specified, it will return the balance at the latest block available.
- Example request by
blockNumber:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":[
"0x1fab9a0e24ffc209b01faa5a61ad4366982d0b7f",
"0x6444bb"
],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x2971b6b90ba793f"
}
- Example request by
blockHash:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":[
"0x1fab9a0e24ffc209b01faa5a61ad4366982d0b7f",
"0x98e7878cc686d5ca61ca2339bda064004c82a6bbf7b6d43d7674897f775edc91"
],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x2971b6b90ba793f"
}
- Example request by
blockTag:
curl --location 'https://rpc.testnet.rootstock.io/<api-key>' \
--request POST \
--header 'accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc":"2.0",
"method":"eth_getBalance",
"params":[
"0x1fab9a0e24ffc209b01faa5a61ad4366982d0b7f",
"latest"
],
"id":0
}'
- Example Response:
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x2971b6b90ba793f"
}