Limitation on the number of events per operation in Smart Contracts

Hello everyone,

I wanted to start a discussion about the limitation in Smart Contracts: an operation cannot emit more than 25 events.

From what I understand, this limit was introduced after the Certik audit.

Even a simple operation, like a transferFrom in an MRC20, can emit an event, so this limit can quickly become restrictive.

Some questions and points for discussion:

  • Why exactly was this limit introduced?

  • Are there any strategies to mitigate this issue, knowing that it is not possible to suppress event emission when one Smart Contract calls another?

Thanks for your feedback and experiences!

Hello!
Thanks for raising the topic. I think this is a really annoying issue that could block a lot of contract builders.
Even very simple uses case are made impossible due to this limitation:
like sending MRC20 token to more than 25 wallet.

I think the limit has been set to avoid node spamming, but i don”t know the details.
Why this limit is not handeled with gasCost instead of set an hardcoded limit?

I don’t know neither what is the rational behind the 25 number.

We can imagine several kind of mitigation for this:

  • Increase the 25 limit

  • remove the MRC20 events (by modifying the bytecode during a node update)

  • Having a “no event” mode for contract call would be nice but we have to think about the implications. Considering that events are ephemeral anyway it might be possible to do it.

1 Like

Hi!

A “no event” mode is a good option. When developing a smart contract, you can choose the “no event” mode (for the entire SC), or when using call(at: Address, functionName: string, args: Args, coins: number, noEvents: bool) — adding the boolean noEvents.

Additionally, in massa-web3, you can add an option like { noEvents: true } in call(.., { Options }).

1 Like