Minting New Tokens

Mar 12, 2024 11:28:29 PM

Creating New Tokens

Tokens must be created before they can be transferred. Just setting the total supply is not enough. In our contract, we are going to mint all the tokens during deployment and assign them to the contract owner.

Transaction Sender

The transaction 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 requires you to fire an event when tokens are created (minted). This allows wallets and other applications to track the token supply. The standard also specified that you must fire an event when tokens are burned.