0

I am facing an issue with the OpenBrush PSP37 smart contract while calling the mint function. I receive a Contract Reverted! error with a TooManyTopics dispatch error. However, upon inspecting the substrate blockchain code, it specifies that up to 4 topics are allowed. In my case, I am only using 4 topics, as visible in the attached screenshot. Could someone please help me understand why I am encountering the "TooManyTopics" error? Surprisingly, when I reduce the number of topics to 3, the contract works fine.

I have previously addressed this issue, and it was recommended that we adhere to a maximum limit of four topics. However, even when we precisely utilize four topics, we continue to encounter the same error. You can find our previous discussion at this Stack Overflow post :enter link description here

Could anyone shed some light on this issue? Is there a possible explanation for receiving the TooManyTopics error even when using the maximum allowed number of topics?

Thank you for your valuable insights and suggestions.

enter image description here enter image description here enter image description here

1 Answer 1

1

#[ink(topic)] is use to index the events, you can find more info about it here, now to answer your question that you are unable to use 4 ink(topics) at a time is that one of the ink(topic) is used by the signature of the event as mentioned in above link, if you want to use all the 4 topics for you event than use #[ink(anonymous)] it will not include the signature of event as an ink(topic) and you are good to go. You can use #[ink(anonymous)] as follows:

#[ink(event)]
#[ink(anonymous)]
pub struct MyEvent {
    #[ink(topic)]
    field_1: i32,
    field_2: bool,
}

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.