How to create an Ethereum private testnet for development or experimentation

in #ethereum8 years ago (edited)

Instead of being a "simple" payment/value storage system like Bitcoin, Ethereum provides a lot of functionality that needs learning and experimenting to get right. But how do we work on this, without the hassle of syncing the blockchain (possibly on various development machines) and without the risk (and cost) of working on the live network?

The solution is to create your own private blockchain, starting at Block 0 (called the genesis block). This way, you have Ethereum up and running in less than 5 minutes, without sacrificing any disk space on yout development 64GB ultrabook!

Steps

1. Download the pre-created data directory and accompanying scripts

You can find the git repository here.

Note: This was not made by me. I forked the original repository to change the scripts to conform to newer geth versions, since they were outdated. A pull request towards the original repository was created. You can have a look at it here.

Clone it using:

git clone https://github.com/mikevas/Ethereum.TestNet.Genesis

2. Initialize your network

Go into the newly created directory and initialize the new network using geth:

cd Ethereum.TestNet.Genesis
geth --rpc --networkid=39318 --maxpeers=0 --datadir=devChain --verbosity 0 init genesis_dev.json

Make sure you provide the correct paths for geth, devChain and genesis_dev.json. These depend on what your current path is, where you cloned the repository and where you have geth installed.

Geth will initialize the network and return immediately.

Note: You can also run the provided scripts. Use init.sh on Linux (needs execute permissions) or init.bat on Windows.

3. Start your node

Start geth pointing it to the new data directory and dissallowing it from connecting to any nodes (we don't want it trying to connect to the Ethereum network!).

geth --rpc --networkid=39318 --maxpeers=0 --datadir=devChain --verbosity 0 console

Note: You can also run the provided scripts. Use startgeth.sh on Linux (needs execute permissions) or startgeth.bat on Windows.

You can now start Ethereum-Wallet and it will detect that you are running on a private network.

Ethereum wallet running on private network

You are ready to experiment/develop.

Sort:  

Your PR has been merged. It's OK to point to the original repo now.

JIC, here's another guide by Hudson Jameson. It explains in detail the arguments to geth, and manual setup. It's dated, though, and references --genesis.

Thanks, I will update the post asap.

Coin Marketplace

STEEM 0.18
TRX 0.24
JST 0.036
BTC 94781.20
ETH 3263.66
USDT 1.00
SBD 3.08