Adding Contract Metadata

Apr 29, 2024 11:46:57 PM

What is Metadata?

Contract Metadata is information that is associated with a smart contract. It’s used to describe the contract’s properties, such as its name, version, author, and others. The metadata information is usually stored inside the contract’s manifest.

Smart Contract Manifest

The manifest contains information about the contract. This includes methods, permissions and metadata. The manifest is automatically generated by the compiler. The manifest is stored in the 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 NEP-17 :

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

Some compilers may automatically add the onNEP17Payment method to the manifest. We recommend you add it manually to avoid 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.