0

When I call the same function twice, first through a direct call an event logs the exact parameters, second through a delegateCall from another contract, it returns the same parameters but the format is wrong, here are the logs from both calls:

Direct call:

"topics": [
            "1",
            "0x294F36a4c1d1be614f8D1CAB33C0e0dcd39031AF",
            "0xeD85D4d8C76a027DDac93654221D31f5c17056A0"
        ]

Delegate call:

"topics": [
            "0xab8530f87dc9b59234c4623bf917212bb2536d647574c8e7e5da92c2ede0c9f8",
            "0x000000000000000000000000294f36a4c1d1be614f8d1cab33c0e0dcd39031af",
            "0x000000000000000000000000ed85d4d8c76a027ddac93654221d31f5c17056a0"
        ]

Thanks in advance for your help

2

1 Answer 1

0

When you call function of contract A from contract B via normal CALL opcode, the events logged by the bytecode of contract A appear in transaction receipt as if they originate from the address of contract A. As long as structures of these events are described in A's ABI, the contract wrapper generated by Web3 API for contract A is able to decode these events.

When you call the same function of contract A from contract B via DELEGATECALL opcode, the very same events will look like they originate from the address of contract B, but there is no description for these events in B's ABI. So wrapper generated for contract B will not know how to decode these events, and will show them in raw format. Thus the difference.

To fix the problem you need either to add declarations of events logged by contract A to the source code of contract B; or to create a wrapper based on A's ABI for the address of contract B, and use this wrapper to query events. In the latter case make sure you do not use this wrapper for calling any methods, because this would lead to undefined behavior.

3
  • Very informative, thank you @Mikhail
    – Arsalen
    Oct 27, 2019 at 14:58
  • This explains the 2nd and 3rd values, not the first, no? Oct 28, 2019 at 9:57
  • First value in the second case is keccak256 of the following string: Mint(address,address,uint256). I believe wrapper replaced this hash with index of the event type inside myContract.events array. Oct 28, 2019 at 10:27

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.