Categories: Blockchain

How to Create an ERC20 Token for FREE?

In the crypto world all you need is an idea and a coin. Okay, now you
have your unique idea but how do you create a coin and start raising 
fundings for the project through ICO or STO? The simplest way is to 
create an Ethereum based ERC20 token which is hosted on the Ethereum
Blockchain. 

Note – You will not need technical knowledge to Create an ERC20 Token for FREE as this tutorial will be a step by step method with screenshots.

Let’s get started! In this tutorial, we will be creating an ERC20 Token for free on the Ethereum Blockchain. As this is test, we will be using the Ropsten network.

Requirements for creating an ERC20 Token for Free

  1. Chrome browser with Meta Mask wallet plugin installed.
  2. A small amount of ETH – Ethereum balance which is required to pay gas fee to facilitate contract submission on ETH network

Token Details Required

  1. Symbol of the Token
  2. Name of the Token
  3. Master owner Wallet Address
  4. Decimal
  5. Total Supply

Decimal – Is the no.of decimal places upto which you want your token to support.

Total Supply – Total no.of Token liquidity you wish to create.

Step 1: Remix IDE Setup

Assuming you have already setup your meta mask wallet. We are directly getting inside the token creation.

Goto the online Ethereum IDE – https://remix.ethereum.org

This online IDE is used for solidity programming and used to deploy smart contracts on the Ethereum Blockchain.

Step 2: Smart Contract Creation

Delete the pre created default files in remix.ethereum.org. Right click on the files and you will see the Delete option.

Then create a new file by clicking the “+” icon on the left menu to create a new file. You will see a popup to enter the file name. Give the same of your token and click save. Make sure you have the .sol extension at the last.

Copy paste the below code in the newly created .sol file in remix IDE:

pragma solidity ^0.4.18;

// ----------------------------------------------------------------------------
// 'YE' token contract
//
// Deployed to : 0x8607112Cd79a57b0d3152cd025bcbe72e737154e
// Symbol      : YE
// Name        : Yokesh Explains
// Total supply: 1000000000
// Decimals    : 18
//
//
//
// ----------------------------------------------------------------------------


// ----------------------------------------------------------------------------
// Safe maths
// ----------------------------------------------------------------------------
contract SafeMath {
    function safeAdd(uint a, uint b) public pure returns (uint c) {
        c = a + b;
        require(c >= a);
    }
    function safeSub(uint a, uint b) public pure returns (uint c) {
        require(b <= a);
        c = a - b;
    }
    function safeMul(uint a, uint b) public pure returns (uint c) {
        c = a * b;
        require(a == 0 || c / a == b);
    }
    function safeDiv(uint a, uint b) public pure returns (uint c) {
        require(b > 0);
        c = a / b;
    }
}


// ----------------------------------------------------------------------------
// ERC Token Standard #20 Interface
// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
// ----------------------------------------------------------------------------
contract ERC20Interface {
    function totalSupply() public constant returns (uint);
    function balanceOf(address tokenOwner) public constant returns (uint balance);
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining);
    function transfer(address to, uint tokens) public returns (bool success);
    function approve(address spender, uint tokens) public returns (bool success);
    function transferFrom(address from, address to, uint tokens) public returns (bool success);

    event Transfer(address indexed from, address indexed to, uint tokens);
    event Approval(address indexed tokenOwner, address indexed spender, uint tokens);
}


// ----------------------------------------------------------------------------
// Contract function to receive approval and execute function in one call
//
// Borrowed from MiniMeToken
// ----------------------------------------------------------------------------
contract ApproveAndCallFallBack {
    function receiveApproval(address from, uint256 tokens, address token, bytes data) public;
}


// ----------------------------------------------------------------------------
// Owned contract
// ----------------------------------------------------------------------------
contract Owned {
    address public owner;
    address public newOwner;

    event OwnershipTransferred(address indexed _from, address indexed _to);

    function Constructor() public {
        owner = msg.sender;
    }

    modifier onlyOwner {
        require(msg.sender == owner);
        _;
    }

    function transferOwnership(address _newOwner) public onlyOwner {
        newOwner = _newOwner;
    }
    function acceptOwnership() public {
        require(msg.sender == newOwner);
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
        newOwner = address(0);
    }
}


