For AI agents: a documentation index is available at /llms.txt. Markdown versions of pages are available by appending .md to any documentation URL.
Skip to main content

State and account methods

These methods read account state at a given block, including balances, nonces, contract code, storage values, and Merkle proofs.

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 - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

    note

    pending returns the same value as latest.

Returns

  • Current balance, in wei, as a hexadecimal value.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": [
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73",
"latest"
],
"id": 53
}'

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 - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

    note

    pending returns the same value as latest.

Returns

  • Code stored at the specified address.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": [
"0xa50a51c09a5c451c52bb714527e1974b686d8e77",
"latest"
],
"id": 53
}'

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 - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

    note

    pending returns the same value as latest.

Returns

  • Account details object.

    • balance: string - Account balance.

    • codeHash: string - 32-byte hash of the account code.

    • nonce: string - Number of transactions sent from the account.

    • storageHash: string - 32-byte SHA3 of the storageRoot.

    • accountProof: array of strings - List of RLP-encoded Merkle tree nodes, starting with the stateRoot.

    • storageProof: array of objects - List of storage entry objects.

      • key: string - Storage key.

      • value: string - Storage value.

      • proof: array of strings - List of RLP-encoded Merkle tree nodes, starting with the storageHash.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getProof",
"params": [
"0a8156e7ee392d885d10eaa86afd0e323afdcd95",
[
"0x0000000000000000000000000000000000000000000000000000000000000347"
],
"latest"
],
"id": 1
}'

eth_getStorageAt

Returns the value of a storage position at a specified address.

Parameters

  • address: string - 20-byte storage address.

  • index: string - Integer index of the storage position.

  • blockNumber or blockHash: string - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

    note

    pending returns the same value as latest.

Returns

  • Value at the specified storage position.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getStorageAt",
"params": [
"0x‭3B3F3E‬",
"0x0",
"latest"
],
"id": 53
}'

eth_getStorageValues

Returns storage values for multiple slots across one or more accounts in a single call. This is a batched version of eth_getStorageAt.

Parameters

  • storageRequest: object - Each key is a 20-byte account address and each value is an array of storage slot keys (as 32-byte hex strings). The maximum total number of storage slots across all addresses is 1024.

  • blockNumber or blockHash: string - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

    note

    pending returns the same value as latest.

Returns

  • Each key is an account address and each value is an array of hex-encoded storage values in the same order as the requested slot keys. Unknown accounts return zero values for all requested slots. Key order in the response object is not guaranteed to match the request.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getStorageValues",
"params": [
{
"0xfe3b557e8fb62b89f4916b721be55ceb828dbd73": [
"0x0",
"0x1"
],
"0x627306090abaB3A6e1400e9345bC60c78a8BEf57": [
"0x0"
]
},
"latest"
],
"id": 1
}'

eth_getTransactionCount

Returns the number of transactions sent from a specified address. Use the pending tag to get the next account nonce not used by any pending transactions.

Parameters

  • address: string - 20-byte account address.

  • blockNumber or blockHash: string - (Optional) Hexadecimal integer representing a block number, block hash, or one of the string tags latest, earliest, pending, finalized, or safe, as described in block parameter. The default is latest.

Returns

  • Integer representing the number of transactions sent from the specified address.

Example

curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": [
"0xc94770007dda54cF92009BFF0dE90c06F603a09f",
"latest"
],
"id": 1
}'