Skip to main content
Version: 19.2.0

Storage with/without annotations

This section shows how to write storage when :

  • it has annotations
  • it has no annotation
  • it has a mix of annotated and not-annotated properties

To do so, let's look at three examples of contract origination showing initial values in the storage.

When all the properties are annotated

//storage representation in Michelson
(pair
(pair
(pair (address %theAddress) (bool %theBool))
(pair (nat %theNat) (int %theNumber)))
(mutez %theTez))

We need to write the storage as a Javascript object and include the annotated names in it.

Live Editor
Result

When there is no annotation

//storage representation in Michelson
(pair
(pair
(pair (address) (bool))
(pair (nat) (int)))
(mutez))

All properties in storage are accessible by the index corresponding to the order that the storage is defined.

Live Editor
Result

When some arguments are annotated and others are not

//storage representation in Michelson
(pair
(pair
(pair (address) (bool))
(pair (nat %theNat) (int %theNumber)))
(mutez))

In the following example, only the elements in positions 2 and 3 have an annotation. We need to access these elements with their annotated name and the others with corresponding indexes.

Note that when proprieties have annotations, we cannot access them by index. For example, if you replace "theNat" by 2 and "theNumber" by 3 in this code example, it will fail.

Live Editor
Result

Provide detailed feedback