aboutsummaryrefslogtreecommitdiffstats
path: root/ethclient/ethclient.go
diff options
context:
space:
mode:
Diffstat (limited to 'ethclient/ethclient.go')
-rw-r--r--ethclient/ethclient.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/ethclient/ethclient.go b/ethclient/ethclient.go
index 45bb87322..48639d949 100644
--- a/ethclient/ethclient.go
+++ b/ethclient/ethclient.go
@@ -203,8 +203,6 @@ func (ec *Client) TransactionReceipt(ctx context.Context, txHash common.Hash) (*
if err == nil {
if r == nil {
return nil, ethereum.NotFound
- } else if len(r.PostState) == 0 {
- return nil, fmt.Errorf("server returned receipt without post state")
}
}
return r, err
@@ -258,6 +256,19 @@ func (ec *Client) SubscribeNewHead(ctx context.Context, ch chan<- *types.Header)
// State Access
+// NetworkID returns the network ID (also known as the chain ID) for this chain.
+func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error) {
+ version := new(big.Int)
+ var ver string
+ if err := ec.c.CallContext(ctx, &ver, "net_version"); err != nil {
+ return nil, err
+ }
+ if _, ok := version.SetString(ver, 10); !ok {
+ return nil, fmt.Errorf("invalid net_version result %q", ver)
+ }
+ return version, nil
+}
+
// BalanceAt returns the wei balance of the given account.
// The block number can be nil, in which case the balance is taken from the latest known block.
func (ec *Client) BalanceAt(ctx context.Context, account common.Address, blockNumber *big.Int) (*big.Int, error) {