Create an ERC-20 Token | Avalanche Docs (2024)

ERC-20 tokens are the most fundamental and essential concept in Ethereum. As the Avalanche community and the ecosystem are growing, new use cases and projects that are running on Ethereum or different chains would be implemented to Avalanche.

Therefore, we will be creating our own mintable ERC-20 token and will mint it to any address we want. The token will be generated on Avalanche C-Chain and will be accessible on that chain. We are using Fuji Testnet in this tutorial.

The article focuses on deploying a smart contract written with Solidity to Avalanche. This is the feature that Avalanche provides us - to be able to deploy any smart contract to the chain and no requirement for a new language specific contract concept to interact. Let's look at how to create an ERC-20 contract and deploy it to avalanche C-Chain.

The first thing we should do is to enable Testnet mode on Core. To do that, go to Settings and click on Advanced.

Create an ERC-20 Token | Avalanche Docs (1)

Here, turn on the Testnet Mode feature. This will automatically make Core switch to Fuji Testnet.

Create an ERC-20 Token | Avalanche Docs (2)

Note

If you are using other wallets, like MetaMask, you can add the Fuji Testnet using the following specs:

The setup is done. For now, we have 0 AVAX.

Fund Your C-Chain Address

Avalanche has a Faucet that drips test tokens to the address of your choice. If you already have an AVAX balance greater than zero on Mainnet, paste your C-Chain address there, and request test tokens. Otherwise, please request a faucet coupon on Guild. Admins and mods on the official Discord can provide testnet AVAX if developers are unable to obtain it from the other two options.

Now, we can create our mintable token on Remix. Open Remix on your browser or go to this link.

Create an ERC-20 Token | Avalanche Docs (3)

You should view this page. On this page, first, click "SOLIDITY" from "Featured Plugins" and then click the "New File" button. When you click the New File button, you will see a pop-up that requires a file name. You can choose a name or leave the default.

Since we will use an ERC-20 contract from OpenZeppelin, just paste this line to the file and save.

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/presets/ERC20PresetMinterPauser.sol";

Create an ERC-20 Token | Avalanche Docs (4)

After saving the file, we will see a bunch of files that are imported to remix. This is a remix feature that allows us to import a GitHub contract repository to remix by just giving the URL-link with an import statement.

Create an ERC-20 Token | Avalanche Docs (5)

We have ERC20PresetMinterPauser.sol file in the presets. This file is written by OpenZeppelin according to ERC20 standards with minter functionality. After deploying this file, we will be the owner of the contract and thus have the authority and ability to mint the tokens.

Create an ERC-20 Token | Avalanche Docs (6)

Deploy the Contract

Open the tab with label Solidity compiler and select the solidity version that matches with the solidity version written in file as pragma solidity …... The version should be equal to or higher than the file's version. For example, in my file, pragma solidity ^0.6.0 is written so the required version is 0.6.0 or higher. As shown, in the compiler the solidity version is 0.6.6, which is OK. After checking the solidity version click the compile button. If you did not change anything in the file, or the solidity version is not wrong, the contract should compile without any errors.

Create an ERC-20 Token | Avalanche Docs (7)

Then, let's jump to the tab with label Deploy & run transactions. Here before deploying our contract, we should change the environment. Click to the environment and select "Injected Web3." If a pop-up shows up and asks you to connect the account, click to connect. After, you should see the account address in the "ACCOUNT" text box.

The last thing before the deployment process is to set the contract that will be deployed as a token. Above the Deploy Button, there is a drop-down menu to select a contract. Select the contract named ERC20PresetMinterPauser.sol.

Create an ERC-20 Token | Avalanche Docs (8)

Now, here enter the name and symbol of your token. I will name it "test" and the symbol will be tst. You can give it a and click to transact button.

Create an ERC-20 Token | Avalanche Docs (9)

After clicking the button, a pop-up will show up and just confirm it.

Create an ERC-20 Token | Avalanche Docs (10)

And then another pop-up, a Core confirmation, appears. Confirm it.

After confirming all these pop-ups we have deployed our token to avalanche C-Chain. So we can start to interact with it.

We can see our transaction that deployed on avalanche C-Chain via this c-chain explorer.

But firstly, let's see our transaction hash from the remix console.

Create an ERC-20 Token | Avalanche Docs (11)

After deploying the contract, we should see a log in remix console. When you click to arrow and expand it, a transaction hash will come up. Copy it.

