Skip to main content
Version: Next

annot

The decorator @annot("foo") sets the annotation %foo on the compiled Michelson code of record fields and variant constructors.

By default, a variant is compiled to a comb of Michelson or type constructors, and each leaf in the nested tree of or that corresponds to a constructor is annotated with that name (%foo).

Similarly, a record is compiled to a comb of Michelson pair type constructors, and each leaf in the nested tree of pair that corresponds to a field is annotated with that name (%foo).

In other words, the decorator @annot("foo") allows the Michelson annotation for a given field or constructor to be customized. This is useful for interoperability, where third-party programs or contracts expect specific Michelson annotations, even if the LIGO code might not use those names internally.

For example, this code assigns annotations to the fields in a record:

type transfer =
@layout("comb")
{ @annot("from") address_from: address;
@annot("to") address_to: address;
value: nat }

The resulting Michelson code has annotations on the output:

(address %from) (address %to) (nat)