-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Closed
Labels
Description
go-ethereum/ethclient/ethclient.go
Lines 323 to 335 in ae42148
| // 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 | |
| } | |
EIP-155 introduced using the chain ID as part of the transaction signing process to protect against transaction replay attacks.
network ID is not necessarily the same as chain ID (eg: ganache), I think the doc here is somewhat misleading.