ethjsonrpc
ethjsonrpc copied to clipboard
Missing 0x prefix for hex data
Hi @ all, Since release 1.5.6 of geth (https://github.com/ethereum/go-ethereum/releases/tag/v1.5.6), the RPC implementation only accepts hex data with prefix '0x', which is missing in the current implementation. As a sample, the client is handling it incorrect at line https://github.com/ConsenSys/ethjsonrpc/blob/master/ethjsonrpc/client.py#L150.
Regards Daniel
The following lines are also affected as far as I can see: https://github.com/ConsenSys/ethjsonrpc/blob/master/ethjsonrpc/client.py#L116 https://github.com/ConsenSys/ethjsonrpc/blob/master/ethjsonrpc/client.py#L128
@danielksan81 thats correct, also for parity the 0x prefix is requiered most of the times. As a workaround, i'm doing this
from eth_utils import add_0x_prefix
And adding it when requiered contract_tx = c.create_contract(c.eth_coinbase(), add_0x_prefix(compiled), gas=300000)
for example
UPDATE: ok i found it hard to implement in the call and call_with_transaction functions so i guess it will be needed to update the lib
Hi, we used monkey patching to patch these methods in a first step. For further development we switched now to web3 python.
I can say this is a blocker. The module doesn't work at all for calling smart contract function calls. I haven't tried it, but it seems that @reiven's PR would fix these issues.
Unfortunately there seems to be even more work beyond @reiven 's work to be done on almost every method e.g. eth_newFilter
:
Traceback (most recent call last):
File "tick.py", line 83, in <module>
cl.monitor_contract(contract_addr)
File "tick.py", line 75, in monitor_contract
self.install_filter(contract_address)
File "tick.py", line 23, in install_filter
installed_filter_id = self.client.eth_newFilter(from_block=0, address=contract_address)
File "/Users/lookfwd/Desktop/foobar/.env/lib/python2.7/site-packages/ethjsonrpc/client.py", line
...
raise BadResponseError(response)
ethjsonrpc.exceptions.BadResponseError: {u'jsonrpc': u'2.0', u'id': 1, u'error': {u'message': u'invalid argument 0: hex string without 0x prefix', u'code': -32602}}
Fix: At line 507.
_filter = {
'fromBlock': "0x{}".format(from_block), # <-- Add the 0x/format
'toBlock': to_block,
'address': address,
'topics': topics,
}
(or one of the suggested @reiven 's methods.)
I will take a look at that method and fix it, thanks @lookfwd
Same issue here.