Truffle
Last updated
Last updated
is a blockchain development environment, which you can use to create and test smart contracts by leveraging the Ethereum Virtual Machine. This guide aims at teaching how to create a smart contract using Truffle and deploying it on the EVM-compatible Gauss Induction Labs Testnet.
Install and set up Truffle
Deploy contract on G.I.L. Testnet
Check the deployment status on the G.I.L. Explorer
There are a few technical requirements before we start. Please install the following:
(packaged with Node)
Once we have those installed, we only need one command to install Truffle:
To verify that Truffle is installed properly, type truffle version
on a terminal. If you see an error, make sure that the npm modules are added to your path.
Start by creating a new directory for this Truffle project:
Download the MetaCoin box:
With that last step, you have created a Truffle project cointaining folders with contracts, deployment, testing, and configuration files.
This is the smart contract data from the metacoin.sol
file:
You can run Solidity and JavaScript tests.
In a terminal, run the Solidity test:
Run the JavaScript test:
Compile the smart contract using the following command:
Before actually depolying the contract, you need to set up the truffle-config.js
file, inserting network and compilers data.
Go to truffle-config.js
and update the file with Polygon Mumbai network details.
Note that it requires mnemonic to be passed in for provider
. This is the seed phrase (or private key) for the account you would like to deploy from. Create a new .secret
file in the root directory and enter your 12-word mnemonic seed phrase to get started. To get the seed words from MetaMask wallet, you can go to MetaMask settings, then from the menu, choose Security and Privacy where you will see a button that says reveal seed words.
We will use one of Truffle's boilerplates which you can find on their page. creates a token that can be transferred between accounts.
Add test GANG to your wallet using . Next, run this command in the root folder of the project directory:
Congratulations! You have successfully deployed a Smart Contract using Truffle. Now you can interact with the contract and also check its deployment status on the .