// ----------------------------------------------------------------------------
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract YokeshExplains is ERC20Interface, Owned, SafeMath {
    string public symbol;
    string public  name;
    uint8 public decimals;
    uint public _totalSupply;

    mapping(address => uint) balances;
    mapping(address => mapping(address => uint)) allowed;


    // ------------------------------------------------------------------------
    // Constructor
    // ------------------------------------------------------------------------
    function Constructor() public {
        symbol = "YE";
        name = "YokeshExplains";
        decimals = 18;
        _totalSupply = 1000000000;
        balances[0x8607112Cd79a57b0d3152cd025bcbe72e737154e] = _totalSupply;
        emit Transfer(address(0), 0x8607112Cd79a57b0d3152cd025bcbe72e737154e, _totalSupply);
    }


    // ------------------------------------------------------------------------
    // Total supply
    // ------------------------------------------------------------------------
    function totalSupply() public constant returns (uint) {
        return _totalSupply  - balances[address(0)];
    }


    // ------------------------------------------------------------------------
    // Get the token balance for account tokenOwner
    // ------------------------------------------------------------------------
    function balanceOf(address tokenOwner) public constant returns (uint balance) {
        return balances[tokenOwner];
    }


    // ------------------------------------------------------------------------
    // Transfer the balance from token owner's account to to account
    // - Owner's account must have sufficient balance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transfer(address to, uint tokens) public returns (bool success) {
        balances[msg.sender] = safeSub(balances[msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(msg.sender, to, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Token owner can approve for spender to transferFrom(...) tokens
    // from the token owner's account
    //
    // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md
    // recommends that there are no checks for the approval double-spend attack
    // as this should be implemented in user interfaces 
    // ------------------------------------------------------------------------
    function approve(address spender, uint tokens) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Transfer tokens from the from account to the to account
    // 
    // The calling account must already have sufficient tokens approve(...)-d
    // for spending from the from account and
    // - From account must have sufficient balance to transfer
    // - Spender must have sufficient allowance to transfer
    // - 0 value transfers are allowed
    // ------------------------------------------------------------------------
    function transferFrom(address from, address to, uint tokens) public returns (bool success) {
        balances[from] = safeSub(balances[from], tokens);
        allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens);
        balances[to] = safeAdd(balances[to], tokens);
        emit Transfer(from, to, tokens);
        return true;
    }


    // ------------------------------------------------------------------------
    // Returns the amount of tokens approved by the owner that can be
    // transferred to the spender's account
    // ------------------------------------------------------------------------
    function allowance(address tokenOwner, address spender) public constant returns (uint remaining) {
        return allowed[tokenOwner][spender];
    }


    // ------------------------------------------------------------------------
    // Token owner can approve for spender to transferFrom(...) tokens
    // from the token owner's account. The spender contract function
    // receiveApproval(...) is then executed
    // ------------------------------------------------------------------------
    function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) {
        allowed[msg.sender][spender] = tokens;
        emit Approval(msg.sender, spender, tokens);
        ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data);
        return true;
    }


    // ------------------------------------------------------------------------
    // Don't accept ETH
    // ------------------------------------------------------------------------
    function () public payable {
        revert();
    }


    // ------------------------------------------------------------------------
    // Owner can transfer out any accidentally sent ERC20 tokens
    // ------------------------------------------------------------------------
    function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) {
        return ERC20Interface(tokenAddress).transfer(owner, tokens);
    }
}

Step 3: Smart Contract Configuration

Do a bit serious note in this step. If any wrong configuration done, the contract will not execute.

  1. Changing the commented part of the contract

This part is just for reference of the contract. This information will be helpful when people view the contract code in the ethereum explorer – Etherscan.

Deployed address to is the address of your master wallet. Copy your meta mask ethereum address and paste.

2. Changing Contract Function Name

On Line no. 101, Change the contract function name to name of your contract. Make sure you don’t give spaces and make sure to use the same formatting everywhere.

3. Constructor Configuration

This is the core part of the smart contract configuration.

