Note
If you are new to the blockchain technology, taking our Introduction to Blockchain Technology self-paced course is highly recommended. Also, for a comprehensive coverage of blockchain development in Ethereum or mastering Solidity programming, taking our below self paced courses is highly recommended:
Recap
In our previous article (How to Build a Local Private Ethereum Blockchain with Mining), we discussed how to develop a local private Ethereum network that includes mining component.
In this article, we learn how to run Geth on a local private Ethereum network that includes mining component.
Running Geth
With the genesis.json file, let’s build the first node in the private blockchain for mining.
1. Let’s navigate to the root directory and initialize the blockchain using the
genesis.json file, as follows:
$ cd hello_world_mining/data $ geth --datadir hello_world_mining/data init hello_world_mining/genesis.json
To make this a bit more interesting, we will set up our own bootnode. A bootnode is a node that can be used to allow any node to join the private network for the first time and find other nodes in the network.
For example, MainnetBootnodes is the bootnode of the main Ethereum network. It is defined as follows in params/bootnodes.go:
var MainnetBootnodes = []string{ // Ethereum Foundation Go Bootnodes "enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c2843399 68eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d33311 63c@52.16.188.185:30303", // IE "enode://3f1d12044546b76342d59d4a05532c14b85aa669704bfe1f864fe07941 5aa2c02d743e03218e57a33fb94523adb54032871a6c51b2cc5514cb7c7e35b3ed0 a99@13.93.211.84:30303", // US-WEST … }
Other than MainnetBootnodes, there are also other predefined bootnodes for test networks:
- Ropsten test network: TestnetBootnodes
- Rinkeby test network: RinkebyBootnodes
- Goerli test network: GoerliBootnodes
- Experimental RLPx v5 topic-discovery network: DiscoveryV5Bootnodes
As we can see, there are the existing test networks: the Ropsten test network, the Rinkeby test network, the Goerli test network, and the experimental RLPx v5 topic-discovery network. We will talk about them in detail later on.
Geth supports bootnode creation for private networks too. You will start bootnode at the specified enode address. The following steps are for creating an enode URL and starting the bootnode.
One-to-One Live Blockchain Classes
Coding Bootcamps school offers One-to-One Live Blockchain Classes for Beginners.
2. If you type the bootnode command, you will get the following warning:
$ bootnode Fatal: Use -nodekey or -nodekeyhex to specify a private key.
It complains about a missing private key, which can be generated by a command;
Let’s call this key PrivateBootnode.key:
$ bootnode -genkey PrivateBootnode.key
3. As shown in the following code block, we can check if the key was generated:
$ cat PrivateBootnode.key 15bdd11dbff8327552ac8ac7fb2c3bca4373e98657dd30d83491cea635dca903
4. We can get the enode address of the bootnode by using the -nodekey option:
$ bootnode -nodekey PrivateBootnode.key
Alternatively, we can use the key from the previous step to generate the enode address:
$ bootnode -nodekeyhex 15bdd11dbff8327552ac8ac7fb2c3bca4373e98657dd30d83491cea635dca903 - writeaddress c25172a39c2c118290912c181b73376e4e58b8cc3b5178e4aa2f0a929e1739216c9 baa6db990513963bcf6a3cf1652c23d5655cc637f5d611297349f887543d0
5. Now, start a new terminal session. We will use the -bootnodes flag to tell geth to use the bootnode we just created. Remember to put enode:// before the enode address:
$ cd hello_world_mining/ $ geth --datadir data -- bootnodes=enode://c25172a39c2c118290912c181b73376e4e58b8cc3b5178e4a a2f0a929e1739216c9baa6db990513963bcf6a3cf1652c23d5655cc637f5d611297 349f887543d0@100.100.100.100:3031
Geth will create a file under hello_world_mining/data/geth.ipc. We will use this file to create a new account.
Next Article
In our next article (How to Create an Account on a Local Private Ethereum Blockchain), we discuss how to create an account on a local private Ethereum network.
This article is written in collaboration with Brian Wu who is a leading author of “Learn Ethereum: Build your own decentralized applications with Ethereum and smart contracts” book. He has written 7 books on blockchain development.
Resources
Free Webinars on Blockchain
Here is the list of our free webinars that are highly recommended:
- Hyperledger Fabric for system admin versus developers
- How to harness blockchain for environmental and corporate sustainability
- Review of Initial Coin Offering, Security Token Offering and asset tokenization use cases and best practices
- Hyperledger Fabric Deployment on Cloud
- Hyperledger Fabric for entrepreneurship- 21 blockchain business use cases
Free Courses
Here is the list of our 10 free self-paced courses that are highly recommended:
- IT Career Roadmap Explained
- Web Design with Bootstrap
- User Experience Best Practices
- Intro to Search Engine Optimization
- Web Design with WordPress
- Introduction to Drupal CMS
- Intro to Joomla CMS
- Intro to Cybersecurity
- Introduction to Cloud Technology
- Recorded Live Webinars and Classes
Self-Paced Blockchain Courses
If you like to learn more about Hyperledger Fabric, Hyperledger Sawtooth, Ethereum or Corda, taking the following self-paced classes is highly recommended:
- Intro to Blockchain Technology
- Blockchain Management in Hyperledger for System Admins
- Hyperledger Fabric for Developers
- Intro to Blockchain Cybersecurity
- Learn Solidity Programming by Examples
- Introduction to Ethereum Blockchain Development
- Learn Blockchain Dev with Corda R3
- Intro to Hyperledger Sawtooth for System Admins
Live Blockchain Courses
If you want to master Hyperledger Fabric, Ethereum or Corda, taking the following live classes is highly recommended:
- Live and self-paced blockchain development with Ethereum
- Live and self-paced blockchain development with Hyperledger Fabric
- Live and self-paced blockchain development with Corda
- Immersive Blockchain Bootcamp with live and self-paced courses
- Live crash course for learning Ethereum with Solidity
- Live crash course for building DApps with Hyperledger Fabric
- Live crash course for building DApps with Corda
- Live full-stack blockchain development in Hyperledger and Ethereum
Articles and Tutorials on Blockchain Technology
If you like to learn more about blockchain technology and how it works, reading the following articles is highly recommended:
- History and Evolution of Blockchain Technology from Bitcoin
- Overview of Blockchain evolution and phases from Ethereum to Hyperledger
- Comprehensive overview and analysis of blockchain use cases in many industries
- Blockchain Crowdfunding Security Token or Initial Coin Offerings
- A beginner Guide to Blockchain Technology
- How Decentralized Peer-To-Peer Network Works
- How blocks are added to the blockchain
- How Public and Private Keys of Cryptography Work
- What Is A Cryptographic Hash Function
- How Digital Signature Works In Blockchain
- The role and types of consensus mechanism in blockchain
- How Proof-of-Work Consensus Works in Blockchain
- How Proof of Stake Consensus works in Blockchain
Articles and Tutorials on Ethereum and Solidity
If you like to learn more about blockchain development in Ethereum with Solidity, reading the following articles and tutorials is highly recommended:
- Review of Architecture and Components of Ethereum
- Comprehensive Blockchain Ethereum Developer Guide from Beginner to Advance Level
- How to Write Ethereum Smart Contracts with Solidity in 1 hour
- Review of Architecture and Components of Ethereum
- How Ethereum Manages Accounts
- How Ethereum Manages Transactions
- How Smart Contracts Work in Ethereum
- How Ether and Gas Work in Ethereum
- How Ethereum Virtual Machine works
- How address and wallet work in Ethereum
- How mining works in Ethereum
- List of Tools and Technologies in Ethereum Ecosystem
- Review of challenges in distributed systems
- Review of Cap Theorem in Distributed Systems
- Horizontal Scaling versus Vertical Scaling in Distributed Systems
- How to Scale up Ethereum Blockchain Applications
- Review of scaling solutions for Ethereum
- How to Manage Ethereum State Channel with Raiden
- How Plasma Chains Work in Ethereum
- How Sharding and Gasper work in Ethereum
- How Proof-of-Stack Consensus Works in Ethereum
- A roadmap for Implementing Ethereum 2.0
- How to work with Decentralized Data and Content Storage in Ethereum
- How Decentralized Messaging with Whisper Works in Ethereum
- Review of Infura for Ethereum Development
- Review of Infura Ethereum API
- How to Use Remix with Infura for Ethereum Development
- How Ethereum Client API Works
- How Ethereum IPFS Storage Works
- How to Install and Start Ethereum IPFS Storage
- How to Run Ethereum IPFS Storage
- How to Work with Ethereum Swarm Storage
- How to Install Ethereum Swarm Storage
- How to Handle Ethereum Messages with Whisper
- Review of Popular Ethereum Smart Contract Libraries
- Review of Private and Permissioned blockchain
- How to Set up a Local Private Ethereum Blockchain
- How to Run Geth on a Local Private Ethereum Blockchain
- How to Build a Local Private Ethereum Blockchain with Mining
- How to Run Geth on a Local Private Ethereum Blockchain with Mining
- How to Create an Account on a Local Private Ethereum Blockchain
- How to Use Ethereum Optional Flags with New Chains
- Review of Ethereum Options for Development and Testing
- Review of Ethereum Developer Chain Options
- Review of Ethereum API and Console Options
- Review of Ethereum Networking Options
- Review of Ethereum Transaction Pool Options
Articles and Tutorials on Hyperledger Family
If you like to learn more about blockchain development with Hyperledger, reading the following articles and tutorials is highly recommended:
- Introduction to Hyperledger Architecture, Projects, Tools and Libraries
- Complete Review of Hyperledger Fabric Architecture and Components
- Hyperledger Fabric for System Administers versus Developers
- How to use Prometheus and Grafana to monitor Hyperledger Fabric
- Blockchain Developer Guide- How to Install Hyperledger Fabric on AWS
- Blockchain Developer Guide- How to Install and work with Hyperledger Sawtooth
- Blockchain Developer Guide- How to Install Hyperledger Burrow on AWS
- Blockchain Developer Guide- How to Install Hyperledger Iroha on AWS
- Blockchain Developer Guide- How to Install Hyperledger Indy and Indy CLI on AWS
- Blockchain Developer Guide- How to Install Hyperledger Seth and Docker on AWS
- Blockchain Developer Guide- How to Configure Hyperledger Sawtooth Validator and REST API on AWS
- Blockchain Developer Guide- How to Build Transaction Processor as a Service and Python Egg for Hyperledger Sawtooth
- Blockchain Developer Guide- How to Deploy Ethereum Smart Contracts with Hyperledger Burrow
- Blockchain Developer Guide- How to Create Cryptocurrency Using Hyperledger Iroha CLI
- Blockchain Developer Guide- How to Explore Hyperledger Indy Command Line Interface
- Blockchain Developer Guide- Comprehensive Blockchain Hyperledger Developer Guide from Beginner to Advance Level
- Introduction to Hyperledger Sawtooth Blockchain Development
Articles and Tutorials on R3 Corda
If you like to learn more about blockchain development on Corda , reading the following articles and tutorials is highly recommended:
Articles and Tutorials on Other Blockchain Platforms
If you like to learn more about blockchain development in other platforms, reading the following articles and tutorials is highly recommended: