AFAIK, there is no way to update storage types(ex: can't add a new record field to a Map<sp.Nat, sp.record(a=1)>) of a contract after deployment. (Correct me if I'm wrong). This means, after a contract is deployed later on, the only way to add additional storage is to rely on encoding the data in JSON or to have it live under a different contract. Are there any other alternatives?

Is the main downside to using JSON for storage the expense in parsing/unparsing and saving/resaving of the JSON string blob? Perhaps if the JSON blob isn't too big it's not a big deal?

1 Answer 1


Parsing and unparsing json seems totally impractical.

You’re correct in your assumption. You cannot change the type of the storage. You could use a map so that fields are replaced by keys (supposing you want to add a field of a known type).

  • that's a good point. using several maps to handle various known types would work and is way better than JSON
    – JJJ
    Apr 10, 2021 at 8:21
  • 1
    An alternative is to have a map whose values are a variant type with the different possibilities. See the Chainlink oracle template for an example. Please let me say that simplicity is an important factor anyhow; you should not over engineer your design.
    – FFF
    Apr 10, 2021 at 12:27

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.