Let’s create a Fungible Token (FT) on the NEAR blockchain. FTs are exchangeable assets that are divisible and not unique, making them ideal for representing currencies or other interchangeable items. Here’s a step-by-step guide to defining and creating your own FT:
Understand the Basics:
- A fungible token is an asset that can be exchanged for another of the same kind. For example, if Benji has 1 Canadian dollar, it’s equivalent to Matt’s Canadian dollar. Both dollars are fungible.
- Non-fungible tokens (NFTs), on the other hand, are unique and indivisible (like a specific house or car).
Navigate to the Skeleton Contract:
- Start by switching to the
1.skeleton
folder in the NEAR repository. If you haven’t cloned the repository, refer to the Contract Architecture to get started. - You can find the finished code for this tutorial in the
2.defining-a-token
folder.
- Start by switching to the
Define Metadata for Your Token:
- Open the
1.skeleton/src/metadata.rs
file. This is where you’ll define metadata for your fungible token. - Required fields:
spec
: Set toft-1.0.0
.name
: Human-readable token name (e.g., “Wrapped NEAR” or “TEAM Tokens”).symbol
: Token abbreviation (e.g., wNEAR or gtNEAR).decimals
: Used in frontends to display significant digits.
- Optional fields:
icon
: Token image (must be a data URL).reference
: Link to supplementary JSON details stored off-chain.reference_hash
: Hash of the referenced JSON.
- Open the
Add Metadata to the Contract:
- In the
1.skeleton/src/lib.rs
file, add the following to theContract
struct:Rustpub struct Contract { // Other fields... metadata: TokenMetadata, }
- Store the metadata on the contract under the
metadata
field.
- In the
Compile and Deploy:
- Compile your contract using the NEAR compiler (e.g.,
near-sdk-as
for AssemblyScript). - Deploy your contract to the NEAR network using the NEAR Wallet or command-line interface.
- Compile your contract using the NEAR compiler (e.g.,
Test Your Token:
- Verify that your fungible token works as expected. Test transfers, balances, and other functionalities.
Document and Promote:
- Create detailed documentation for your token, explaining how it works and its security features.
- Share your token with the NEAR community through forums, social media, and development platforms.
Remember, creating a token involves technical steps, but with patience and persistence, you can build your own custom token on the NEAR blockchain! 🚀
For a more detailed tutorial, check out the Defining a Fungible Token tutorial.1
Useful links :
Defining a Fungible Token Tutorial:
- This tutorial guides you through creating a complete FT smart contract from scratch that conforms with all the NEAR FT standards. Learn what a fungible token is and how to define one on the NEAR blockchain.
- Defining a Fungible Token Tutorial1
More NEAR Tutorials:
- Explore other tutorials and examples related to NEAR development, including random numbers, DeFi, governance, and more.
- NEAR Examples & Tutorials2
NEAR Token Basics:
- Understand the native token used in NEAR Protocol, its use cases, and how it secures the network.
- NEAR Token Documentation3
Feel free to explore these resources to dive deeper into creating your own custom token on the NEAR blockchain! 🚀
0 Comments