I'm working on adding events to an OpenBrush PSP37 smart contract and deploying it using Substrate Contract UI. However, when I try to call the mint function, I encounter the following error:

Contract Reverted! Dispatch error: TooManyTopics I have attached screenshots of the error message and relevant code snippets for reference.

I'm not sure what could be causing this error or how to resolve it. Could someone please provide some guidance on what might be causing this error and how to fix it?

enter image description here

enter image description here

1 Answer 1


When encountering the "Contract Reverted!" error with the "TooManyTopics" dispatch error while calling the mint function in the OpenBrush PSP37 smart contract, it is likely due to exceeding the limit of event topics that can be written for an event.

Upon searching the source code of the Substrate framework for the error code "TooManyTopics," the following code snippet was found:

// If there are more than `event_topics`, then trap.

if topics.len() > ctx.ext.schedule().limits.event_topics as usize { return Err(Error::<E::T>::TooManyTopics.into()); }

This code snippet indicates that if the number of topics exceeds the predefined limit of event topics, an error will be returned with the "TooManyTopics" variant. By default, the limit for event topics is set to 4 in the Limits implementation:

impl Default for Limits {
fn default() -> Self {
    Self {
        event_topics: 4,
        globals: 256,
        locals: 1024,
        parameters: 128,
        memory_pages: 16,
        // 4k function pointers (This is in count not bytes).
        table_size: 4096,
        br_table_size: 256,
        subject_len: 32,
        payload_len: 16 * 1024,
        runtime_memory: 1024 * 1024 * 128,


The provided code snippet shows the default values for various limits in the Limits struct, with the event_topics limit set to 4.

To resolve the "TooManyTopics" dispatch error, you need to ensure that the number of topics used in your mint function call does not exceed the limit of 4. Review your code and adjust the number of topics accordingly.

enter image description here

enter image description here

enter image description here

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.