The following code is related to Ethereum network logs, which I am trying to extract with qouick node api. My code was working until a few days ago, but today when I visited it, I encountered this error:
{'error': {'code': -32602, 'message': 'non-array args'},
'id': 0,
'jsonrpc': '2.0'}
my code:
def get_logs(block_hash):
logs_block = w3.eth.get_logs({'blockHash': block_hash})
for log in logs_block:
trx = w3.eth.get_transaction_receipt(log['transactionHash'])
result = client.make_request("trace_transaction", trx['transactionHash'].hex())
print(result)
get_logs('0xeadccd8a2436ab5d50736ae2f93998aa007d3115089c14733b9a5764f6c7caaf')
# number block = 20504126
My code shows the trx variable correctly and does not cause any problems, but when it reaches the result, it becomes a problem and an error occurs.
How can I fix this error?
I don't know this tracing API, but I see that the Nethermind API for trace_transaction
has this specification:
Request
curl localhost:8545 \ -X POST \ -H "Content-Type: application/json" \ --data '{ "jsonrpc": "2.0", "id": 0, "method": "trace_transaction", "params": [txHash] }'
...where the params
property is expected to be an array with one transaction hash. Also the error object you quoted mentions "non-array args". So I would expect that you need to pass an array here:
result = client.make_request("trace_transaction",
[trx['transactionHash'].hex()])
Note the wrapping square brackets.