Adding Transfer Notifications

What are Transfer Notifications?

It’s not possible to infer the effects of a transaction by just looking if the transaction was successful or not. We need to use blockchain events to notify the network and other applications about the changes that happened during the transaction.

NEP-17 Transfer Event

The standard defines the Transfer event must be fired when tokens are transferred, including when new tokens are created or destroyed.

The Transfer event signature is:

Make sure you are following the standard when firing the Transfer event. If you don’t, your won’t be compatible with wallets and other applications.

Adding the Transfer Event

Let’s add the Transfer event to our smart contract. Most SDKs provide classes to fire NEP-compatible events that can be used to fire the Transfer event. Update your code to fire the Transfer event after the tokens are minted to the contract owner.

Reset the blockchain and run any method to trigger the _deploy method. You should see the Transfer event in the output.

This event will also be used later when we implement the transfer method.