Talking to an Ethereum node from Ruby, where the transport options are the API
Ruby had almost nothing for talking to an Ethereum node, so Rails apps wanting chain state were writing raw JSON-RPC by hand. Fix that.
Most of what the README documents is transport configuration, and that is the
difficulty rather than padding. Web3::Eth::Rpc.new with no arguments hits a
local node. Anything else needs host, port, use_ssl, open_timeout,
read_timeout, and rpc_path for providers that do not serve RPC at the root
of the domain. That last one is the option people need and cannot find, because
a provider whose endpoint includes a project path refuses everything until it is
set.
Timeouts are wrong by default in both directions. A read_timeout of 120
seconds looks absurd until you call something that legitimately takes minutes,
and a short one turns a slow response into what looks like a network fault.
Where JSON-RPC bugs actually live is hex quantities. Everything numeric on the
wire is a hex string, values routinely exceed what other languages hold
comfortably, and Ruby’s arbitrary-precision Integer is one of the few places
Ruby has the advantage. Encoding and decoding correctly at the boundary is most
of what the library is for.