Adding Contract Metadata

What is Metadata?

Metadata is data that describes other data. In the context of , metadata is used to describe the contract’s properties, such as its name, version, author, and so on.

Smart Contract Manifest

The smart contract manifest is a JSON file that contains the contract’s metadata. It’s generated by the compiler. It’s possible to customize the manifest properties. The manifest is stored in the blockchain along with the contract’s bytecode.

Adding Smart Contract Metadata

First, add the following code to the contract name and label the contract as an :

This will tell the compiler that the contract is an NEP-17 token. The supported_standards property is a list. You can add more standards to the list if you want.

Note that some compilers may throw an exception if you try to compile a contract that doesn’t implement the standards it claims to implement. Check the error message to see if this is the case.

Allowing OnNEP17Payment Calls

The NEP-17 standard defines the onNEP17Payment method must be called when tokens are transferred to a smart contract. This method is used as a callback to notify the contract about the transfer. This allows the recipient to perform actions when it receives tokens. However, we must explicitly allow our contract to call the onNEP17Payment method. Some compilers may automatically add the onNEP17Payment method to the manifest but we recommend you to add it manually to avoid any issues.

Add the following code to the contract to allow the onNEP17Payment method to be called:

Adding Other Properties

You can add custom properties to the manifest. Use it to add information about the contract, such as its name, version, author, and so on.

Add the following code to the contract to add a contract author to the manifest:

Coin Ready for Deployment

If you followed all the steps correctly, you have created a NEP-17 compatible token. This will allow it to be used by existing wallets. To use it, you need to deploy it to the Testnet. Once it’s deployed, you can use any compatible to interact with it.