DEFI RECRUITMENT TASK
Build Your Own Token Using ERC-20 Tokens
This step-by-step tutorial will guide you through creating and deploying an ERC-20 token on
Ethereum to build your own cryptocurrency. The process uses MetaMask and Remix
IDE.
What is ERC-20?
ERC stands for Ethereum Request for Comment. These are standards approved by the
Ethereum community, used to convey technical requirements and specifications for
various use cases.
● ERC-20 is the standard for fungible* tokens (all parts are the same, e.g., 1 ETH is
always equal to another 1 ETH).
● Most tokens on Ethereum comply with the ERC-20 specification, enabling seamless
integration with applications and exchanges.
● Fungible tokens: All units are interchangeable (like ETH or fiat currencies).
● Non-Fungible Tokens (NFTs): Each token is unique.
*Fungible: (literal meaning from google) of a product or commodity, replaceable by
another identical item; mutually interchangeable.
Example: Think of a ₹5 coin. You can exchange it with another ₹5 coin anywhere in
India, and it will still hold the same value — no one cares which ₹5 coin you have. This is
because money is fungible — every unit is interchangeable with another of the same
kind and value.
Now compare that to a painting. Even if two paintings look similar or are the same size,
they might have very different values based on the artist, condition, or personal taste.
You can’t just swap one painting for another or say it’s exactly worth ₹5 — its value is
subjective and hence, non-fungible.
Prerequisites
Before you start, ensure you have:
● Downloaded and installed MetaMask.
● Switched MetaMask to the Sepolia Testnet network.
● Requested some Sepolia Testnet ETH from a faucet (search for "Ethereum Sepolia
Faucet" to get free test ETH).
// The above are covered in blockbase Day 2
Writing the Code
We'll use Remix IDE for writing the smart contract.
1. Create a new contract file (e.g., [Link]).
2. Add the following code:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
import
"[Link]
er/contracts/token/ERC20/[Link]";
contract MyToken is ERC20 {
constructor(string memory _tknname, string memory _tknsymbol)
ERC20(_tknname, _tknsymbol) {
_mint([Link], 10 * 10 ** 18);
} // comment your name and roll number to confirm original work
Code Breakdown
● pragma solidity ^0.8.19;
Specifies the Solidity compiler version.
● import ...[Link];
Imports the ERC-20 token standard from OpenZeppelin, a reputable source of secure
smart contract templates.
● contract MyToken is ERC20 { ... }
Defines a new contract that extends the ERC20 standard, inheriting all its logic.
● constructor(string memory _name, string memory _symbol) ...
The constructor takes the token name and symbol as arguments and initializes the
ERC20 contract.
● _mint([Link], 10 * 10 ** 18);
Mints 10 tokens (with 18 decimals) to the deployer's address.
Note:
Solidity does not support floating point numbers. ERC20 tokens use 18 decimal
places by default, so 1 token is represented as 1 * 10^18.
Compiling the Contract
● Compile your contract in Remix by saving the file or using the Compiler tab.
● Select the correct Solidity version if prompted.
Deploying the Contract
1. Go to the Deploy and Run Transactions tab in Remix.
2. Select the Injected Provider - MetaMask environment (ensure you are on the Sepolia
Test Network).
3. Connect your MetaMask wallet.
4. Select your contract and enter values for the constructor arguments (_name and
_symbol). // covered in the solidity fundamentals of day 3
5. Click Transact and approve the transaction in MetaMask.
After deployment:
● The contract will appear under Deployed Contracts.
● Copy the contract address.
● You can view your contract on Sepolia Etherscan by searching for the contract address.
Viewing Tokens in MetaMask
If your tokens don't appear in MetaMask automatically:
1. Copy your contract address.
2. Open MetaMask and click Import Tokens in the Assets tab.
3. Paste your Token Contract Address. MetaMask should detect the token name and
decimals automatically.
4. Click Add to see your balance.
Submission
Submit the screenshot of your deployed token on metamask and the contract address of
the token. You can give it any name of your choice.
Example:
Contract Address : 0xEFaA289000dC4217f7E6993232CD35E2FA1AA84f (for FEC token)
PS: you can import fec tokens too !!