Skip to main content
Version: Next

Decorators

Decorators modify the default semantics of a piece of code. Decorators come in two forms:

  1. @name_of_decorator
  2. @name_of_decorator("Some string")

The most common use of a decorator is to denote an entrypoint.

Decorators are placed immediately before the code they apply to. You can also apply multiple decorators on one line, as in this example:

type storage = int;
type result = [list<operation>, storage];
@entry @no_mutation
const sub = (delta: int, storage: storage) : result =>
[[], storage - delta];

Note that the lexical convention for decorators clashes with that of escaped variables. Therefore, you cannot escape the name of a decorator and use it as a variable name.

List of decorators

LIGO supports these decorators: