Basic Truffle Framework Deploy Smart Contract

Truffle is a development framework for Ethereum. It is written in JavaScript in a completely modular, allowing you to pick and choose the functionality you’d like to use. For example, you can use Truffle as a library in your own tool, using only the modules that you need. You can imagine it just like an IDE, provide you an environment to develop Ethereum Dapp in your computer. Good News, you don’t need to use Remix to deploy smart contract, you can use truffle !!! In this tutorial, I will provide some guidance on using truffle framework deploy smart contract.

Install Truffle Via NPM

Open the terminal or command line and enter the following command to install truffle.

After that create a new folder call “truffle_basic_dapp”.

Then initialize Truffle framework in your project so you can use it.

Start Project

Open your editor and open your project folder “truffle_basic_dapp”. You will see there have folder and files downloaded by truffle init.

Create a new contract

Add a new file name “SimpleStorage.sol” in the contract folder, and this will try to store value and retrieve from the contract.

Create Javascript file

Add a new migration file “2_deploy_contracts.js” in the migration folder, and copy the code below.

Edit Truffle.js

Modify truffle.js in the project folder and it will connect the local blockchain on your computer via 127.0.01 and port 7545.

Start your Ganache

Open your ganache to proceed, so you able to connect it to the truffle environment.

Compile Source Code

Connect it to your Ganache

Deploy to the Ganache Blockchain

Test the functions

To get the storage value.

To set the storage value.

Basic Truffle Framework Deploy Smart Contract

Source Code

(Visited 77 times, 1 visits today)
Advertisements

Kristofer Ng

A crazy android and web developer. Passion on developing android application and exploring new technology as a hobby.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *

GET YOUR EBOOK FOR FREE

Unlock free ebook "Beginning Programming ALL-IN-ONE Desk Reference for DUMMIES" now!

We will send a copy to your email