Native tokens exercises
- You should be familiar with setting up and operating a Cardano node.
- 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.
- Checkout and build the
githubsources for the
cardano-nodethat have been tagged with
- Start a Cardano node that you can submit commands to.
This set of exercises is aimed to ensure that you can:
- Manage existing native tokens;
- Create new native tokens;
- Submit transactions that include native tokens on the Cardano blockchain.
Please report any bugs or improvements through the
cardano-node github repository.
- 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?
- 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.
- Define a minting policy script for the KingOfKings currency that allows shelley to create new Ozymandian tokens.
- 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.
- 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?
- 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?
- 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?
- 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.
- Set up a number of “mints” that each produce coins of a specific type. The values of each of the coins is given below.
|13 shillings and 4 pence
|6 shillings and 8 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.
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.
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!