Book Image

Truffle Quick Start Guide

By : Nikhil Bhaskar
Book Image

Truffle Quick Start Guide

By: Nikhil Bhaskar

Overview of this book

Truffle is a world-class development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. If you are a web developer wanting to try your hand at developing Dapps with Truffle, then this is the book for you. This book will teach you to write smart contracts and build Dapps with Truffle. You will begin with covering the basics of Truffle, briefly explaining how it integrates Solidity and Web3, in orderto start building a mini decentralized application. Also, you will dive into migration, testing and integrating Truffle with the use of popular JavaScript frameworks. Lastly, you will ship your decentralized application and package it into a product. Moreover, you will go through the best practices in Truffle,so as to increase your proficiency in building Dapps with Truffle. By the end of the book, you will be able to write smart contracts and build decentralized applications with Truffle on Ethereum blockchains.
Table of Contents (9 chapters)

Web3 in Truffle

Now that we have a clear understanding of web3 in an isolated environment, it's time to get out of our comfort zone and see how it interacts with Truffle. We've already seen a bit of this in Chapter 1, Truffle for Decentralized Applications.



Let's refer back to our app.js file under chapter1/app/javascripts/ (https://github.com/PacktPublishing/Truffle-Quick-Start-Guide/blob/master/chapter1/app/javascripts/app.js).

Let's see how we import web3:

import { default as Web3} from 'web3';

Now, let's see how we set the blockchain network provider for web3:

window.web3 = new Web3(new Web3.providers.HttpProvider("http://127.0.0.1:9545"));

Remember how we simply glossed over this in Chapter 1, Truffle for Decentralized Applications? Hopefully, you now have a better understanding of what's going on here. Since we don&apos...