12

I'd like to set lots of arguments in solidity functions. I wonder how many arguments contracts can handle. Does it depend on number of arguments or data size?

2 Answers 2

4

Someone who is more familiar with the compiler may know otherwise, but at least from looking at the code (libsolidity) that deals with parsing .sol contract code into the compiler, there doesn't appear to be a limit.

(I'm specifically looking at parseFunctionCallListArguments and parseFunctionCallArguments in Parser.cpp.)

1
  • 1
    Solidity allows 16 parameters. Reference Link: docs.soliditylang.org/en/v0.8.2/… The EVM is not a register machine but a stack machine, so all computations are performed on a data area called the stack. It has a maximum size of 1024 elements and contains words of 256 bits. Access to the stack is limited to the top end in the following way: It is possible to copy one of the topmost 16 elements to the top of the stack or swap the topmost element with one of the 16 elements below it. Mar 7, 2021 at 23:57
3

It looks like in order to avoid the Stack too deep, although function argument can take 16 parameters, the safest way is to avoid exceeding the 16 parameter number else you run into a Stack too deep error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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