How to Setup a Private Ethereum Blockchain
For this tutorial to work you must have geth downloaded.
First you must create a genesis.json file with the parameters below. Each field can be changed however you want. It is recommended that you make a random nonce for your private ethereum network to avoid the chance of someone connecting to your blockchain. The allec object is to prefund accounts on your blockchain with tokens.
"coinbase" : "0x0000000000000000000000000000000000000000",
"difficulty" : "0x20000",
"extraData" : "",
"gasLimit" : "0x2fefd8",
"nonce" : "0x0000000000000042",
"mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" : "0x00",
Once you have setup your genesis.json file you need to run it from your terminal with this command to initiative your private blockchain network. Setting a data directory is optional, however it is recommended because otherwise your blockchain will be started in a default folder, or can get connected to the live ethereum blockchain if you are running a full ethereum node, which you probably don't want.
geth --datadir /path/to/genesis.json init genesis.json
When executed in your terminal, you should see a success message. You should also see a folder called "chaindata" that was created in the data directory that you initiated your private ethereum blockchain.
You can now connect to your private network using geth, which will run on your testnet the same way as it does on the live ethereum blockchain. Run the following command to connect geth with your private blockchain.
geth --datadir /path/to/genesis.json
In the message that is returned from the terminal, it is important to note the enode you are listening at and the IPC endpoint to connect other nodes to your blockchain.
If your terminal returns a message saying that the server has started, you have successfully connected geth to your private ethereum blockchain.
You should now have 3 more folders created in your private ethereum blockchain data directory including dapp, nodekey and nodes.
This tutorial was originally published on MLG Blockchain.
MLG Blockchain is a blockchain development and consulting firm based in Toronto that is focused on building next generation applications using blockchain and smart contract technology. See more blockchain development tutorials on the MLG Blockchain blog.
Don't miss a story
Subscribe to our email newsletter:
Don't worry we hate spam as much as you do