/create-your-coin

Create your own ERC20 ;)

Primary LanguageJavaScriptMIT LicenseMIT

Create your own coin (ERC20)

  • This is a basic project to explain how to deploy and transfer your own coin
  • This project is used to demonstrate in practice how to use a blockchain, with the following steps
    • Update the contract contracts/MyErc20Token
    • Deploy this contract
    • Check the contract in blockchain explorer
    • Execute transactions in the contract through scripts and metamask
  • For portugues, take a look at the file README.brl.md instructions

Requirements

  • There are some required programs

  • Node v16.9.1

    • If you use Linux, just type the following command line in console to install node
    $~ curl -fsSL https://deb.nodesource.com/setup_16.x | sudo -E bash -
    $~ sudo apt install nodejs
  • npm v7.21.1

  • git

  • Chrome

To check the installed versions, use node -v ; npm -v

Metamask

  • Open any browser compatible with chrome extensions (Chrome, Brave)
  • Install metamask
  • Create your wallet

Clone the repository

  • Do the git clone
$~ git clone https://github.com/RafilxTenfen/create-your-coin.git
  • Enter directory
$~ cd create-your-coin/

Environment variables

  • To carry out all the steps of this project, some environment variables are needed.
  • Start by copying the file .env.example to .env
## Unix
$~ cp .env.example .env
## Windows
$~ copy .env.example .env

ETHERSCAN_API_KEY

  • This environment variable is used to check contracts through hardhat package scripts
  • To acquire the environment variable ETHERSCAN_API_KEY
  • Access etherscan
  • Register and/or login
  • After entering, click on API-KEYs
  • Add a new key by clicking the add button addKey
  • Copy the created key and replace it in the copied file .env in the key ETHERSCAN_API_KEY

GOERLI_URL

  • This environment variable is used to connect to a node of the Ethereum test blockchain network, called Goerli and so be able to send transactions through these nodes
  • Let's use Infura
  • Perform the login
  • Click in ETHEREUM image
  • Click on the first project if you have it, if not click on CREATE NEW PROJECT image
  • Click in SETTINGS
  • Select Goerli in the field ENDPOINTS
  • Copy the Goerli URL HTTPS image
  • Replace in file .env the key GOERLI_URL

PRIVATE_KEY

  • The environment variable PRIVATE_KEY is your wallet's private key, which is used to sign your transactions on the blockchain
  • Go to the metamask extension

It is not necessary to select the Goerli network

  • Click in the ellipsis("...") image
  • Click in Account Details
  • Click in Export Private Key image
  • Type your password
  • Copy your private key
  • Replace in file .env the key PRIVATE_KEY
  • To be able to carry out transactions it is necessary to pay fees on the blockchain network
  • In the main chain it is certainly expensive to carry out transactions
  • On the goerli test network you can purchase for free to perform xD tests
  • In test networks, the funds are called faucet, in the case of the goerli's network click here
  • Copy your Metamask address image
  • Enter your network address (can be copied into metamask extension) Paste your address in the field and click on Send me test Ether image
  • Wait a few moments (about 2 minutes)
  • Select the Goerli network in your metamask extension image
  • Check your balance, it should be something around 0.3 Ether, which will be more than enough for our tests. image

Install the packages

  • We are going to use several packages, so run the following command to install
$~ npm install

Smartcontract

  • Go to the contracts/MyErc20Token.sol file on line 8 and enter in the first parameter the name of your currency, and in the second parameter the symbol of your currency

    • Use a maximum of 15 characters for the first parameter (currency name)
    • Use a maximum of 5 characters for the second parameter (currency symbol)
  • Compile the contract with the following command

$~ npm run compile
  • Deploy the contract
$~ npm run deploy
  • Check the contract
$~ npm run verify

Expected result image

Replace the address with your contract address

  • Copy your contract address and add your token to the Metamask extension
  • Open the metamask extension and click Import Token image
  • Paste your token address in Token Contract Address click Add Custom Token image
  • Then click import tokens
  • If everything is ok, the Metamask must complete the other fields

Frontend

  • Look at front-end/README.md