I'm trying to create a contract which stores simple user profile information like name, email, age, address, etc (all string/bytes type) and I've come across the size restriction issue when passing the arguments to the constructor/function.

What are the best possible options to work around this limiation?

Should I serialize and pass this data somehow? Or is it better to just store this simple data object of every user in IPFS and save the hash in the contract?


The best solution is to use arrays which only count as one variable

So if you have

address var1;
address var2;
uint var3;
uint var4;

You can turn this into two variables by going:

address[2]  address_vars;
uint[2] uint_vars;

Then later in your code, you can just access them through the array like:

address_vars[0] = msg.sender;

and so on. In your case(inputs), you can input arrays too:

function myFunc(uint[6] _uint_vars) public {
  • Sorry I forgot to add, the inputs I want to pass are of String / Bytes type. And so there are restrictions in passing an array format of that type if I'm not wrong Jun 16 '18 at 18:50
  • Well bytes you can do an array. The other thing you can do is just bundle up all the ones that can do arrays on to lower the number of variables. The problem is a 'stack too deep' error which comes if you have too many local variables (which all stuff passed in is).
    – thefett
    Jun 17 '18 at 0:34

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