1

From my experience you can declare events with capital letter.
eg: ThisHappened(address user, bytes32 act);

Then you can call it by just writing: ThisHappened(user, "ATE_HAMBURGER");

But recently I saw a contract writing emit ThisHappened(user, "ATE_HAMBURGER");

What is the difference? Which one should I use?

1 Answer 1

1

emit was introduced in solidity version 0.4.21 after a long discussion. It just helps you to differentiate between event and function. Code will work same with or without emit.

For more detail: https://medium.com/@aniketengg/emit-keyword-in-solidity-242a679b0e1a

2
  • I'm pretty sure that it doesn't compile without emit in Solidity 0.4.21 and later. Commented May 9, 2018 at 12:31
  • In my case, it just throws a deprecation warning on Truffle & Remix if you don't use emit
    – Aniket
    Commented May 9, 2018 at 12:35

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.