Chapter 16 : Built-ins

A LIGO smart contract can query part of the state of the Tezos blockchain by means of built-in values. In this section you will find how those built-ins can be utilized.

A few built-ins

Tezos.balance : Get the balance for the contract.

Tezos.amount : Get the amount of tez provided by the sender to complete this transaction.

Tezos.sender : Get the address that initiated the current transaction.

Tezos.self_address : Get the address of the currently running contract.

Tezos.source : Get the originator (address) of the current transaction. That is, if a chain of transactions led to the current execution get the address that began the chain. Not to be confused with Tezos.sender, which gives the address of the contract or user which directly caused the current transaction.

Tezos.chain_id : Get the identifier of the chain to distinguish between main and test chains.

ℹ️ A more complete list is available on


The keyword failwith throws an exception and stop the execution of the smart contract


<string_message> must be a string value

Access Control

This example shows how Tezos.source can be used to deny access to an entrypoint.

type parameter = unit;
type storage = unit;
type return = (list (operation), storage);
let owner : address = ("tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx": address);

let main = ((action, store) : (parameter, storage)) : return => {
  if (Tezos.source != owner) { (failwith ("Access denied.") : return); }
  else { (([] : list (operation)), store); };

Your mission

1- Check that the originitor address is indeed our ship_address, or fail with “Access denied”

2- Check that the sent amount corresponds to the purchase_price, or fail with “Incorrect amount”