Book Image

Ethereum Cookbook

By : Manoj P R
Book Image

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)

Using Azure Ethereum as a service

Azure offers cloud solutions to deploy and configure Ethereum consortiums with a simple single-click deployment through the Azure portal. In this recipe, you will learn how to deploy a flexible Ethereum network, consisting of a set of load-balanced transaction nodes, with which an application or user can interact to submit transactions, and a set of mining nodes to record transactions.

Getting ready

You will need an Azure subscription to create an Ethereum consortium. Other dependencies will be configured by the provider itself.

How to do it...

Follow these steps to create an Ethereum POW blockchain in Azure:

  1. Log in to the Azure portal and click on Create a resource from the left navigation bar.
  1. Select Create Ethereum Proof-of-Work Consortium under Blockchain.

Once you click Create, you can see a five-step wizard that will guide you through the setup process. The first step will ask you to choose a username, password, subscription, location, and so on. Provide the appropriate values and click OK:

  1. Step 2 will ask you to configure the regions in which the nodes should be deployed. For a simple network, one region should be enough.
  2. Step 3 is all about configuring the number of nodes that should be dedicated to mining and transactions. Mining nodes do all the heavy lifting of creating blocks, and transaction nodes take care of broadcasting the transaction from your application. Choose the number of nodes for each category and their respective configuration to meet your needs.
  3. Step 4 focuses more on the parameters of blockchain that you are about to create. You can compare it with the genesis file you will create during private network configuration.
  1. Once you are finished on the Ethereum settings tab, you can choose the Operations Management Suite for your Azure resource. Create a new one if you are new to Azure and creating resources for the first time.
  2. If everything goes well, then the verification process in the Summary tab will be successful and you can proceed to purchase the service.
  3. Read through the Terms and Conditions and click Create. This will start deploying your resources and can take a few minutes to finish.
  4. Once the deployment is finished, you can see your resources in the resource group that you created/selected. Select your resource group from the Resource groups tab in the left navigation bar and Deployments.
  5. This will display the set of deployments that has been created as part of Ethereum consortium's deployment. Select the deployment name that starts with microsoft-azure-blockchain-ethereum:
  1. Select output from the window, and now you can see the access credentials for the resources that you created:

These are some of the credentials you can use in the Azure blockchain service:

  • ADMIN-SITE: Admin portal that you can use to view the current node status and send Ether to newly created accounts
  • OMS-PORTAL-URL: Azure Operations Management Portal for your resources
  • ETHEREUM-RPC-ENDPOINT: Ethereum RPC port for you to interact with the blockchain you created
  • SSH-TO-FIRST-TX-NODE-REGION1: Credentials for connecting to a transaction node that is in the first region

How it works...

Steps 1 to 9 guide you through the process of creating a private Ethereum consortium using services offered by Azure. This will create and deploy multiple peers across various regions behind a load balancer for you to interact with. Steps 10 to 12 describe the process of using these services. This helps you understand various services and where to use them.