I'm developing a contract whose storage is very large.

I have exactly 23 fields in a struct, that is the value part of a mapping.
All the data must be included at once, but given the stack size limit, I can't have all of them declared in the function signature.

So I was thinking about "compressing" most of the parameters into a serialized string (JSON, maybe), but I really need this data to be stored as independent fields. Therefore, I'd need to unserialize this big chunk of data.

Another possibility is to consider everything a big byte array, with fixed size fields, and then split it up in a predefined order.

Is any of these possible?

  • 1
    Interesting. I did not realise there was a stack size limit that would prevent many parameters being passed - " Not having a stack size limit - no particular justification either way; note that limits are not strictly necessary in many cases as the combination of gas costs and a block-level gas limit will always act as a ceiling on the consumption of every resource." from github.com/ethereum/wiki/wiki/Design-Rationale . Commented May 4, 2016 at 15:45

1 Answer 1


While I haven't tried it, that definitely seems possible. Assuming each of your 23 values's can fit into 32 bytes, you can use a bytes32[23].

contract MyContract{
    struct MyStruct {...}
    function MyContract(bytes32[23] input) {
  • Yeah, but this is basically reinventing the wheel :D. If I have to write a stdlib for every contract, I'm screwed. Commented May 4, 2016 at 17:35

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.