github.com/lmittmann/w3@v0.20.0/module/eth/code.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/module"
     8  	"github.com/lmittmann/w3/w3types"
     9  )
    10  
    11  // Code requests the code of the given common.Address addr at the given
    12  // blockNumber. If blockNumber is nil, the code at the latest known block is
    13  // requested.
    14  func Code(addr common.Address, blockNumber *big.Int) w3types.RPCCallerFactory[[]byte] {
    15  	return module.NewFactory(
    16  		"eth_getCode",
    17  		[]any{addr, module.BlockNumberArg(blockNumber)},
    18  		module.WithRetWrapper(module.HexBytesRetWrapper),
    19  	)
    20  }