I am trying to pass 13 arguments as string and creating a structure with them. But I am getting error: Stack too deep, try using less variables.

My code:

struct Test { 
// 13 string variables... }

function myfunc(13 string parameters...){
      Test t = Test(13 parameters...); // have to initialize t

Any possible solution to the problem ?

  • Just a friendly remark. When you need 13 parameters for a function, maybe the interface design should be improved. I can't remember a situation where I really needed more than 8 parameters during the past 25 years as a developer (coding in more than a dozen languages). Jun 7, 2020 at 11:17

1 Answer 1


The following piece of code is working perfectly fine:

pragma solidity ^0.4.20;

contract multiVar {
    struct trial { 
        string s1;
        string s2;
        string s3;
        string s4;
        string s5;
        string s6;
        string s7;
        string s8;
        string s9;
        string s10;
        string s11;
        string s12;
        string s13;

    trial t;

    function myfunc(string t1,
        string t2,
        string t3,
        string t4,
        string t5,
        string t6,
        string t7,
        string t8,
        string t9,
        string t10,
        string t11,
        string t12,
        string t13){
          t = trial(t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12,t13);

However, you may want to know that there is a limitation on number of local variables you can use. This answer might solve your problem.


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.