- 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
- Update the contract
- For portugues, take a look at the file
README.brl.md
instructions
-
There are some required programs
-
- 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
To check the installed versions, use
node -v ; npm -v
- Open any browser compatible with chrome extensions (Chrome, Brave)
- Install metamask
- Create your wallet
- Do the git clone
$~ git clone https://github.com/RafilxTenfen/create-your-coin.git
- Enter directory
$~ cd create-your-coin/
- 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
- 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
- Copy the created key and replace it in the copied file
.env
in the keyETHERSCAN_API_KEY
- 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
- Click on the first project if you have it, if not click on CREATE NEW PROJECT
- Click in SETTINGS
- Select Goerli in the field ENDPOINTS
- Copy the Goerli URL HTTPS
- Replace in file
.env
the keyGOERLI_URL
- 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("...")
- Click in Account Details
- Click in Export Private Key
- Type your password
- Copy your private key
- Replace in file
.env
the keyPRIVATE_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
- Enter your network address (can be copied into metamask extension) Paste your address in the field and click on
Send me test Ether
- Wait a few moments (about 2 minutes)
- Select the Goerli network in your metamask extension
- Check your balance, it should be something around
0.3 Ether
, which will be more than enough for our tests.
- We are going to use several packages, so run the following command to install
$~ npm install
-
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
- You can access and verify your contract in goerli explorer
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
- Paste your token address in Token Contract Address click Add Custom Token
- Then click import tokens
- If everything is ok, the Metamask must complete the other fields
- Look at
front-end/README.md