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