Ethereum RPC
Overview
The eth_getProof
is an Ethereum JSON-RPC method that retrieves the Merkle-Patricia proof for an account, storage key-value pairs, and account transaction count. It allows developers to verify the state of an account or storage value at a specific block without needing the entire Ethereum state trie. This method is particularly useful for light clients or off-chain applications that require proof of an account's state or specific storage values.
Parameters
The eth_getProof
requieres following parameters: :
address
: Data, 20 Bytes- The address of the account.
- Example: "fromBlock": "0x1"
keys
: Array of Data- An array of storage keys for which the proof should be generated.
- Example: ["0x0000000000000000000000000000000000000000000000000000000000000000"]
blockNumber
: Quantity or String- The block number for which the proof should be generated.
- Example: "0x1" or "latest"
Returns
TThe eth_getProof method returns an object, that contains the following fields:
Name | Description | Type |
---|---|---|
accountProof | The serialized Merkle-Patricia proof for the account. | Array of Data |
balance | The balance of the account at the specified block. | Quantity |
codeHash | The hash of the code for the account at the specified block. | Data, 32 Bytes |
nonce | The transaction count of the account at the specified block. | Quantity |
storageProof | An array of storage proof objects, one for each requested key, containing the following fields:key - Data, 32 Bytes: The storage key.value - Quantity: The storage value.proof - Array of Data: The serialized Merkle-Patricia proof for the key-value pair. | Array of Object |
Request
curl --location 'https://api.tatum.io/v3/blockchain/node/ethereum-mainnet/' \
--header 'Content-Type: application/json' \
--header 'x-api-key: {API_KEY}' \
--data '{
"id": 1,
"jsonrpc": "2.0",
"method": "eth_getProof",
"params": [
"0x742d35Cc6634C0532925a3b844Bc454e4438f44e",
[
"0x0000000000000000000000000000000000000000000000000000000000000000"
],
"latest"
]
}'
// yarn add @tatumio/tatum
import { TatumSDK, Ethereum, Network } from '@tatumio/tatum'
const tatum = await TatumSDK.init<Ethereum>({ network: Network.ETHEREUM })
const result = await tatum.rpc.getProof(
'0x742d35Cc6634C0532925a3b844Bc454e4438f44e',
['0x0000000000000000000000000000000000000000000000000000000000000000'],
'latest',
)
await tatum.destroy() // Destroy Tatum SDK - needed for stopping background jobs