5

Because anonymous events do not contain the hash of their signature as their first topic, you cannot easily search for them on the blockchain.

However, if the set of the indexed arguments of an anonymous event is unique in the contract (say, it is the only one that indexes an uint256, followed by a string), then, deducing when it has been emitted is relatively simple.

But what if there are 2 anonymous events which the same indexed arguments? How do you tell them apart once they're emitted?

2
  • 1
    You can extract any information from blockchain transactions. It is all public there. It is just matter of difficulty to how to get them. Oct 14, 2021 at 19:34
  • How do you check that a log was produced by an anonymous event then?
    – Sun
    Oct 16, 2021 at 9:16

1 Answer 1

1
+50

It is not possible to differentiate between the two just by comparing the log output. According to the solidity documentation, it is even possible to fake the signature of an event using an anonymous event.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

contract Event {
    event Log(address indexed sender, string message);
    event FakeLog(bytes32 indexed sig, address indexed sender, string message) anonymous;

    function test() public {
        emit Log(msg.sender, "Hello World!");
        emit FakeLog(Log.selector, msg.sender, "Hello World!");
    }
}

Here, Log and FakeLog would produce identical outputs.

However, this only means that you cannot identify source from the event data alone. You can always run the transactions on a node and see which event is issued.

3
  • Some eventa may only be emitted when certain users/addresses call the functions emitting them, so "executing the transactions yourself" is not always a good alternative... Unless you execute the transactions programatically in a "fork testing" environment via Foundry, I think.
    – Iaroslav
    May 17, 2023 at 16:10
  • 1
    When I say "executing the transactions yourself"", I mean execute the transaction on an Ethereum node and watch observe the state changes. I have clarified that in my answer. May 18, 2023 at 10:35
  • Oh, so, that'd involve running (or having access to) a Full Ethereum node. Gotcha!
    – Iaroslav
    May 18, 2023 at 11:11

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.