I'm currently working on a D-App for a client. It's basically a temper-proof immutable storage of 'objects', each object being defined with 8 key-value pairs (strings) and a collection of pictures.

The client asked explicitly to have everything on-chain. I convinced them to store the pictures on IPFS and store their addresses on-chain. I thought the 8 strings wouldn't be an issue, but I find myself struggling with it because of the stack-to-deep exception, as the record of a new contract should ideally be done in one transaction. Related code:

function addProject(
bytes32[] pictures,
string a,
string b,
string c,
string d,
string e,
string f,
string g,
string h) external payable returns(bytes32) {
  if(msg.sender != owner()) {
    require(msg.value < price, "received insufficient value");


  return registery.addProject(

Registery is a wrapper to an eternal storage pattern modified to be immutable. This function doesn't compile because of the stack-to-deep exception.

My question is: does it make sense to store those 8 key-value pairs on-chain, considering they are just records and don't have any functional value in the smart contract ? Should I spend time trying to find a work around (serialization, etc.) or is it a design issue ?

Thanks a lot !


To answer your "does it make sense": this is a business decision and you should agree about it with your client. I can't even give you much of an opinion as I don't really understand what they are used for.

Basically whatever needs to be immutable should be stored on-chain. IPFS hashes are immutable so those should be on-chain.

As you have noticed, you will face problems with accepting 8 strings as a parameter. Actually the limit is 16 slots and each string takes 2 slots, so you could input those strings if you didn't need any other parameters. But as you probably need other parameters as well, you can'd do it this way.

You could for example consider concatenating the strings in some way into one longer string. Or maybe giving them as an array input?

P.S. I'm assuming your address[] pictures refers to the IPFS hashes? They are not of address type, but of type string - or even better - bytes32.

  • Thanks for your answer Lauri. It is indeed a business decision, but I'd have appreciated to get some pro/cons for an on-chain solution vs ipfs + on-chain hash for a collection of string key-value pairs. Those are basically technical details of a legal agreement (names, location, etc.) that should not be tempered. I read a lot of conversation around files, not so much on using the chain as an immutable data dictionary. – Thibaut Dumont Dec 28 '18 at 14:34

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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