Entrypoints
In Tezos there are two different types of accounts: implicit and originated. The latter is an account with Michelson code attached to it and is basically known as smart contract. It can be seen as a collection of functions that share and manipulate the same storage. Different to implicit accounts, originated accounts can receive more than just ꜩ in a transaction, namely parameters that are consumed when executing the code. Those parameters always first arrive at the main function of the code.
The challenge is how to address specific functions from the "outside", while parameters are always passed to the main function? That's why we have so called entrypoints that work like the following: variants of parameters get matched and routed to the functions we want to address. In this way, entrypoints make functions explicitly callable from the outside of the smart contract.
Remember
Entrypoints make functions explicitly callable from the outside of a smart contract.
Example from the workshop
In the notarization workshop the smart contract has two functions exposed with the help of entrypoints:
- NotarizeDocument(notarizeParameter): It takes a new document hash to notarize and a list of signees.
- SignDocument(signParameter): This signs an existing document for a given document hash.
The chart below shows how both variants of the parameters are matched in the main function of the smart contract. The variants are notarizeParameter with (documentHash, signees) and for signParameter with documentHash. Depending on which parameter is passed in the transaction, one of the two functions notarizeDocument and signDocument is called. As you can see, the exposed functions are calling other functions that are within the smart contract, which are not exposed to the outside.
We can also look at the code that does this matching. It is written in Ligo in the ReasonLIGO flavor.