Using Truffle

Setting up the development environment

Requirements

There are a few technical requirements before we start. Please install the following: Requirements:

Recommendations for Windows

If you're running Truffle on Windows, you may encounter some naming conflicts that could prevent Truffle from executing properly. Please see the section on resolving naming conflicts for solutions.

Installing Truffle

Once we have those installed, we only need one command to install Truffle:

npm install -g truffle

To verify that Truffle is installed properly, type truffle version on a terminal. If you see an error, make sure that your npm modules are added to your path.

Project Creation, Compilation, and Configuration

The first step is to create a Truffle project. We'll use the *MegaCoin as an example, which creates a token that can be transferred between accounts:

Create a new directory for your Truffle project

Intialize your project:

To initialize your project use the following command

Once this operation is completed, you'll now have a project structure with the following items:

  • contracts/: Directory for Solidity contracts

  • migrations/: Directory for scriptable deployment files

  • test/: Directory for test files for testing your application and contracts

  • truffle-config.js: Truffle configuration file

Create Contract

You can write your own smart contract or download the ERC20 token smart contract template.

Compile Contract

To compile a Truffle project, change to the root of the directory where the project is located and then type the following into a terminal:

Config Truffle for (Agora)BizNet

  • Go to truffle-config.js

    • Update the truffle-config

Notice, it requires a mnemonic to be passed in for Provider, this is the seed phrase for the account you'd 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.

Deploying on Agora(BizNet) Network

Run this command the root of the project directory:

A contract will be deployed on Agora(BizNet) Testnet, it looks like this:

Remember your address, transaction_hash and other details provided would differ, Above is just to provide an idea of structure.

Congratulations! You have successfully deployed ERC20 Smart Contract. Now you can interact with the Smart Contract.

You can check the deployment status here: https://scan.bosagora.org or https://testnet-scan.bosagora.org

Last updated