# How to SetUp ETH account Step to step Guide ## How to Set Up a Private Ethereum Blockchain In this tutorial, I will give you a complete step-by-step guide on how to build a private Ethereum blockchain in minutes. Let's first see what Blockchain and Ethereum is. ![](https://i.imgur.com/gJVH8CY.png) ## What is Blockchain? Simply Blockchain is a distributed database that can be updated securely and iteratively. Recently, many applications using blockchain have been developed, basically to facilitate secure and private final transactions. Blockchain acts as a universal spreadsheet that removes a central point of failure from the system and has been proposed as a way to secure online transactions. **The main characteristics of blockchains are:** * Distributed — Since the blockchain is a distributed database, there is no centralized copy. This makes the system robust against hacks. * Secure — The distributed database is encrypted with private and public keys. * Public - There is no central authority to validate or record transactions in a blockchain, which leads to a more transparent and secure system. ### What is Ethereum? Ethereum is an open-source, public, blockchain-based, distributed computing platform and operating system with smart contract functionality[1]. "Ether" is the crypto-fuel of the Ethereum network which is used to carry out transactions. Ethereum's most sophisticated feature is Smart Contract which is a program that facilitates the exchange of money, content, property, shares or anything of value. The smart contract becomes a self-contained computer program that runs automatically when specific conditions are met. They work exactly as programmed without any possibility of downtime, censorship, fraud or third party interference. The Ethereum blockchain network is simply a collection of nodes connected to all other nodes to create a network. Each node runs a copy of the entire blockchain and competes to validate and create the next block. Each time a new block is added, the blockchain updates itself and spreads to the entire network. Therefore, to become a node in the Ethereum network, your computer will need to download and update a copy of the entire blockchain. You can create a "private" Ethereum network rather than the public network that can be used to transact and create smart contracts without the need for real Ether. A private network is the best way to learn blockchain concepts without the need for real currency. **So let's get started!** ### Step 1 - Environment Setup First, you need to install Geth which is a command line interface (CLI) tool that communicates with the Ethereum network and acts as a link between your computer and the rest of the Ethereum nodes. Go to the Go Ethereum site. Download and install the binary for your operating system. ### Step 2 - Configure the Genesis File To run a private network, you need to provide geth with some basic information needed to create the initial block. Every blockchain starts with a Genesis block, the very first block in the chain. To create our private blockchain, we will create a genesis block with a custom genesis file. Next, tell Geth to use this genesis file to create our own genesis block. **Custom Genesis File** { "nonce": "0x0000000000000042", "timestamp": "0x0", "parentHash": "0x00000000000000000000000000000000000000000000000000000000000", "extraData": "0x00", "gasLimit": "0x8000000", "difficulty": "0x400", "mixhash": "0x00000000000000000000000000000000000000000000000000000000000", "coinbase": "0x33333333333333333333333333333333333333", "allocate": {}, "config": {"chainId": 987, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0} } **Explanation about the configuration file;** ### chainId: A unique identifier of the new private blockchain * homesteadBlock: Homestead is the first production version of Ethereum and since the developers are already using this version, the value of this parameter can be left at '0'. * eip155Block/eip158Block: EIP stands for "Ethereum Improvement Proposals", these have been implemented to release Homestead. In a private blockchain development, hard forks are not needed, therefore the parameter value should be left as "0". * difficulty: controls the complexity of the mining puzzle and a lower value allows for faster mining. * gasLimit: Sets an upper limit for the execution of smart contracts. And boom!! Lots of ether in your account. But remember that it is fake ether and you cannot use it to transact on the Ethereum mainnet. However, you can use this ether to test blockchain functions such as transfers, smart contract deployment, etc. In the next step we will add more nodes to our private network. Wait! #### Step 5 - Add more nodes/peers To add a new node, run the commands from steps 2-4 in a new terminal. **Important note:** * You must use the same genesis.json file to launch the node. * You must use a different data store folder from the new node. * Make sure to use the same network ID for the new node. * You must give a port number because the default port is already used by the first node. 1. geth --rpc --rpcport "8085" --datadir /path_to_your_data_directory/TestChain2 init /path_to_folder/genesis.json 2. geth --rpc --rpcport "8085" --datadir /path_to_your_data_directory/TestChain2 --networkid 123 --nodiscover --port 30306 In the console of the second node, run admin.nodeInfo.enode You should get something similar to this. **Note:** * [::] will be parsed as localhost (127.0.0.1). If your nodes are on a local network, check each individual host machine and find your IP address with ifconfig * If your peers are not on the local network, you need to know your external IP address (use a service) to construct the enode URL. **Copy this value and in the console of the first executed node,** admin.addPeer("enode://f2da64f49c30a0038bba3391f40805d531510c473ec2bcc7c201631ba003c6f16fa09e03308e48f87d21c0fed1e4e0bc53428047f6dcf34da344d3f5bb693") This will return true on success, but it doesn't mean the node was successfully added. To confirm, run admin.peers and you should see details of the node you just added. * If you start mining on the first node by running miner.start(), you will see the block number increase on the second node. * Congratulations! You've just built your first private Ethereum blockchain, mined ether, and added more peers to the network! * Thank you for following this tutorial and I hope you found it useful. * Do you have something to add ? I would love to hear your thoughts. **The references** **[1]** https://en.wikipedia.org/wiki/Ethereum **[2]** https://www.ethereum.org Thanks for reading!! Do you have something to add ? I would love to hear your thoughts :)