Skip to content

Commit

Permalink
ethclient: support networkID in hex format (ethereum#30263)
Browse files Browse the repository at this point in the history
Some chains’ network IDs use hexadecimal such as Optimism ("0xa" instead
of "10"), so when converting the string to big.Int, we cannot specify
base 10; otherwise, it will encounter errors with hexadecimal network
IDs.
  • Loading branch information
kkqy authored and leeren committed Aug 16, 2024
1 parent 6c40568 commit 65b6fe1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ethclient/ethclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ func (ec *Client) NetworkID(ctx context.Context) (*big.Int, error) {
if err := ec.c.CallContext(ctx, &ver, "net_version"); err != nil {
return nil, err
}
if _, ok := version.SetString(ver, 10); !ok {
if _, ok := version.SetString(ver, 0); !ok {
return nil, fmt.Errorf("invalid net_version result %q", ver)
}
return version, nil
Expand Down

0 comments on commit 65b6fe1

Please sign in to comment.