symbol = "Symbol of your contract";
name = "Name of your contract";
decimals = Decimal of your token;
_totalSupply = Total supply of your token;
balances[Your Ethereum Master wallet address] = _totalSupply;
emit Transfer(address(0), Your Ethereum Master wallet address, _totalSupply);

Once done, you are all set now for deployment on ethereum network.

Step 4: Deploying on Ethereum Blockchain

Deploying on Ethereum Main network – Make sure you have your meta mask wallet on Ethereum Main net.

Deploying on Test Ropsten network – Make sure you have your meta mask wallet on Ropsten network.

Make sure you have Connected Status in Green

  1. Click on compile contract from the left menu in remix IDE

once after successful compilation you will see a ✅ mark on the left. This shows us the contract is compiled successfully without errors. Incase if any errors faced, check closely the above steps or reduce the compiler versions.

2. Click on DEPLOY & RUN TRANSACTIONS – 3rd option in the remix IDE left menu

Choose your contract name from the contract selection dropdown.

Choose Environment -> Injected Web3

Click on Deploy button. You will see the Metamask Popup coming up. Click on Confirm Button

Click on the transaction URL created in the terminal.

Our YokeshExplains smart contract is deployed now – https://ropsten.etherscan.io/tx/0x54d5637566cbe9c80fe24051521b38a28b12558c318157d2b7dcc7a2b7aa7413

This is our contract Address – 0x8b20b4721f06E5F9FAc1D8988375a76Cc49655fa

Hurray! Now you have Create your ERC20 Token for FREE!

Step 5: Adding newly created token to Meta Mask Wallet

Click on Add Token in the Metamask wallet. And paste your token contract address.

The Token symbol should appear automatically. Click Next.

Once you see your token balance, Click on Add Tokens.

Your Token is now Ready! Start sending!

Step 6: Verify and Publish your Smart Contract

On the Contract Tab in etherscan you will find the option to verify and Publish your smart contract. Below that you will see a bulk of numeric junk. It is called the ByteCode. Copy it to clipboard.

On the next step select the below options and click continue.

Next copy paste the contract solidity code in the first box and contract ABI ByteCode in the second Box.

Finally your contract is Published and you have created an ERC20 Token for FREE

Thanks for reading. Leave down in comments if you face any issues. I can help you out on the process.

Get in touch with me if you need assistance on creating your own token.

NEXT: Read this article for step by step installation of Bitcoin Blockchain on Ubuntu server.

Yokesh Sankar

Technical Consultant - Blockchain Advisor - Project Manager

View Comments

  • Your tutorial is very well put together, thank you for posting it. I'm only having one problem... I can't see how you are getting it to create and transfer tokens into the "New Token" account. When I look at my Hash/ID, I do not have a line for "Tokens Transferred" like you show. And my balance ends up being zero tokens in the metamask pop up, while yours shows 200000 tokens. What am I missing? Is there a step left out somewhere?

    • Thanks Hawthorne.Are you saying in Metamask? Were you able to add your Token contract address in "Add Token" in metamask? (Not wallet address). Can you send me a screenshot with the problem which you are facing to yokeshexplains@gmail.com? Happy to help! :)

Recent Posts

Enhancing Supply Chain Management with Cross-Chain Communication: A Blockchain Revolution

Introduction In spite of the modernity advancements, supply chain control remains intricate but imperative in…

6 months ago

Ethereum EIP-4844 Explained

EIP-4844 suggests a new way to handle transactions on Ethereum so that it can scale…

6 months ago

7 Leading Real Estate Tokenization Development companies

The industry is experiencing a significant change as a result of the tokenization of real…

6 months ago

BRC20 Token Development: A Complete Guide

What is BRC20 Token? Domo, a confidential inventor, introduced BRC-20 tokens to the open on…

6 months ago

Zero-Knowledge Proof (ZKP) Technology: A Ultimate Guide

What is Zero-Knowledge Proof (ZKP-TECH) Confidence in zero knowledge proof is necessary between two individuals.…

7 months ago

Digital technologies for real estate Industry in 2024

By implementing over 1000 projects, software development became an expert field for Sparkout tech. We…

7 months ago