Get ChainID from ethereum node

This commit is contained in:
Eduard S
2020-12-23 16:26:56 +01:00
parent 150597c282
commit 086dc85104
6 changed files with 60 additions and 26 deletions

View File

@@ -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)