9

Are there any limitation on the amount of arguments that can be send in an event?

I have a function in which I want to trigger event that has 12 arguments of which 6 arguments are arrays. I get Stack too deep, try using less variables. Without the event the function works normally.

I am guessing event arguments have some limitations or count towards max arguments in a solidity function but I cannot find any documentation around it.

Can anyone clarify this?

1 Answer 1

11

To answer my own question:

If you look at the ContractCompiler.cpp where FunctionDefinition is declared, you see there is a limit of 17 elements on the stack ;

if (stackLayout.size() > 17)           
  BOOST_THROW_EXCEPTION(   
        CompilerError() <<     
    errinfo_sourceLocation(_function.location()) <<     
    errinfo_comment("Stack too deep, try removing local variables.")     
);  

Events are defined as functions, as can be seen in ExpressionCompiler.cpp.

Simply put Events are treated as functions so they have a limit of 17 arguments. Array counts as 2 so in my example where I have 6 arrays + 6 normal arguments this equals 18 and I'm breaking the stack by 1.

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.