CREATE YOUR FIRST GRC-20 TOKEN

The body of a GRC-20 token contains the methods and events a GRC-20 token must have.

A GRC-20 token must be able to:

  • Transfer tokens from one account to another

  • Return the balance of an account

  • Return the total tokens available in the token

  • Transfer tokens to an account

This is an example of how to create and deploy a simple GRC-20 token on the Gather testnet. You can follow the same steps for the mainnet after changing the configuration from testnet to mainnet.

Prerequisites

  1. Metamask or any web3 wallet configured with Gather testnet.

  2. Testnet GTHs.

For this guide, we will be using remix as IDE and MetaMask as our wallet.

STEPS

  1. Open Remix online compiler. https://remix.ethereum.org/

  2. In contracts create a new file token.sol and add the following code there. You can get the code from here as well - https://github.com/GatherNetwork/GRC-20-Token.git

    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.3;
    
    import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
    import "@openzeppelin/contracts/access/Ownable.sol";
    
    contract Token is ERC20, Ownable {
        constructor(string memory _name, string memory _symbol, uint256 _initialSupply) payable ERC20(_name, _symbol) {
            _mint(msg.sender, _initialSupply);
        }
    
        function mint(uint256 amount) public onlyOwner {
            _mint(msg.sender, amount);
        }
    } 
  3. Compile token.sol

  4. Switch to Gather Testnet Network in your MetaMask.

  5. In environments of Remix, select injected web3 and connect an account with enough testnet GTHs.

  6. Fill in the details for the deployment section and deploy your contract.

    Please note that the unit provided for the field initial supply is in WEI.

    Eg: For creating 1,000 tokens, for the initial supply you need to enter

    1,000 * 1,000,000,000,000,000,000 = 1,000,000,000,000,000,000,000

    In this case, the total number of DEM tokens minted will be 1000000000000 * 1e-18.

  7. This will open your MetaMask extension and ask you to confirm the pending transaction. Click the Confirm button on the MetaMask popup.

  8. You have successfully created and deployed a GRC-20 token on the Gather test network. You check your contract details on the gather testnet block explorer.

VIDEO

Last updated