1

I am pulling a trace from a Parity node using the JSONRPC API. It looks like this:

print(trace)
{
    'action': {
        'callType': 'staticcall',
        'from': '0xXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        'gas': '0x1ad02e',
        'input': '0x2f58b80d',
        'to': '0xZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ',
        'value': '0x0'
    },
    'result': {'gasUsed': '0x501', 'output': '0x000000000000000000000000082b0ca59f2122c94e5f57db0085907fa9584ba6'},
    'subtraces': 0,
    'traceAddress': [0, 0],
    'type': 'call'
}

I can decode the input using the ABI from the to address, but this doesn't seem to work for the result.output field.

# this works
print(contract.decode_function_input(trace['action']['input']))
(<Function balanceOf(address)>, {'': '0xYYYYYYYYYYYYYYYYYYYYYYYY'})

# this does not
print(contract.decode_function_input(trace['result']['output']))
*** ValueError: Could not find any function with matching selector

Is the output encoded in a different way, maybe one that isn't tied to the ABI for the input?

I am not able to find documentation on how to decode it. I also tried using decode_function_input() for the ABI it calls, but that didn't seem to work either.

1
  • Any updates on this? @lollercoaster were you able to find any solutions for this?
    – pbsh
    Commented Jan 28, 2022 at 14:46

1 Answer 1

0

In your code for

contract.decode_function_input

Your contract object is of the token in question or of the router? E.g. on BSC (BinanceSmartChain), you need to use the PancakeSwapRouter Version2 address (I know because I am decoding transaction.input data there on daily basis).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.