Truffle box configured to create an ERC20 token using Open Zeppelin smart contracts library and deploy on Görli or Kovan Ethereum testnet network.
- English: Using Truffle Sol token box
- Español: Usando Truffle Sol token box
- Português: Usando Truffle Sol token box
There are a few technical requirements before we start.
To use Truffle boxes
, you need to have installed in your computer:
- Git
- a POSIX compliant shell
- cURL
- Node.js and NPM
- a code editor
Truffle framework
Once you have those requirements installed, you only need one command to install Truffle
.
It is better to do it globally:
npm install -g truffle
- Create a new folder.
For example, create the folder
mytoken
. Navigate to the folder in the terminal.
mkdir mytoken
cd mytoken
- Run the unbox command. This also takes care of installing the necessary dependencies and it can take some time.
truffle unbox solangegueiros/eth-token-box
Compile the smart contract.
truffle compile
This Truffle box also comes with the file TestToken.js
which include some examples for testing the smart contract.
You can check it out in the test
folder.
There are many other tests which can be done to check an ERC20 token.
Run this command on terminal:
truffle test
Before you deploy on a network, you need:
- A wallet with enought ETH to deploy
- An account at infura
- Create a wallet
The easy way to setup an account is using a web3 wallet injected in the browser
Copy your mnemonic (seed phrase or backup words)
- Create an account at infura
- Create a project, selecting
Ethereum network
. - Copy the project ID
- Create a project, selecting
Make a copy of .env.example
and named .env
, located in the folder project.
Update your MNEMONIC and RPC_URL in .env
Save .env
file.
Select the Goerli Network in the web wallet.
- Get some ETHs - Faucets
Run the Truffle development console
truffle console --network goerli
Run this commands in the Truffle console:
Shows the last block number.
(await web3.eth.getBlockNumber()).toString()
To get the network ID, run this command:
(await web3.eth.net.getId()).toString()
The Görli network ID is 5.
Exit the Truffle console:
.exit
truffle migrate --network goerli
The migrate process in a real blockchain takes more time, because Truffle creates some transactions which need to be mined on the blockchain.