CREATE NATIVE TOKEN ON WINDOWS - PART 2
In this second part of the tutorial, we will now mint our native token and receive the tokens to our payment address. Minting tokens is simply creating a transaction with additional minting parameters. All the needed keys and templates should have been generated as shown in the first part of this tutorial.
STEP 1. Create a draft transaction for us to be able to calculate the minimum transaction fee. The transaction hash and index that contains the funds is in the token.csv file we created in the previous video.
But before we proceed, let's copy the content of our payment.addr and policy.id files and paste them inside our token.csv template file.
Notepad "Token\token.csv"
Notepad "Token\payment.addr"
Notepad "Token\Policy\policy.id"
token.csv should now contain the following values:
[PAYMENT ADDRESS],[POLICY ID],[TOKEN NAME],[TOKEN AMOUNT],[TX HASH ID],[TX HASH IX],[BALANCE]
The DOS commands below create 6 variables which values were extracted from token.csv file and assign them to the following placeholders:
%i = payment address
%j = policy id
%k = token name
%l = token amount
%m = UTxO hash id
%n = UTxO hash index
Let's verify the contents of token.csv file if they contain the correct values using this command:
for /F "tokens=1,2,3,4,5,6 delims=," %i in (Token\token.csv) do @echo %i %j %k %l %m %n
Use this command to generate the actual raw transaction file:
for /F "tokens=1,2,3,4,5,6 delims=," %i in (Token\token.csv) do @cardano-cli transaction build-raw --fee 0 --tx-in %m#%n --tx-out %i+0+"%l %j.%k" --mint="%l %j.%k" --minting-script-file "Token\Policy\policy.script" --out-file "Token\matx.raw"
STEP 2. Calculate the minimum transaction fee.
cardano-cli transaction calculate-min-fee --tx-body-file "Token\matx.raw" --tx-in-count 1 --tx-out-count 1 --witness-count 2 --byron-witness-count 0 --mainnet --protocol-params-file "Token\protocol.json"
STEP 3. Deduct the fee from the UTxO balance as our change. Then rebuild our raw transaction with the correct values.
[BALANCE] - [FEE] = [CHANGE]
for /F "tokens=1,2,3,4,5,6 delims=," %i in (Token\token.csv) do @cardano-cli transaction build-raw --fee [FEE] --tx-in %m#%n --tx-out %i+[CHANGE]+"%l %j.%k" --mint="%l %j.%k" --minting-script-file "Token\Policy\policy.script" --out-file "Token\matx.raw"
STEP 4. Sign the transaction to prove the authenticity and ownership of the policy key.
cardano-cli transaction sign --tx-body-file "Token\matx.raw" --signing-key-file "Token\payment.skey" --signing-key-file "Token\Policy\policy.skey" --mainnet --out-file "Token\matx.signed"
STEP 5. Submit the transaction to the blockchain, which mints our native asset.
cardano-cli transaction submit --tx-file "Token\matx.signed" --mainnet
Congratulations, we have now successfully minted our own token. After a few seconds, you can check the payment address and you should see a transaction output with your [Policy ID].[base16 Token Name] using this command.
for /F %i in (Token\payment.addr) do @cardano-cli query utxo --address %i --mainnet
If you want to support my work, any amount of $ADA donation will be highly appreciated or simply subscribe to my channel and share my videos.
Donate $ADA: addr1qxscn6rl2fl5mktyy5nwrd87pj0qqpcpn5rluuc0qcumvgedg50m0eva7negw4fn5cdhghy5xewgmxvm6gx0epv0396qr54yfg
Ещё видео!