getProof
Returns the account and storage values of the specified account including the Merkle-proof
Import
Import the public actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/public"Usage
A minimal example showing how to construct a public client and call this action.
import ( "context" "log"
"github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
publicClient, err := client.CreatePublicClient(client.PublicClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = publicClient.Close() }()
proof, err := public.GetProof(ctx, publicClient, public.GetProofParameters{ Address: common.HexToAddress("0x4200000000000000000000000000000000000016"), StorageKeys: []common.Hash{ common.HexToHash("0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99"), },})if err != nil { log.Fatal(err)}log.Printf("Account proof: %d account proof entries", len(proof.AccountProof))Returns
formatters.Proof
Proof data containing:
Address common.Address- The account addressAccountProof []string- The account proofBalance *big.Int- The account balanceCodeHash common.Hash- The code hashNonce *int- The account nonceStorageHash common.Hash- The storage hashStorageProof []StorageProof- Storage proofs for each requested key
Parameters
Configuration options accepted by this action.
Address
- Type:
common.Address - Required
Account address.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")
proof, err := public.GetProof(ctx, publicClient, public.GetProofParameters{ Address: common.HexToAddress("0x4200000000000000000000000000000000000016"), StorageKeys: []common.Hash{common.HexToHash("0x0")},})StorageKeys
- Type:
[]common.Hash - Required
Array of storage keys that should be proofed and included.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")
proof, err := public.GetProof(ctx, publicClient, public.GetProofParameters{ Address: common.HexToAddress("0x4200000000000000000000000000000000000016"), StorageKeys: []common.Hash{ common.HexToHash("0x4a932049252365b3eedbc5190e18949f2ec11f39d3bef2d259764799a1b27d99"), },})BlockNumber
- Type:
*uint64 - Optional
Proof at a given block number.
import "github.com/ChefBingbong/viem-go/actions/public"
blockNum := uint64(42069)proof, err := public.GetProof(ctx, publicClient, public.GetProofParameters{ Address: common.HexToAddress("0x4200000000000000000000000000000000000016"), StorageKeys: []common.Hash{common.HexToHash("0x0")}, BlockNumber: &blockNum,})BlockTag
- Type:
BlockTag - Default:
"latest" - Optional
Proof at a given block tag.
import "github.com/ChefBingbong/viem-go/actions/public"
proof, err := public.GetProof(ctx, publicClient, public.GetProofParameters{ Address: common.HexToAddress("0x4200000000000000000000000000000000000016"), StorageKeys: []common.Hash{common.HexToHash("0x0")}, BlockTag: public.BlockTagLatest,})JSON-RPC Method
Underlying JSON-RPC method used by this action.
Calls eth_getProof (EIP-1186).