Created
June 14, 2024 08:07
-
-
Save cvonkleist/98efbfdd4a815673295f22153edf57ea to your computer and use it in GitHub Desktop.
There are too many old references to how to use Ruby's Net::HTTP to do SSL, post JSON, etc., so here is a simple, fairly modern example for future reference, posting a JSON-RPC call.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "json" | |
require "net/http" | |
url = "https://mainnet.era.zksync.io" | |
pp JSON.parse(Net::HTTP.post(URI.parse(url), {"method": "eth_blockNumber", "params": [], "id":1, "jsonrpc":"2.0"}.to_json, "Content-Type" => "application/json").body) | |
# => {"jsonrpc"=>"2.0", "result"=>"0x22d9d5d", "id"=>1} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment