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)

Common migration pitfalls

A common mistake is to have a misconfigured truffle.js file. Ensure that for each network you plan to deploy to, there should be a corresponding entry in the networks object, stating the following information:

networks: {
network_name: {
network_id: <number>
host: <string>,
port: <number>,
gas: <number>
}
}

How do we know what is the correct gas limit? Well, you have to play with this a little.

Every transaction you make has a gas cost. A migration is a transaction, too, and thus has a gas cost. When attemmpting to migrate your contract, you may run into this error:

exceeds block gas limit

Every transaction you send has a gas limit. Try to decrease the amount of gas specified.

Another error you may encounter is the following:

insufficient funds for gas * price + value

This means the total cost of the transaction exceeds...