Using Sudo to Mint Native Tokens¶
Introduction¶
Sudo is a module that enables privileged runtime calls to be dispatched when called from the Sudo account. Sudo is sometimes colloquially referred to as a superuser or god-like account. This enables you to perform privileged actions in the course of managing your appchain, such as minting new native tokens.
In this guide, you'll learn how to use Sudo to properly mint new native tokens. This comprehensive guide shows how to check the balance of an existing account prior to assigning it a new balance with Sudo access.
Checking Prerequisites¶
For the examples in this guide, you will need to have the following:
- A Tanssi appchain (Snap or Dedicated)
- Your appchain's Sudo account connected to your appchain's Polkadot.js Apps. You can refer to the Managing Sudo guide for instructions on injecting your Sudo account into Polkadot.js Apps
If you're unsure what your Tanssi appchain's Sudo account is, you can find it in your Tanssi Dashboard underneath the Properties section.
Warning
It's critical to protect your Sudo account key with the utmost security precautions, as it grants privileged access to your Tanssi appchain.
Minting Tokens¶
As you know, the Sudo account has the ability to perform privileged functions, including minting additional tokens. When setting up your Tanssi appchain on the Tanssi dApp, you can specify genesis account balances. In other words, you have the ability to endow accounts with initial balances upon launching your Tanssi appchain. However, you can also mint new tokens after launch with the help of the Sudo account.
Note
This tutorial demonstrates assigning arbitrary token balances on a TestNet appchain that has no value. You should carefully consider the ramifications of creating additional tokens on your own Tanssi appchain.
Checking Existing Account Balance¶
The next section will demonstrate how to assign arbitrary token balances to accounts using the Sudo account. This process will overwrite the specified account's existing balance, so verifying the account is empty is a good practice before continuing. To check an account's balance, take the following steps:
- Navigate to the Developer tab of Polkadot.js Apps and click on Chain State
- Select the system pallet to query
- Select account
- Paste in the account address or select it from the dropdown
- Press + icon
- You'll see the balance information returned at the bottom, including free, reserved, and frozen balances
Assigning Balances with Sudo¶
To assign an account balance to an account, make sure to have your Sudo account accessible in Polkadot.js Apps. Then, take the following steps:
- Navigate to the Developer Tab of Polkadot.js Apps for your Tanssi appchain
- Click on Sudo. If you do not see Sudo in this menu, then you have not associated the Sudo account with Polkadot.js Apps. Make sure that your Sudo account is injected by your wallet and connected to Polkadot.js Apps
- Select the balances pallet
- Select the forceSetBalance method
- Paste in the account address to endow with tokens or select it from the dropdown
- Enter the amount of tokens to endow the account with. In this example, we specify
9000000000000000000
for nine native tokens. Remember that Tanssi EVM appchains have 18 decimals, while Substrate or custom appchains configure the decimals when launching the chain. If you're unsure how many decimals your Tanssi appchain has, navigate to the Settings tab and click on Metadata - Press Submit Sudo and confirm the transaction in your wallet
And that's it! The Developer Portal section has plenty more guides on how to manage your Tanssi appchain.
| Created: March 13, 2024