LogoLogo
  • Gather Fundamentals
    • INTRODUCTION TO GATHER
    • GTH
    • TOKEN STANDARDS
      • CREATE YOUR FIRST GRC-20 TOKEN
      • CREATE YOUR FIRST GRC-721 TOKEN
    • NETWORKS
    • CONSENSUS
      • PROOF-OF-WORK (POW) & GTHASH
    • BLOCK EXPLORER
    • BRIDGE
    • MULTI-SEND
  • GATHER DEVELOPEMENT STACK
    • WALLET SETUPS
      • GATHER WEB WALLET
      • METAMASK MAINNET CONFIGURATION
      • METAMASK TESTNET CONFIGURATION
    • SMART CONTRACTS & DAPPs
      • DEPLOYING YOUR FIRST SMART CONTRACT
      • HARDHAT CONFIGURATION AND DEPLOYMENT
      • TRUFFLE CONFIGURATION AND DEPLOYMENT
      • BUILDING AN ESCROW SMART CONTRACT
      • BUILDING AN E-COMMERCE SHOPPING SMART CONTRACT
      • DEPLOYING NFT MARKETPLACE DAPP
      • DEPLOYING DE-FI BANK DAPP
      • DEPLOYING DECENTRALIZED TWITTER
    • TESTNET FAUCET
    • COVALENT
    • THIRDWEB
    • VERIFY SMART CONTRACTS
      • VERIFY CONTRACTS ON SOURCIFY VIA REMIX IDE
      • VERIFY CONTRACTS USING HARDHAT
Powered by GitBook
On this page
  • Prerequisites
  • STEPS
  • VIDEO
  1. Gather Fundamentals
  2. TOKEN STANDARDS

CREATE YOUR FIRST GRC-20 TOKEN

PreviousTOKEN STANDARDSNextCREATE YOUR FIRST GRC-721 TOKEN

Last updated 2 years ago

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.

  2. In contracts create a new file token.sol and add the following code there. You can get the code from here as well -

    // 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 .

VIDEO

https://remix.ethereum.org/
https://github.com/GatherNetwork/GRC-20-Token.git
gather testnet block explorer