1

I have this log here:

{'removed': False, 'logIndex': '0x1b', 'transactionIndex': '0x7', 'transactionHash': '0x40f36c257d1298b85f924faf42de44f46a17b96037a12e798b066c12d49eebb7', 'blockHash': '0xb85ebe68112a0ebb2024df7263e95a5881970def9ea72806eb2687c943f7af50', 'blockNumber': '0xf1adb4', 'address': '0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640', 'data': '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff0480faaf40000000000000000000000000000000000000000000000025c2cc26741a4db5a000000000000000000000000000000000000632cf6956757b0df7448e1e67d170000000000000000000000000000000000000000000000011eebf3c7c54531e30000000000000000000000000000000000000000000000000000000000031863', 'topics': ['0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67', '0x00000000000000000000000068b3465833fb72a70ecdf485e0e4c7bd8665fc45', '0x0000000000000000000000005aaaef91f93be4de932b8e7324abbf9f26daa706']}

I would like to decode the data key

'data': '0xfffffffffffffffffffffffffffffffffffffffffffffffffffffff0480faaf40000000000000000000000000000000000000000000000025c2cc26741a4db5a000000000000000000000000000000000000632cf6956757b0df7448e1e67d170000000000000000000000000000000000000000000000011eebf3c7c54531e30000000000000000000000000000000000000000000000000000000000031863'

I know that somehow I need to use the contract ABI to do this. Does someone have any idea on how to do it?

Thank you in advanced

1 Answer 1

0

You can use Web Contract event objects to decode the transaction receipt with processReceipt.

    # Decode the last output.
    # Assume Swap events go in the same chain as path
    swap = pair.events.Swap()

    # The tranasction logs are likely to contain several events like Transfer,
    # Sync, etc. We are only interested in Swap events.
    events = swap.processReceipt(tx_receipt, errors=DISCARD)

    # (AttributeDict({'args': AttributeDict({'sender': '0xDe09E74d4888

See full example.

Note that logs are in the transaction receipt (output), not in the transaction (input).

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.