Create an ERC-20 Token | Avalanche Docs (12)

Just paste the transaction hash to the explorer I shared above and press enter.

Create an ERC-20 Token | Avalanche Docs (13)

Here we can see all details about the transaction and token contract.

Create an ERC-20 Token | Avalanche Docs (14)

The first one is my wallet address that creates token and the second address is my token contract address which is named test. Now, let's mint some token to our own address.

Create an ERC-20 Token | Avalanche Docs (15)

Come back to the remix and after deploying, you should be able to see the contract in "Deployed Contracts" section.

Here, we have a bunch of functions that we can use to interact with our token contract. You can check all these methods from OpenZeppelin documentation to learn how to use them. But we will only use the mint method.

Click to arrow beside the mint method to read it.

Create an ERC-20 Token | Avalanche Docs (16)

Enter your address and an amount in wei. For example, I will mint 1000 tst token so, I entered "1000000000000000000000"

Add Token to Core Wallet

Now we minted 1000 token to our contract, but you should not be able to see the tokens in your Core wallet. In order to see our own token, we have to add it. On Core, click on the Avalanche C-Chain, and then select Manage:

Create an ERC-20 Token | Avalanche Docs (17)

Create an ERC-20 Token | Avalanche Docs (18)

Click on Add custom token. Here,enter the token address that you can see from the explorer, as showed above. Copy and paste it here. Then click on the Add token button, you should see 1000 token that you named in your Core wallet. Also, you can send it to another account via either remix or Core.

Create an ERC-20 Token | Avalanche Docs (19)

Create an ERC-20 Token | Avalanche Docs (2024)
Top Articles
How to Choose a Credit Card
What is a rootkit? Detection + prevention tips - Norton
Centricity Kp Schedule
Preggophili
Classical Star Massage
Dass Slumber Party Pt1
Davis.k12.Ut.us
Lesson 1 Homework 5.5 Answer Key
How much does it cost to sell your Bitcoin?
Molly-Mae Hague splits from Tommy Fury after five years together
Kltv Weather Report
Https://Cbdwarehousestore.com/Product-Category/Liquid-Herbal-Incense/
Serenity Nail Salon Brentwood Tn
Pokemon Radical Red Move Tutor
Can Kool Aid Powder Go Bad
Mujeres Prepago Puerto Rico
Daily Press Escanaba Mi Obituaries
Grace Kinstler Bathing Suit
Christwill Christian Music
Wlfi Delays
Ael Collegiate Essay Contest
Kentucky Lottery Remaining Prizes
Lol Shot Io Unblocked
Hardage Giddens Chapel Hills Obituaries
Dtm Urban Dictionary
Sams La Habra Gas Price
Ruth 1 Esv
Flixtor Nu Not Working
Craiglist Eastbay
Dmitri Wartranslated
Wednesday Morning Gifs
D&O-Versicherung für Manager & Geschäftsführer
Truist Cash Reserve: Line of Credit | Truist
Where Is The Purser In 2K22
20-pin J-Link Connector - SEGGER Wiki
Gypsy Rose Blanchard's Mother's Brutal Crime Scene Photos Go Viral On Her 33rd Birthday
Akali Op Gg Aram
Ron Marhofer Hyundai Of Green Photos
Philip Markoff - Parents, Death & Facts
Coors Field Seats In The Shade
Sierra At Tahoe Season Pass Costco
Troll Hunter Wiki
Slmd Skincare Appointment
Gluten Ease Walgreens
Copypasta Discord
Indiana Wesleyan Transcripts
1977 Elo Hit Wsj Crossword
238 Grams Equals How Many Cups
Cbx Promo Codes 2023
Weather Spooner Wi Radar
Newjetnet Aa.com
Latest Posts
Article information

Author: Saturnina Altenwerth DVM

Last Updated:

Views: 6021

Rating: 4.3 / 5 (44 voted)

Reviews: 91% of readers found this page helpful

Author information

Name: Saturnina Altenwerth DVM

Birthday: 1992-08-21

Address: Apt. 237 662 Haag Mills, East Verenaport, MO 57071-5493

Phone: +331850833384

Job: District Real-Estate Architect

Hobby: Skateboarding, Taxidermy, Air sports, Painting, Knife making, Letterboxing, Inline skating

Introduction: My name is Saturnina Altenwerth DVM, I am a witty, perfect, combative, beautiful, determined, fancy, determined person who loves writing and wants to share my knowledge and understanding with you.