Using the go-ethereum
library, I'm able to call contract methods using the generated Go bindings:
balance, err := wallet.Balance(&bind.CallOpts{
Pending: false,
From: sender,
Context: ctx,
})
However, I'd like to make the above method call for a specific block number.
To do this I would need to do two things:
- Get the latest block number.
There doesn't seem to be a function to do this dirrectly with the Ethereum client https://godoc.org/github.com/ethereum/go-ethereum/ethclient.
In web3.js there's a getBlockNumber()
method, but I couldn't find the equivalent in Go.
- Use the obtained block number to call the
balance
method on the smart contract.
The bind.CallOpts
object doesn't allow you to specify the block number directly.
How would I go about achieving this using the go-ethereum
library?