ethclient: add CallContractAtHash (#24355)
* add CallContractAtHash to ethclient * add docstring and test * optimize test * ethclient: nits Co-authored-by: Péter Szilágyi <peterke@gmail.com>
This commit is contained in:
@ -456,6 +456,17 @@ func (ec *Client) CallContract(ctx context.Context, msg ethereum.CallMsg, blockN
|
||||
return hex, nil
|
||||
}
|
||||
|
||||
// CallContractAtHash is almost the same as CallContract except that it selects
|
||||
// the block by block hash instead of block height.
|
||||
func (ec *Client) CallContractAtHash(ctx context.Context, msg ethereum.CallMsg, blockHash common.Hash) ([]byte, error) {
|
||||
var hex hexutil.Bytes
|
||||
err := ec.c.CallContext(ctx, &hex, "eth_call", toCallArg(msg), rpc.BlockNumberOrHashWithHash(blockHash, false))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return hex, nil
|
||||
}
|
||||
|
||||
// PendingCallContract executes a message call transaction using the EVM.
|
||||
// The state seen by the contract call is the pending state.
|
||||
func (ec *Client) PendingCallContract(ctx context.Context, msg ethereum.CallMsg) ([]byte, error) {
|
||||
|
Reference in New Issue
Block a user