7 : Mint from a wrapped token in Soroban.
Token Playground Chapter 7 : Mint from a wrapped token in Soroban.
Check this guide in https://token-playground.gitbook.io/
Edit this guide in it's repo: https://github.com/esteblock/token-playground/
Contribute to this guide in the ./docs folder of the repo
1. Introduction
In the previous chapters we have already:
Issued a (classic) Stellar Assets in the (classic) Stellar blockchain.
Wrapped this asset into a SAC (Stellar Asset Contract) token into Soroban
In this chapter we will mint some units of this SAC token inside the Soroban chain, so this token can be used by smart contracts!
2. Setting up your soroban-cli
Configure your soroban-cli to use the token-admin
identity
Check last chapter if you don't know what this means.
3. Smart Contract ID
From last chapter, you'll need to have your SAC's id, that can be something like this:
If you followed our Token Playground's code, you should have this id inside the .soroban/token_id
file
3. Destination address
As when issuing an asset in Stellar Classic, in order to mint a token in Soroban, you need to send units of this token to some receiver, hence we will set a receiver address:
If you are following our code, and you are using the settings.json
file, you can do
4. The xfer function
In order to mint, we will use the soroban invoke
command in the soroban-cli
in order to invoke a function inside the SAC contract.
The transfer function in a SAC contract is the xfer function and receives 3 arguments:
from
to
amount
Here is a piece of code of the SAC contract
If you want to learn more about the SAC code in the Stellar guide
5. Invoke the xfer function and mint the token
If we invoke the xfer function from the issuer we will actually mint some units of the token, hence, we will do:
Here, src/contracts/token/soroban_token_spec.wasm
is the path of token wasm file. We provide you the one used when wrapping the token.
6. Did it mint? in Stellar or in Classic?
How can we know if we in fact minted the token?
In fact, when we wrap the token, both balances of the token Soroban/Classic are shared. Hence, if we ask Stellar Classic it yould say that there are not 5 units anymore, but 10.
And if we ask to the SAC token, it should say the same.
In chapter 5 we took information about the Stellar Asset in the classic Stellar. Let's ask Stellar Classic (check chapter 5!)
The answer:
We have now 10 units of the token! We managed to suscesfully mint a wrapped asset in Soroban!
5. Use our code
If you want to use our code in the Token Playground's Repo, you can just call our script with the soroban-preview-7
docker containter
You can run it by:
Check all the code of our mint_with_just_token_id.sh
script here
What is next?
In this chapter we minted units in Soroban, but we checked the total balance in Classic. In the next chapter we will use the SAC contract to get information about the token in Soroban. We should get the same information than in classic. Why? Because balances are shared!
Are you ready?
This Playground has been developed by @esteblock in collaboration with @marcos74 from @Dogstarcoin
Last updated