eth.rb: Possible problem in translating call() params into camelCase requirement
version: 0.5.6
I haven’t been able to send a call transaction to a custom Substrate-based chain with EVM compatibility.
I get IOErrors
related to the name of the tx params.
Example:
Traceback (most recent call last):
.
.
.
3: from /home/arthurmoreira-t14/Code/eth.rb/lib/eth/client.rb:440:in `call_raw'
2: from /home/arthurmoreira-t14/Code/eth.rb/lib/eth/client.rb:400:in `block (2 levels) in <class:Client>'
1: from /home/arthurmoreira-t14/Code/eth.rb/lib/eth/client.rb:475:in `send_command'
IOError (unknown field `gas_limit`, expected one of `from`, `to`, `gasPrice`, `maxFeePerGas`, `maxPriorityFeePerGas`, `gas`, `value`, `data`, `nonce`, `accessList`, `type` at line 1 column 12)
Investigating further, I noticed that the JSON fields in the payload look like this:
{:jsonrpc=>"2.0", :method=>"eth_call", :params=>[{:gas_limit=>"0xcf08", :chain_id=>"0x7d8", :data=><sensitive>, :to=>"0xB7d2fFd908ef6B69dA0749600F553923C465c811", :priority_fee=>"0x0", :max_gas_fee=>"0x4a817c800"}, "latest"], :id=>9}
And the response is:
"{\"jsonrpc\":\"2.0\",\"error\":{\"code\":-32602,\"message\":\"unknown field `gas_price`, expected one of `from`, `to`, `gasPrice`, `maxFeePerGas`, `maxPriorityFeePerGas`, `gas`, `value`, `data`, `nonce`, `accessList`, `type` at line 1 column 25\"},\"id\":9}\n"
I was able to make it work by adding a byebug
just before sending the request and manually renaming the JSON fields to camelCase
, and removing chain_id
, adding transaction type
:
then I can get the correct response:
irb(main):011:0> request.body = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"gas\":\"0xcf08\",\"data\":\"0x\",\"to\":\"0xC6d1eFd908ef6B69dA0749600F553923C465c812\",\"gasPrice\":\"0x0\",\"type\":\"0x00\"},\"latest\"],\"id\":9}"
irb(main):011:0> response = http.request(body)
#<Net::HTTPOK 200 OK readbody=true>
irb(main):011:0> response.body
"{\"jsonrpc\":\"2.0\",\"result\":\"0x0000000000000000000000000000000000000000000000000000000000000000\",\"id\":9}\n"
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 15 (13 by maintainers)
Done 😃
OK, I’m working on it here: https://github.com/a-moreira/eth.rb/pull/1 I will open the PR here as soon as I fix all the test errors.
Yes, a default camel case would work for me! Sorry for the late response! 😃