API Method
The API Method allows you to interact with the Bitrock Blockchain.
Last updated
The API Method allows you to interact with the Bitrock Blockchain.
Last updated
ADMIN
methodsadmin_addPeer
If connections are timing out, ensure the node ID in the enode URL is correct.
Parameters
enode
: - String = enode://1fd6bfa1ac606ab3cdbbbacef1b27a1e38b0ac54d5c1a361d07a27211b54b4817aa9b14e596f23c7020d246998f5224ae18882b181dad2ee940d774a085eb7bd@206.81.20.253:30303
Returns
result
: boolean - true
if peer added or false
if peer already a static node
curl HTTP request
wscat WS request
JSON result
admin_changeLogLevel
Changes the log level without restarting Besu. You can change the log level for all logs, or you can change the log level for specific packages or classes.
You can specify only one log level per RPC call.
Parameters
level
: string - log level
log_filter
: array - (optional) packages or classes for which to change the log level
Returns
result
: string - Success
if the log level has changed, otherwise error
The following example changes the debug level for specified classes to DEBUG
.
curl HTTP request
wscat WS request
JSON result
The following example changes the debug level of all logs to WARN
.
curl HTTP request
wscat WS request
JSON result
admin_generateLogBloomCache
Generates cached log bloom indexes for blocks. APIs such as eth_getLogs
and eth_getFilterLogs
use the cache for improved performance.
Note
Each index file contains 100000 blocks. The last fragment of blocks less than 100000 are not indexed.
Parameters
startBlock
: string - block to start generating indexes
endBlock
: string - block to stop generating indexes
Returns
result
: object - log bloom index details:
startBlock
: string - starting block for the last requested cache generation
endBlock
: string - ending block for the last requested cache generation
currentBlock
: string - most recent block added to the cache
indexing
: boolean - indicates if indexing is in progress
boolean - indicates acceptance of the request from this call to generate the cache
curl HTTP request
wscat WS request
JSON result
admin_logsRemoveCache
Removes cache files for the specified range of blocks.
Parameters
fromBlock
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
toBlock
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
You can skip a parameter by using an empty string, ""
. If you specify:
No parameters, the call removes cache files for all blocks.
Only fromBlock
, the call removes cache files for the specified block.
Only toBlock
, the call removes cache files from the genesis block to the specified block.
Returns
result
: object - Cache Removed
status or error
.
curl HTTP request
wscat WS request
JSON result
admin_logsRepairCache
Repairs cached logs by fixing all segments starting with the specified block number.
Parameters
startBlock
: string - decimal index of the starting block to fix; defaults to the head block
Returns
result
: object - status of the repair request; Started
or Already running
curl HTTP request
wscat WS request
JSON result
admin_nodeInfo
Returns networking information about the node. The information includes general information about the node and specific information from each running Ethereum sub-protocol (for example, eth
).
Parameters
None
Returns
result
: object - node object with the following fields:
enode
: string - enode URL of the node
listenAddr
: string - host and port for the node
name
: string - client name
id
: string - node public key
ports
: object - peer discovery and listening ports
protocols
: object - list of objects containing information for each Ethereum sub-protocol
Note
If the node is running locally, the host of the enode
and listenAddr
display as [::]
in the result. When advertising externally, the external address displayed for the enode
and listenAddr
is defined by --nat-method
.
curl HTTP request
wscat WS request
JSON result
admin_peers
Returns networking information about connected remote nodes.
Parameters
None
Returns
result
: array of objects - list of objects returned for each remote node, with the following fields.
version
: string - P2P protocol version
name
: string - client name
caps
: array of strings - list of Ethereum sub-protocol capabilities
network
: object - local and remote addresses established at time of bonding with the peer (the remote address might not match the hex value for port
; it depends on which node initiated the connection.)
port
: string - port on the remote node on which P2P discovery is listening
id
: string - node public key (excluding the 0x
prefix, the node public key is the ID in the enode URL enode://<id ex 0x>@<host>:<port>
.)
protocols
: object - current state of peer including difficulty
and head
(head
is the hash of the highest known block for the peer.)
enode
: string - enode URL of the remote node
curl HTTP request
wscat WS request
JSON result
admin_removePeer
Removes a static node.
Parameters
enode
: string - enode URL of peer to remove
Returns
result
: boolean - true
if peer removed or false
if peer not a static node
curl HTTP request
wscat WS request
JSON result
DEBUG
methodsThe DEBUG
API methods allow you to inspect and debug the network. The DEBUG
API is a more verbose alternative to the TRACE
API, and its main purpose is compatibility with tools such as Remix. Where these APIs overlap, we recommend using the TRACE
API for production use over the DEBUG
API. Specifically, we recommend trace_block
over debug_traceBlock
, and trace_transaction
over debug_traceTransaction
.
Note
The DEBUG
API methods are not enabled by default for JSON-RPC. To enable the DEBUG
API methods, use the --rpc-http-api
or --rpc-ws-api
options.
debug_accountAt
Returns account information at the specified index of the specified block.
Parameters
blockHashOrNumber
: string - block hash or number at which to retrieve account information
txIndex
: number - transaction index at which to retrieve account information
address
: string - contract or account address for which to retrieve information
Returns
result
: object - account details object with the following fields:
code
: data - code for the account. Displays 0x0
if the address is an externally owned account.
nonce
: quantity - number of transactions made by the account before this one
balance
: quantity - balance of the account in Wei
codehash
: data - code hash for the account
This example uses an externally owned account address for the address
parameter.
curl HTTP request
wscat WS request
JSON result
This example uses a contract address for the address
parameter.
curl HTTP request
wscat WS request
JSON result
debug_accountRange
Retesteth uses debug_accountRange
to implement debugging.
Returns the accounts for a specified block.
Parameters
blockHashOrNumber
: string - block hash or number at which to retrieve account information
txIndex
: number - transaction index at which to retrieve account information
address
: string - address hash from which to start
limit
: integer - maximum number of account entries to return
Returns
result
: object - account details object with the following fields:
addressMap
: map of strings to strings - map of address hashes and account addresses
nextKey
: string - hash of the next address if any addresses remain in the state, otherwise zero
curl HTTP request
wscat WS request
JSON result
debug_batchSendRawTransaction
Sends a list of signed transactions. This is used to quickly load a network with a lot of transactions. This does the same thing as calling eth_sendRawTransaction
multiple times.
Parameters
data
: string - signed transaction data array
Returns
result
: array of objects - object returned for each transaction, with the following fields:
index
: string - index of the transaction in the request parameters array
success
: boolean - indicates whether or not the transaction has been added to the transaction pool
errorMessage
: string - (optional) error message
curl HTTP
wscat WS
JSON result
debug_getBadBlocks
Returns a list of invalid blocks. This is used to detect and analyze consensus flaws.
Parameters
None
Returns
result
: array of objects - list of block objects
curl HTTP
wscat WS
JSON result
debug_getRawBlock
Returns the RLP encoding of the specified block.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: object - RLP-encoded block object
curl HTTP request
wscat WS request
JSON result
Returns the RLP encoding of the header of specified block.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: string - RLP-encoded block header or error
curl HTTP request
wscat WS request
JSON result
debug_metrics
Returns metrics providing information on the internal operation of Besu.
The available metrics might change over time. The JVM metrics might vary based on the JVM implementation used.
The metric types are:
Timer
Counter
Gauge
Parameters
None
Returns
result
: object - metrics object
curl HTTP request
wscat WS request
JSON result
debug_replayBlock
Re-imports the block matching the specified block number, by rolling the head of the local chain back to the block right before the specified block, then importing the specified block.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: string - Success
or error
curl HTTP request
wscat WS request
JSON result
debug_resyncWorldstate
Triggers a re-synchronization of the world state while retaining imported blocks. This is useful if there are world state database inconsistencies (for example, Bonsai database issues).
Parameters
None
Returns
result
: string - Success
or error
curl HTTP request
wscat WS request
JSON result
debug_setHead
Sets the current head of the local chain to the block matching the specified block number.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: string - Success
or error
curl HTTP request
wscat WS request
JSON result
debug_standardTraceBlockToFile
Generates files containing the block trace. A separate file is generated for each transaction in the block.
You can also specify a trace file for a specific transaction in a block.
Use debug_standardTraceBadBlockToFile
to view the trace for an invalid block.
Parameters
blockHash
: string - block hash
txHash
: string - (optional) transaction hash; if omitted, a trace file is generated for each transaction in the block.
disableMemory
: boolean - (optional) specifies whether to capture EVM memory during the trace; defaults to true
Returns
result
: string - location of the generated trace files
curl HTTP request
wscat WS request
JSON result
debug_standardTraceBadBlockToFile
Generates files containing the block trace of invalid blocks. A separate file is generated for each transaction in the block.
Use debug_standardTraceBlockToFile
to view the trace for a valid block.
Parameters
blockHash
: string - block hash
Returns
result
: string - location of the generated trace files
curl HTTP request
wscat WS request
JSON result
debug_storageRangeAt
Remix uses debug_storageRangeAt
to implement debugging. Use the Debugger tab in Remix instead of calling debug_storageRangeAt
directly.
Returns the contract storage for the specified range.
Parameters
blockHash
: string - block hash
txIndex
: number - transaction index from which to start
address
: string - contract address
startKey
: string - start key
limit
: number - number of storage entries to return
Returns
result
: object - range object.
curl HTTP request
wscat WS request
JSON result
curl HTTP request
wscat WS request
JSON result
debug_traceBlock
Returns full trace of all invoked opcodes of all transactions included in the block.
Parameters
block
: string - RLP of the block
options
: object - request options object with the following fields (all optional and default to false
):
disableStorage
: boolean - true
disables storage capture.
disableMemory
: boolean - true
disables memory capture.
disableStack
: boolean - true
disables stack capture.
Returns
result
: object - trace object
curl HTTP request
wscat WS request
JSON result
debug_traceBlockByHash
Returns full trace of all invoked opcodes of all transactions included in the block.
Parameters
blockHash
: string - block hash
options
: object - request options object with the following fields (all optional and default to false
):
disableStorage
: boolean - true
disables storage capture.
disableMemory
: boolean - true
disables memory capture.
disableStack
: boolean - true
disables stack capture.
Returns
result
: array of objects - list of trace objects
curl HTTP request
wscat WS request
JSON result
debug_traceBlockByNumber
Returns full trace of all invoked opcodes of all transactions included in the block.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
options
: object - request options object with the following fields (all optional and default to false
):
disableStorage
: boolean - true
disables storage capture.
disableMemory
: boolean - true
disables memory capture.
disableStack
: boolean - true
disables stack capture.
Returns
result
: array of objects - list of trace objects
curl HTTP request
wscat WS request
JSON result
ETH
methodsThe ETH
API methods allow you to interact with the blockchain.
Note
Methods with an equivalent GraphQL query include a GraphQL request and result in the method example. The parameter and result descriptions apply to the JSON-RPC requests. The GraphQL specification is defined in the schema.
eth_accounts
Returns a list of account addresses a client owns.
Parameters
None
Returns
result
: array of strings - list of 20-byte account addresses owned by the client
curl HTTP request
wscat WS request
JSON result
eth_blockNumber
Returns the index corresponding to the block number of the current chain head.
Parameters
None
Returns
result
: string - hexadecimal integer representing the index corresponding to the block number of the current chain head
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_call
Invokes a contract function locally and does not change the state of the blockchain.
You can interact with contracts using eth_sendRawTransaction
or eth_call
.
If revert reason is enabled with --revert-reason-enabled
, the eth_call
error response includes the revert reason.
Parameters
call
: object - transaction call object
blockNumber
or blockHash
: string - integer representing a block number, block hash, or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Note
By default, eth_call
does not fail if the sender account has an insufficient balance. This is done by setting the balance of the account to a large amount of ether. To enforce balance rules, set the strict
parameter in the transaction call object to true
.
Returns
result
: string - return value of the executed contract
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
Example of a simulated contract creation
The following example creates a simulated contract by not including the to
parameter from the transaction call object in the call
parameter. Besu simulates the data to create the contract.
curl HTTP
JSON result
eth_chainId
Returns the chain ID.
Parameters
None
Returns
result
: string - chain ID in hexadecimal
curl HTTP request
wscat WS request
JSON result
eth_coinbase
Returns the client coinbase address. The coinbase address is the account to pay mining rewards to.
To set a coinbase address, start Besu with the --miner-coinbase
option set to a valid Ethereum account address. You can get the Ethereum account address from a client such as MetaMask or Bitrock Scan. For example:
Example
Parameters
None
Returns
result
: string - coinbase address
curl HTTP request
wscat WS request
JSON result
eth_createAccessList
Creates an EIP-2930 access list that you can include in a transaction.
Parameters
transaction
: object - transaction call object
blockNumber
or blockHash
: string - integer representing a block number, block hash, or one of the string tags latest
, earliest
, or pending
, as described in block parameter.
Returns
result
: object - access list object with the following fields:
accessList
: array of objects - list of objects with the following fields:
address
: string - addresses to be accessed by the transaction
storageKeys
: array - storage keys to be accessed by the transaction
gasUsed
: string - approximate gas cost for the transaction if the access list is included
curl HTTP
wscat WS
JSON result
eth_estimateGas
Returns an estimate of the gas required for a transaction to complete. The estimation process does not use gas and the transaction is not added to the blockchain. The resulting estimate can be greater than the amount of gas the transaction ends up using, for reasons including EVM mechanics and node performance.
The eth_estimateGas
call does not send a transaction. You must call eth_sendRawTransaction
to execute the transaction.
If revert reason is enabled with --revert-reason-enabled
, the eth_estimateGas
error response includes the revert reason.
Parameters
For eth_estimateGas
, all fields are optional because setting a gas limit is irrelevant to the estimation process (unlike transactions, in which gas limits apply).
call
: object - transaction call object
Returns
result
: string - amount of gas used
The following example returns an estimate of 21000 wei (0x5208
) for the transaction.
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
The following example request estimates the cost of deploying a simple storage smart contract to the network. The data field contains the hash of the compiled contract you want to deploy. (You can get the compiled contract hash from your IDE, for example, Remix > Compile tab > details > WEB3DEPLOY.) The result is 113355 wei.
curl HTTP request
JSON result
eth_feeHistory
Returns base fee per gas and transaction effective priority fee per gas history for the requested block range, allowing you to track trends over time.
Parameters
blockCount
: integer or string - Number of blocks in the requested range. Between 1 and 1024 blocks can be requested in a single query. If blocks in the specified block range are not available, then only the fee history for available blocks is returned. Accepts hexadecimal or integer values.
newestBlock
: string - Integer representing the highest number block of the requested range or one of the string tags latest
, earliest
, or pending
, as described in block parameter.
array
of integers
- (optional) A monotonically increasing list of percentile values to sample from each block's effective priority fees per gas in ascending order, weighted by gas used.
Returns
result
: object - Fee history results object.
curl HTTP
wscat WS
JSON result
eth_gasPrice
Returns a percentile gas unit price for the most recent blocks, in Wei. By default, the last 100 blocks are examined and the 50th percentile gas unit price (that is, the median value) is returned.
If there are no blocks, the value for --min-gas-price
is returned. The value returned is restricted to values between --min-gas-price
and --api-gas-price-max
. By default, 1000 Wei and 500GWei.
Use the --api-gas-price-blocks
, --api-gas-price-percentile
, and --api-gas-price-max
command line options to configure the eth_gasPrice
default values.
Parameters
None
Returns
result
: string - percentile gas unit price for the most recent blocks, in Wei, as a hexadecimal value
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getBalance
Returns the account balance of the specified address.
Parameters
address
: string - 20-byte account address from which to retrieve the balance
blockNumber
or blockHash
: string - integer representing a block number, block hash, or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: string - current balance, in Wei, as a hexadecimal value
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getBlockByHash
Returns information about the block matching the specified block hash.
Parameters
hash
: string - 32-byte hash of a block
verbose
: boolean - if true
, returns the full transaction objects; if false
, returns the transaction hashes
Returns
result
: object - block object, or null
when there is no block
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getBlockByNumber
Returns information about the block matching the specified block number.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, pending
, finalized
, or safe
as described in block parameter
verbose
: boolean - if true
, returns the full transaction objects; if false
, returns only the hashes of the transactions.
Returns
result
: object - block object, or null
when there is no block.
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getBlockTransactionCountByHash
Returns the number of transactions in the block matching the specified block hash.
Parameters
hash
: string - 32-byte block hash
Returns
result
: number - integer representing the number of transactions in the specified block, or null
if no matching block hash is found
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block matching the specified block number.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: string - integer representing the number of transactions in the specified block, or null
if no matching block number is found
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getCode
Returns the code of the smart contract at the specified address. Besu stores compiled smart contract code as a hexadecimal value.
Parameters
address
: string - 20-byte contract address
blockNumber
or blockHash
: string - integer representing a block number, block hash, or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: data - code stored at the specified address
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getFilterChanges
Polls the specified filter and returns an array of changes that have occurred since the last poll.
Parameters
filterId
: string - filter ID
Returns
result
: array of strings or objects - if nothing changed since the last poll, an empty list; otherwise:
For filters created with eth_newBlockFilter
, returns block hashes.
For filters created with eth_newPendingTransactionFilter
, returns transaction hashes.
For filters created with eth_newFilter
, returns log objects.
curl HTTP request
wscat WS request
JSON result
eth_getFilterLogs
Returns an array of logs for the specified filter.
Leave the --auto-log-bloom-caching-enabled
command line option at the default value of true
to improve log retrieval performance.
Note
eth_getFilterLogs
is only used for filters created with eth_newFilter
. To specify a filter object and get logs without creating a filter, use eth_getLogs
.
Parameters
filterId
: string - filter ID
Returns
result
: array of objects - list of log objects
curl HTTP request
wscat WS request
JSON result
eth_getLogs
Returns an array of logs matching a specified filter object.
Leave the --auto-log-bloom-caching-enabled
command line option at the default value of true
to improve log retrieval performance.
caution
Using eth_getLogs
to get logs from a large range of blocks, especially an entire chain from its genesis block, might cause Besu to hang for an indeterminable amount of time while generating the response. We recommend setting a range limit using the --rpc-max-logs-range
option (or leaving it at its default value of 1000).
Parameters
filterOptions
: object - filter options object
Returns
result
: array of objects - list of log objects
curl HTTP
wscat WS
JSON result
curl GraphQL
GraphQL
GraphQL result
eth_getMinerDataByBlockHash
Returns miner data for the specified block.
Parameters
hash
: string - 32-byte block hash
Returns
result
: object - miner data object
curl HTTP
wscat WS
JSON result
eth_getMinerDataByBlockNumber
Returns miner data for the specified block.
Parameters
blockNumber
: string - integer representing a block number or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: object - miner data object
curl HTTP
wscat WS
JSON result
eth_getProof
Returns the account and storage values of the specified account, including the Merkle proof.
The API allows IoT devices or mobile apps which are unable to run light clients to verify responses from untrusted sources, by using a trusted block hash.
Parameters
address
: string - 20-byte address of the account or contract
keys
: array of strings - list of 32-byte storage keys to generate proofs for
blockNumber
or blockHash
: string - integer representing a block number, block hash, or one of the string tags latest
, earliest
, or pending
, as described in block parameter
Returns
result
: object - account details object with the following fields:
balance
: string - account balance
codeHash
: string - 32-byte hash of the account code
nonce
: string - number of transactions sent from the account