NEP-17

What is NEP-17?

NEP-17 is a standard for creating fungible tokens on the Neo blockchain. It is similar to the standard on Ethereum. By following the NEP-17 standard developers can ensure that their is compatible with existing and future applications.

NEP-17 Standard

The NEP-17 standard defines the interface for a fungible token on the Neo blockchain. It defines the following methods:

  • symbol() -> string - Returns the symbol of the token.
  • decimals() -> int - Returns the number of decimals used by the token.
  • totalSupply() -> int - Returns the total supply of the token.
  • transfer(from: UInt160, to: UInt160, amount: int, userData: Any) -> bool - Transfers tokens from one account to another.
  • balanceOf(account: UInt160) -> int - Returns the balance of the specified account.

It also defines one event:

  • Transfer(from: UInt160, to: UInt160, amount: int) - Triggered when tokens are transferred from one account to another. This event must triggered when tokens are minted or burned.

And one callback:

  • onNEP17Payment - Triggered when tokens are transferred to the contract.

The casing of the methods, events, and callbacks is important. They must be named exactly as specified in the standard.