Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Ethereum Cookbook
  • Table Of Contents Toc
  • Feedback & Rating feedback
Ethereum Cookbook

Ethereum Cookbook

By : Manoj P R
close
close
Ethereum Cookbook

Ethereum Cookbook

By: Manoj P R

Overview of this book

Ethereum and Blockchain will change the way software is built for business transactions. Most industries have been looking to leverage these new technologies to gain efficiencies and create new business models and opportunities. The Ethereum Cookbook covers various solutions such as setting up Ethereum, writing smart contracts, and creating tokens, among others. You’ll learn about the security vulnerabilities, along with other protocols of Ethereum. Once you have understood the basics, you’ll move on to exploring various design decisions and tips to make your application scalable and secure. In addition to this, you’ll work with various Ethereum packages such as Truffle, Web3, and Ganache. By the end of this book, you’ll have comprehensively grasped the Ethereum principles and ecosystem.
Table of Contents (13 chapters)
close
close

Creating a blockchain network for development

You don't always have to create a fully functioning node to support your development. There are development networks that can simulate an Ethereum network. In this recipe, you will learn about ganache-cli (previously TestRPC), which is part of the Truffle suit of Ethereum development tools and is a command-line tool that you can use to create your personal blockchain network for Ethereum development.

Getting ready

Since the tool is written in JavaScript and distributed via npm, you will need Node.js (>= v6.11.5) installed on your machine to try this recipe.

How to do it...

Follow these steps to install and create a test Ethereum network using npm:

  1. Install ganache-cli using npm:
npm install -g ganache-cli
  1. Starting a basic blockchain network is as simple as running this command:
ganache-cli

You will know that your blockchain is ready when you see this screen:

Ganache creates a virtual Ethereum blockchain, and it generates some sample accounts for you to use during development. Each account is filled in 100 Ether so that you only have to focus on development. You can access the network from http://localhost:8545.

  1. You can use a few parameters to customize the blockchain. Here's one such example:
ganache-cli -a 5 -e 2000 -p 8080 -l 999999
  • -a: Number of accounts to generate while starting the network. The default is 10.
  • -e: Amount of Ether to allocate for each account. The default is 100 Ether.
  • -p: Port number for listening to RPC requests. The default is 8,545.
  • -l: Gas limit for each block. The default is 90,000.

You can find the complete list of parameters to configure here:

https://github.com/trufflesuite/ganache-cli.

By default, accounts are unlocked and you can do the transaction from any account without a password. You can change this by using the --secure or -n flag. This will lock all accounts by default and you need to unlock each one to send a transaction.

There's more...

There is a GUI for ganache that offers an easy-to-use interface for creating Ethereum networks. It even offers an intuitive User Interface (UI) for browsing blocks and transactions.

You can download and install the ganache GUI from http://truffleframework.com/ganache/.

Visually different images
CONTINUE READING
83
Tech Concepts
36
Programming languages
73
Tech Tools
Icon Unlimited access to the largest independent learning library in tech of over 8,000 expert-authored tech books and videos.
Icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Icon 50+ new titles added per month and exclusive early access to books as they are being written.
Ethereum Cookbook
notes
bookmark Notes and Bookmarks search Search in title playlist Add to playlist download Download options font-size Font size

Change the font size

margin-width Margin width

Change margin width

day-mode Day/Sepia/Night Modes

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY

Submit Your Feedback

Modal Close icon
Modal Close icon
Modal Close icon