MCPcopy Create free account
hub / github.com/GridPlus/client / NetVersion

Method NetVersion

src/rpc/web3.go:534–559  ·  view source on GitHub ↗

Get the network version (a.k.a. chainId)

()

Source from the content-addressed store, hash-verified

532
533// Get the network version (a.k.a. chainId)
534func (client *EthereumClient) NetVersion() (int64, error) {
535
536 reqBody := JSONRPCRequest{
537 JSONRPC: "2.0",
538 ID: 1,
539 Method: "net_version",
540 Params: []interface{}{},
541 }
542
543 body, err := client.issueRequest(&reqBody)
544 if err != nil {
545 return 0, err
546 }
547
548 var clientResp BlockNumberResponse
549 err = json.Unmarshal(body, &clientResp)
550 if err != nil {
551 return 0, err
552 }
553 version, err := strconv.ParseInt(clientResp.Result, 10, 64)
554 // if err != nil {
555 // return 0, err
556 // }
557
558 return int64(version), nil
559}
560
561// Use this to make calls to a contract
562type Call struct {

Callers 2

DefaultRawTxFunction · 0.80
RawTxFunction · 0.80

Calls 1

issueRequestMethod · 0.95

Tested by

no test coverage detected