mirror of
https://github.com/arnaucube/hermez-node.git
synced 2026-02-07 11:26:44 +01:00
Get ChainID from ethereum node
This commit is contained in:
@@ -34,6 +34,7 @@ type EthereumInterface interface {
|
||||
EthTransactionReceipt(context.Context, ethCommon.Hash) (*types.Receipt, error)
|
||||
|
||||
EthERC20Consts(ethCommon.Address) (*ERC20Consts, error)
|
||||
EthChainID() (*big.Int, error)
|
||||
}
|
||||
|
||||
var (
|
||||
@@ -101,6 +102,15 @@ func NewEthereumClient(client *ethclient.Client, account *accounts.Account, ks *
|
||||
}
|
||||
}
|
||||
|
||||
// EthChainID returns the ChainID of the ethereum network
|
||||
func (c *EthereumClient) EthChainID() (*big.Int, error) {
|
||||
chainID, err := c.client.ChainID(context.Background())
|
||||
if err != nil {
|
||||
return nil, tracerr.Wrap(err)
|
||||
}
|
||||
return chainID, nil
|
||||
}
|
||||
|
||||
// BalanceAt retieves information about the default account
|
||||
func (c *EthereumClient) BalanceAt(addr ethCommon.Address) (*big.Int, error) {
|
||||
return c.client.BalanceAt(context.TODO(), addr, nil)
|
||||
|
||||
Reference in New Issue
Block a user