Native Tokens Exercises

Prerequisites

  1. You should be familiar with setting up and operating a Cardano node.

  2. Read the explainer about multi-asset tokens, documentation on how to work with the Cardano node, and operations with multi-asset tokens in the sections above.

  3. Checkout and build the github sources for the cardano-node that have been tagged with mary.

  4. Start a Cardano node that you can submit commands to.

Objectives

This set of exercises is aimed to ensure that you can:

  1. Manage existing native tokens;

  2. Create new native tokens;

  3. Submit transactions that include native tokens on the Cardano blockchain.

Please report any bugs or improvements through the cardano-node github repository.

Exercises

  1. Create a set of private/public signing keys, shelley, and three addresses (ada, mary and percy). Fund ada from the faucet. Request some Wollstonecraft tokens from the token owner to fund your mary address. Verify that both addresses have the expected values. What do you observe about the mary values?

  2. Send 100 ada from ada to mary, and 10 Wollstonecraft from mary to percy. Check the values of all three addresses before and after the transactions.

  3. Define a minting policy script for the KingOfKings currency that allows shelley to create new Ozymandian tokens.

  4. Mint 1000 new Ozymandians in the percy address. Check that they have been successfully minted. Note that you might need to fund the percy address with additional ada.

  5. What is the least amount of ada that you need to keep in each of your addresses? What is the least amount of Ozymandians or Wollstonecraft that you can keep in an address?

  6. You want to redeem some of your Wollstonecraft tokens. How do you do this? Similarly, how do you redeem your Ozymandians? What happens to your ada balances when you redeem your tokens?

  7. Create a new minting policy script that allows shelley to create Wollstonecraft, ada and Ozymandian tokens. Mint new tokens of each type and send them to mary and percy. Check that they have been successfully received. What do you observe about the balances on each of the addresses?

  8. Create five new signing addresses: athena, zeus, hera, poseidon and dionysus. Create a minting policy script that allows any majority of the five Olympians to mint Platinum, Gold, Silver and Bronze medals. Send percy one new Gold medal, and send mary one new Platinum medal, two Gold medals, and four Silver medals. Check the balances for each of your addresses. Now transfer one Gold medal and one Silver medal from mary to percy and check the balances again.

Optional exercises

  1. Set up a number of “mints” that each produce coins of a specific type. The values of each of the coins is given below.

Coin Value
Pound 20 shillings
Merk 13 shillings and 4 pence
Noble 6 shillings and 8 pence
Shilling 12 pence
Bawbee 6 pence
Groat 4 pence
Penny 1 pence

Each mint may produce new coins to match the value of any coins that are sent to a specific address. For example, if the Bawbee address is sent three Groats, two new Bawbees may be minted. Coins can be minted up to the value that has been received. Any excess is lost. So if the Noble mint address is sent 8 Shilling coins, then one new Noble coin is minted in exchange.

Please note that until we have Plutus scripts, there is no way to enforce these conversion rates on-chain, and you will need to do them manually.

  1. Set up a “coin exchange” with one or more colleagues. Each of you is responsible for one or more “mints”. You should each set up an exchange address and fund it with newly minted coins that are worth precisely twenty-one shillings. Now practice sending coins and changing them for ones of equivalent value. For example, if someone sends you two Merk coins, you might return one Pound coin and one Noble coin, or any other equivalent value that you like. Use transaction metadata to record the coin exchanges on-chain. If you cannot give the exact change, give the closest value that you can.

  2. Adapt your exchanges so that you charge a fee of 10% for each transaction. Record this in a separate account. Exchange coins until one of you can no longer make change.

Thank you for completing the exercises!