Create your own Fungible Token on the Near Protocol from scratch in 5 minutes

The fullest step-by-step guide on how to create your own FT on the Near Protocol blockchain from scratch

Den
Near Protocol Development
3 min readMay 29, 2022

--

Introduction

Hi, readers 👋

Did you ever wonder to create your own Fungible Token on the Near Protocol blockchain❓

If your answer was “yes”, then this guide is exactly what you need — we’ll be going through all steps with you and at the end, you’re a creator of your own Fungible Token

Let’s get started

Prerequisites

To avoid any problems during deployment — don’t forget to ensure you have the latest version of Rust installed:
rustup update

Guide

1️⃣ The very first thing we have to do is to clone the Fungible Token template for further work:

git clone https://github.com/denbite-is-near/ft_template.git ft_contract && cd ft_contract

❗️ In this guide, we use my own template, but you also can use the official template from Near docs

⚙️ [optional] To configure FT on your own, change these parameters

⚠️️ “Decimals” mean a number of symbols after the point

2️⃣ After we got the ready template, let’s build our contract:

./build.sh
contract build process gif

Great news, you’ve recently built your first contract, so the next step is to deploy it to the Near Protocol network (testnet)

3️⃣ Save your account name to the ENV variable for further usage:

In my case account address is ‘denbite.testnet’, but you should type here your own

export ACCOUNT_ADDR=denbite.testnetexport TOKEN_ADDR=token.$ACCOUNT_ADDR

4️⃣ In the Near ecosystem, we have to create a separate account where the token contract will be located at:

near create-account $TOKEN_ADDR --masterAccount $ACCOUNT_ADDR --initialBalance 3

✅ Expected terminal output is:

Account token.denbite.testnet for network “testnet” was created

5️⃣ Now let’s make an actual deployment of our contract:

near deploy --accountId $TOKEN_ADDR --wasmFile out/main.wasm

✅️ The expected terminal output is:

Transaction Id FyqQJQCSPQ7cQmRwKPzzS4fFdoZ9QGZv5W2gstiEf3ys
To see the transaction in the transaction explorer, please open this url in your browser
https://explorer.testnet.near.org/transactions/FyqQJQCSPQ7cQmRwKPzzS4fFdoZ9QGZv5W2gstiEf3ys
Done deploying to token.denbite.testnet

6️⃣ The next step is to call the initialization function to make our Fungible Token contract actually works

near call $TOKEN_ADDR new_default_meta '{"owner_id": "'$ACCOUNT_ADDR'", "total_supply": "10000000"}' --accountId $TOKEN_ADDR

⚠️ Note that ‘total_supply’ is a stringified version of a 128-bit integer

✅ The expected terminal output is:

Transaction Id H2ddCjm2pgmCxwy5v4a63SST8dFnaqjYTeJCNnoZX74h
To see the transaction in the transaction explorer, please open this url in your browser
https://explorer.testnet.near.org/transactions/H2ddCjm2pgmCxwy5v4a63SST8dFnaqjYTeJCNnoZX74h

7️⃣ Let’s review whether our token is actually deployed and created

Follow here to open your testnet wallet

ft balance in the near wallet

⚠️ The precision of your token is 6 decimals after the point
This is why you see only 10 tokens in the wallet
10⁷ / 10⁶ = 10 FTNEAR

Great, we’ve done it 🎉

At this point, you know how to create and deploy your own Fungible Token on the Near Protocol, which only are our first steps in learning crypto tokenomics 👀

Stay tuned and don’t miss the next chapter soon 😇

If you’ve found this article useful, reach over to the 👏 button and hit it as many times as you have enjoyed reading this post. Your responses are also highly appreciated. You could also find me on the Twitter.

--

--

Den
Near Protocol Development

Follow me on Twitter https://twitter.com/captaincatd #web3 #NearProtocol #blockchain #development Hit FOLLOW ⤵