LIGO is a programming language for writing Tezos smart contracts.
LIGO compiles scripts written in a high-level language into Michelson script.
A smart contract is some code written in Michelson language (a low-level stack-based turing-complete language).
- It defines all the entrypoints (invokable functions) of the smart contract.
- It defines the prototype of each entry point (e.g. specifies the parameters types of the entry point).
- It defines the storage of the smart contract.
The storage is an allocated memory space associated with a smart contract. The description of the storage is done by strongly-typing the data structure.
Entrypoints of a smart contract describe how to mutate the storage. Executing an entry point takes some of the parameters and a state of the storage and returns a new state of storage and some operations.
FIGURE 1 Smart Contract
LIGO functions are the basic building block of smart contracts. Each entrypoint of a contract is a function and each smart contract must have at least one main function that dispatches the control flow to other functions.
The option type is used to express if there is a value, of some type, or none. This is especially useful when calling a partial function, that is, a function that is not defined for specific inputs.
failwith(<string_message>)throws an exception and stop the execution of the smart contract.
You can transfer tez to an account, or to the function of another smart contract, with
Tezos.transaction (<parameter>, <mutez>, <contract>)