However, due to the
recent protocol upgrade
of the Tezos mainnet, Pedro cannot access the tokens stored in his
shop's contract directly. This was previously possible via spendable
smart contracts, which are no longer available in the new
protocol. We will have to implement a solution to access tokens from
the contract programmatically.
Pedro is a standalone business owner, and in our case, he does not
have to split profits and earnings of the taco shop with anyone. So
for the sake of simplicity, we will payout all the earned XTZ directly
to Pedro right after a successful purchase.
This means that after all the purchase conditions of our contract
are met, e.g., the correct amount is sent to the contract, we will not
only decrease the supply of the individual purchased taco kind, but
we will also transfer this amount in a subsequent transaction to
Pedro's personal address.
In order to send tokens, we will need a receiver address, which, in
our case, will be Pedro's personal account. Additionally we will wrap
the given address as a contract (unit), which represents either a
contract with no parameters, or an implicit account.
| None ->(failwith ("Not a contract"):(contract(unit)))
Would you like to learn more about addresses, contracts and
operations in LIGO? Check out the
LIGO cheat sheet
Adding the Transaction to the List of Output Operations#
Now we can transfer the amount received by buy_taco to Pedro's
ownerAddress. We will do so by forging a transaction (unit, amount,
receiver) within a list of operations returned at the end of our
Because Pedro is a member of the Speciality Taco Association (STA), he
has decided to donate 10% of the earnings to the STA. We will just
add a donationAddress to the contract, and compute a 10% donation
sum from each taco purchase.