Burn and Unlock
This tutorial will guide you through unlocking and burning fractions of NFTs in Concordium contracts, demonstrating how to transfer and manipulate token ownership, and verifying state changes.
Step 1: Burn Fractions
To unlock the token, you'll burn fractions. The transfer function differs slightly from regular cis-2 multi contracts; it checks if a token transfers back to the same contract, indicating a burn.
Note the following:
Start with 1000 tokens in your state, all owned by you.
Burn 400 tokens to test properly.
Transfer some tokens to another account.
Burn the remaining tokens from both accounts.
Check the state.
To transfer the tokens, create a JSON file and add the following to the file:
Run the following command:
Check the state now that you've made a change:
You have successfully burned 400 fractions, and the account has 600 left.
Step 2: Transfer to Another Person
Let's transfer some tokens to an actual account for deeper testing. To do this, follow the steps below:
Modify the "cis2-multi-transfer.json" file or create a JSON file named "transfer-account.json."
Transfer 100 fractions to the second account.
Use the following code:
Run the transfer command below:
When you run the command, you'll see the following in your terminal:
Recheck the state, and you should see two owners with balances of 500 and 100:
Both of the accounts have some assets now
Step 3: Burn Remaining Tokens
Burn all tokens from both accounts and check the state of the fractionalizer and the collateralized token.
Burn 500 tokens from the first account:
Burn the remaining 100 tokens from the second account to unlock the first asset. You should see your account possessing it in the token's state:
Donât forget to invoke the function from the second account as it's the owner of the assets.
Step 4: Check the Token Contract State
Check the token contract state to ensure all tokens are returned when burned. In the previous steps, you saw that the account has "999" tokens and the fractionalizer contract has "1" token.
However, your smart contract is designed to transfer the tokens back when they are all burned. So there should be 1000 tokens in the primary account intact:
By looking at the state, you can confirm the following:
The primary account received all tokens back.
The fractionalizer contract for zero balance
Congratulations, you have completed this tutorial!
Last updated