Minting New Tokens

Creating New Tokens

Tokens must be created before they can be transferred. Just setting the total supply is not enough. The total supply is just a number that represents the total amount of tokens that can be created. In our case, we are going to mint all the tokens during deployment and assign them to the contract owner.

Transaction Sender

The transaction sender is the account that is sending the transaction. It must have signed the transaction and it is the account that pays the transaction fees. In our case, we will set the transaction sender as the contract owner.

Setting the Initial Balances

Update the _deploy method to set the sender balance to the total supply.

Now, when you run the balanceOf method using the sender, it will return the total supply. Since we updated the _deploy method, we need to reset the contract. Press Ctrl+Shift+P to open the command palette and select Linkd: Reset Blockchain.

Next, run the balanceOf method by pressing Run. Select the first account from the dropdown and press enter. The method will return the total supply.

What NEP-17 Standard Says About Minting

The standard does not define a method to mint new tokens. However, it does require you to fire an event when tokens are minted. This is to allow wallets and other applications to track the supply. The standard also requires you to fire an event when tokens are burned.