0

I have to extend my modifier to support different number of input arguments. Modern languages as Java support varargs arguments, but I do not see any information about it in solidity.

Here is the ambiguous information regarding the stack for input parameters either not limited or limited up to 16 params.

Do you know more about this issue? Is it possible to define varargs as an input parameter for a function or modifier?

1
  • 1
    I think all the params are strung together as one string of bytes. There's probably a way to access it but you won't know how the arguments were supposed to be formatted. Dec 14, 2022 at 10:34

2 Answers 2

1

Solidity currently does not support defining varargs as an input parameter for a function or modifier. However, there is a way to add anonymous params (e.g. with no name).

1

In Solidty, codes convert to EVM bytecode in two different ways: directly from solidity code to EVM opcode ("old codegen") or intermediate representation (“IR”) in Yul (“new codegen”), if you have more than 16 variables in one function in old codegen you get "stack is too deep" error, for solving this problem you can pass variables in less than 16 variables packages or using turning on "viaIR" . viaIR lets you use more than 16 variables.

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.