Minting New Tokens

Apr 29, 2024 11:46:57 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.

Blockchain Transactions

A transaction is a set of instructions that are sent to the . It’s used to invoke smart contract methods. Besides the instructions, a transaction also contains authentication information, such as the sender’s .

Transaction Sender

The pays the transaction fees. In most cases, the transaction sender is involved in the transaction. However, it’s possible to send a transaction on behalf of someone else.

In our example, we set the contract owner as the transaction sender.

Setting the Initial Balances

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

Now, when you run the balanceOf method, 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 dev1 and press enter. The method will return the total supply.

What NEP-17 Standard Says About Minting

The NEP-17 requires you to fire an event when tokens are created (minted). This allows wallets and other applications to track the supply. The standard also specified that you must fire an event when tokens are burned.