github.com/lmittmann/w3@v0.20.0/module/eth/storage_at.go (about)

     1  package eth
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/ethereum/go-ethereum/common"
     7  	"github.com/lmittmann/w3/internal/hexutil"
     8  	"github.com/lmittmann/w3/internal/module"
     9  	"github.com/lmittmann/w3/w3types"
    10  )
    11  
    12  // StorageAt requests the storage of the given common.Address addr at the
    13  // given common.Hash slot at the given blockNumber. If block number is nil, the
    14  // slot at the latest known block is requested.
    15  func StorageAt(addr common.Address, slot common.Hash, blockNumber *big.Int) w3types.RPCCallerFactory[common.Hash] {
    16  	return module.NewFactory(
    17  		"eth_getStorageAt",
    18  		[]any{addr, slot, module.BlockNumberArg(blockNumber)},
    19  		module.WithRetWrapper(func(ret *common.Hash) any { return (*hexutil.Hash)(ret) }),
    20  	)
    21  }