Skip to content

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.

Locating your Sudo address on apps.tanssi.network

Warning

You should always 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:

  1. Navigate to the Developer tab of Polkadot.js Apps and click on Chain State
  2. Select the system pallet to query
  3. Select account
  4. Paste in the account address or select it from the dropdown
  5. Press + icon
  6. You'll see the balance information returned at the bottom, including free, reserved, and frozen balances

Check balances on Polkadot.js Apps

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:

  1. Navigate to the Developer Tab of Polkadot.js Apps for your Tanssi appchain
  2. 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
  3. Select the balances pallet
  4. Select the forceSetBalance method
  5. Paste in the account address to endow with tokens or select it from the dropdown
  6. 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
  7. Press Submit Sudo and confirm the transaction in your wallet

Force assign balances on Polkadot.js Apps

And that's it! The Using Sudo section has plenty more guides on how you can use the Sudo account to manage your Tanssi appchain.

The information presented herein has been provided by third parties and is made available solely for general information purposes. Tanssi does not endorse any project listed and described on the Tanssi Doc Website (https://docs.tanssi.network/). Tanssi Foundation does not warrant the accuracy, completeness or usefulness of this information. Any reliance you place on such information is strictly at your own risk. Tanssi Foundation disclaims all liability and responsibility arising from any reliance placed on this information by you or by anyone who may be informed of any of its contents. All statements and/or opinions expressed in these materials are solely the responsibility of the person or entity providing those materials and do not necessarily represent the opinion of Tanssi Foundation. The information should not be construed as professional or financial advice of any kind. Advice from a suitably qualified professional should always be sought in relation to any particular matter or circumstance. The information herein may link to or integrate with other websites operated or content provided by third parties, and such other websites may link to this website. Tanssi Foundation has no control over any such other websites or their content and will have no liability arising out of or related to such websites or their content. The existence of any such link does not constitute an endorsement of such websites, the content of the websites, or the operators of the websites. These links are being provided to you only as a convenience and you release and hold Tanssi Foundation harmless from any and all liability arising from your use of this information or the information provided by any third-party website or service.
Last update: May 10, 2024
| Created: March 13, 2024