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?


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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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