entry
The decorator @entry
on a function marks that function as an entrypoint of the contract, either at top-level or in a module that is then used as a contract.
Here is an example of entrypoints defined in a module:
type storage = int;
type @return = [list<operation>, storage];
namespace Foo {
@entry
const decrement = (param: int, storage: storage) : @return =>
[[], storage - param];
@entry
const increment = (param: int, storage: storage) : @return =>
[[], storage + param];
@entry
const reset = (_u: unit, _s: storage) : @return =>
[[], 0];
@view
const get_storage = (_: unit, storage: storage) : storage => storage;
};
Note that if you want to define an entrypoint called default
, use
the escaped identifier @default
because default
is a keyword.