ethclient, internal/ethapi: add support for EIP-695 (eth_chainId) (#19694)
EIP-695 was written in 2017. Parity and Infura have support for this method and we should, too.
This commit is contained in:
committed by
Péter Szilágyi
parent
c420dcb39c
commit
2b54666018
@ -61,6 +61,16 @@ func (ec *Client) Close() {
|
||||
|
||||
// Blockchain Access
|
||||
|
||||
// ChainId retrieves the current chain ID for transaction replay protection.
|
||||
func (ec *Client) ChainID(ctx context.Context) (*big.Int, error) {
|
||||
var result hexutil.Big
|
||||
err := ec.c.CallContext(ctx, &result, "eth_chainId")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return (*big.Int)(&result), err
|
||||
}
|
||||
|
||||
// BlockByHash returns the given full block.
|
||||
//
|
||||
// Note that loading full blocks requires two requests. Use HeaderByHash
|
||||
|
Reference in New Issue
Block a user