getProof
Returns the account and storage values of the specified account including the Merkle-proof
Loading...
Returns the account and storage values of the specified account including the Merkle-proof
Import the public actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/public"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))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 keyConfiguration options accepted by this action.
common.AddressAccount 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")},})[]common.HashArray 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"), },})*uint64Proof 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"latest"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,})Underlying JSON-RPC method used by this action.
Calls eth_getProof (EIP-1186).