Join AWS, Dust Labs & OrangeDAO at QuickPitch. Win $80k — Apply Today.

Contents

eth_chainId RPC Method

The API credit value for this method is 1 . To learn more about API credits and each method's value, visit the API Credits page.

Parameters:

  1. none

Returns:

  1. chain ID - It returns a hexadecimal value in string format which represents an integer of the chain ID

Code Examples:

require "uri"
require "json"
require "net/http"

url = URI("http://sample-endpoint-name.network.quiknode.pro/token-goes-here/")

https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = "application/json"
request.body = JSON.dump({
  "method": "eth_chainId",
  "params": [],
  "id": 1,
  "jsonrpc": "2.0"
})

response = https.request(request)
puts response.read_body
Ready to get started? Create a free account