This example demonstrates how to implement a compliant NEP-17 token on the Neo N3 blockchain. NEP-17 is the fungible token standard for Neo N3, similar to ERC-20 on Ethereum. This sample provides a complete implementation with essential token functionality and administrative features.
- Complete NEP-17 standard implementation
- Owner and minter role management
- Token minting and burning capabilities
- Contract update functionality
- Event notifications for state changes
The SampleNep17Token contract demonstrates several key aspects of NEP-17 token design:
- Implements all required NEP-17 methods and properties
- Inherits from the base
Nep17Tokenclass - Includes proper event notifications
- Declares standard compliance with
[SupportedStandards]attribute
The contract implements two distinct administrative roles:
-
Owner Role:
- Controls contract ownership
- Can update the contract
- Can transfer ownership
-
Minter Role:
- Controls token creation rights
- Can mint new tokens
- Can be assigned by the owner
- Symbol: "SampleNep17Token"
- Decimals: 8 (allowing for fractional tokens)
- Storage-based tracking of token balances and supply
SetOwner: Transfers contract ownership to a new addressSetMinter: Assigns minting rights to a new addressMint: Creates new tokens and assigns them to a specified addressBurn: Destroys tokens from a specified addressUpdate: Upgrades the contract to a new implementation
The contract emits the following events:
Transfer: When tokens are transferred between addressesSetOwner: When contract ownership changesSetMinter: When minting rights are reassigned
- Permission checks using
Runtime.CheckWitness - Role-based authorization for sensitive operations
- Protected mint and burn operations
- Secured contract update mechanism
This NEP-17 token implementation can be customized for:
- Fungible tokens and cryptocurrencies
- Governance tokens with voting rights
- Staking and reward systems
- Tokenized assets and securities
- In-application currencies
To adapt this example for your own token:
- Modify the token properties (Symbol, Decimals)
- Update the initial owner and minter addresses
- Adjust minting and burning logic as needed
- Add any additional token-specific functionality
- Configure permissions and access controls
Once deployed, the token can be:
- Minted by the assigned minter
- Transferred between users
- Burned when no longer needed
- Managed by the contract owner
- Updated to new implementations
This example serves as a solid foundation for creating compliant, secure, and functional fungible tokens on the Neo N3 blockchain.