I'd like to set up a local (private) blockchain that isn't connected to the wider internet so that I can deploy some test contracts. How do I go about doing that?

  • Hi all - the top answers below are out of date these days (July/Aug 2017). Specifically, --dev (DevMode) is probably not what you want to use to run a private blockchain. See, e.g. ethereum.stackexchange.com/questions/23468/… for more discussion on the topic. Commented Aug 2, 2017 at 6:51

13 Answers 13


Creating a private testnet for Ethereum is actually pretty easy. In recent versions of geth, you don't even need to create your own genesis block, or any other complicated steps (many of the online tutorials are out of date).

First, make sure you have geth installed. On OSX, you would do this by first installing Homebrew, then running:

$ brew tap ethereum/ethereum
$ brew install ethereum

For other platforms, check out the geth installation instructions.

You can test that it's working by checking the version:

$ geth version
Version: 1.3.6
Git Commit: 9e323d65b20c32ab1db40e8dde7172826e0e9c45
Protocol Versions: [63 62 61]
Network Id: 1
Go Version: go1.6
OS: darwin

Now, you can start a private blockchain by running geth with the --dev option:

$ get --dev --ipcpath ~/Library/Ethereum/geth.ipc

This does the following things to make development easy (source):

  • Sets --vmdebug (Virtual Machine debug output)
  • Sets --maxpeers 0 (Networking disabled)
  • Sets --gasprice 0 (Make your contracts affordable)
  • Sets --port 0 (Listen on a random port)
  • Sets --shh (Whisper protocol enabled)
  • Sets --datadir to a temporary directory on your hard drive
  • Enables "dev mode", which causes geth to automatically generate a new genesis block the first time you run it.
  • Sets --ipcpath to the standard IPC path so other commands e.g. geth attach, works without additional parameters

Now, you can probably connect to your private network already, either by running geth --dev attach in another terminal window, or by starting up Mist Wallet. But before you can do anything, you probably want to create an account, and mine a few coins so that you can spend them.

Leave your original terminal window running, and in another window type:

$ geth --dev attach

This will give you a JavaScript console. You can run the following commands to create your first account:

> personal.newAccount('choose-a-password')

Now, you want to mine some coins:

> miner.start()

In the first window, you will see mining messages start to scroll by:

I0401 12:41:03.318046   83003 worker.go:348] 🔨  Mined block (#1 / fb68b6aa). Wait 5 blocks for confirmation
I0401 12:41:03.318486   83003 worker.go:569] commit new work on block 2 with 0 txs & 0 uncles. Took 399.006µs

Once you have about 10 blocks mined, go back to the JavaScript console, and stop it:

> miner.stop()

That's it! Now you have your own private testnet.

Finally, a quick shameless plug: I wrote gethdev, a simple wrapper around geth, which will simplify this process of creating your own private testnet, by automatically creating your first account, starting and stopping the mining process when there are pending transactions, and providing an environment variable to remember common arguments you always end up passing to geth. Feedback welcome!

  • 1
    Very good/detailed answer. +1
    – niksmac
    Commented Apr 3, 2016 at 2:15
  • 7
    thanks for answer! by the way, geth --dev attach won't start, if you didn't specify ipc path, so this what worked for me: geth attach ipc://%your_temp_dev_path%/ethereum_dev_mode/geth.ipc
    – animekun
    Commented Jun 15, 2016 at 22:08
  • 2
    when we start mining in dev/private net what exactly is being mined? where do the blocks come from ? In main or testnet we are connected to a global network . how is it in the case of dev? . I am just starting up on ethereum block chain . excuse for any obvious wrong questions.
    – Aravind
    Commented Jun 17, 2016 at 4:12
  • 3
    geth --dev works great, as does the gethdev project Adrian discussed. To prevent having to use the custom ipc flag to attach to the dev server, consider running like this: get --dev --ipcpath ~/Library/Ethereum/geth.ipc This has the added benefit of allowing the Ethereum Mist wallet to work with your local ethereum testnet.
    – JTE
    Commented Aug 6, 2016 at 16:50
  • 1
    You should also add a command to show the balance after miner stop.
    – Jus12
    Commented Jan 19, 2017 at 8:05

Some of the main steps involve specifying a networkId, and creating a genesis file (you can give your account a lot of ether!).

Rather than repeat what's been written, there are guides here and here.

  • 1
    This is no longer necessary. See Adrian Macneil's answer.
    – bortzmeyer
    Commented May 26, 2016 at 14:59

If you are just testing contracts I would recommend using a lightweight Ethereum node like https://github.com/trufflesuite/ganache-cli. This way getting your network set up is as simple as running:

npm install -g ganache-cli

Once it is installed, you can start the testnet with:


This Ethereum Node simulator will have a few accounts which are prefilled with a bunch of ETH. Not only is using a simulator easier to setup, but boot-time and transactions are much quicker. However, it isn't a fully featured Ethereum node, so it's only good for early stage development.

I just wrote a blog post called An Introduction to Ethereum Testnets which you may find helpful. You can find it here: https://karl.tech/intro-guide-to-ethereum-testnets/


Using the scripts below (from From geth --dev exposes live net accounts. Is it safe?) will ensure that your --dev keystore is separated from your Mainnet keystore, reducing your risk of exposing your Mainnet account passwords.

Here is my Dev startup script:


geth --datadir ~/EtherDev/data --dev --nodiscover    \
  --mine --minerthreads 1 --maxpeers 0 --verbosity 3 \
  --unlock 0 --password ~/EtherDev/etc/passwordfile  \
  --rpc console

And here is the Dev script I use to create my passwords:


mkdir ~/EtherDev/data
geth --datadir ~/EtherDev/data           \
  --password ~/EtherDev/etc/passwordfile \
  account new

And I just use a simple password in ~/EtherDev/etc/passwordfile.


I faced some issues, while I was setting up private net using geth. Here are the steps I noted and I believe it can be helpful for you -

Note: I'm assuming you have installed geth and go on your machine.

$ mkdir pnet
$ geth --datadir pnet/ account new 

# This command will prompt you to enter password, type the password and remember it.
# Once you enter the password, account will be created and account address(hash) will appear, don't miss saving it.
# Sample output - Address: {93044af5bc90b1dda0668ae3e171ce746c320d06}
# Note, multiple accounts can be created
# Note, you must append "0x" to the address in the allocate section i.e your address becomes {0x93044af5bc90b1dda0668ae3e171ce746c320d06}
$ vim genesis.json 

# Sample Gensis file given below. In alloc attribute, 
# Mention created account address and assign some balance as shown in sample file.
# {
#    "config": {
#        "chainId": 15,
#        "homesteadBlock": 0,
#        "eip155Block": 0,
#        "eip158Block": 0
#    },
#     "gasLimit": "0x8000000",
#     "difficulty": "0x400",
#     "alloc": {"0x93044af5bc90b1dda0668ae3e171ce746c320d06": 
#                  {"balance":"200000000000000000000000"}
#             }
# }

# run below command to instantiate genesis block
$ geth --datadir pnet init genesis.json

# run following to start geth private node
$ geth --rpc --rpcport "8545" --rpcaddr "" --rpccorsdomain "*" --datadir pnet/ --port "30303" --rpcapi "personal,db,eth,net,web3" --mine  
# rpcaddr in above command will be the IP of the instance where you plan to run your geth node

# once geth node starts copy the geth.ipc path to attach a geth console in another terminal using below command
$ geth attach ipc://path_to_ipc_file/geth.ipc

# After opening geth console, try unlocking the first account created above, using below command
# personal.unlockAccount("hash of the account in quotes or eth.coinbase", "password in quotes", 0)

$ personal.unlockAccount('93044af5bc90b1dda0668ae3e171ce746c320d06', 'password', 0)

Now you can start using the geth private node.

  • what is geth attach ipc://path_to_ipc_file/geth.ipc means ? I curious that the path you said .
    – Gopal ojha
    Commented Jul 25, 2017 at 8:27
  • In order to attach another terminal window with your geth node you would have to use geth attach command and give the IPC file path. So here is my example you will need to change "path_to_ipc_file/geth.ipc" this to the actual ipc file path.
    – Sanchit
    Commented Jul 25, 2017 at 8:32
  • How do I know the path?
    – Gopal ojha
    Commented Jul 25, 2017 at 8:35
  • You can find it when you run your geth console, you will find it in logs. See the screenshot for reference(the second last line) i.imgur.com/IOSjodm.png
    – Sanchit
    Commented Jul 25, 2017 at 8:40

As an additional information to the previous answers:

if your goal is to write and test contracts/Dapps you could use blockapps, it helps you to setup easily a local private blockchain you could also look at testRpc .

  • 2
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Commented Jan 3, 2017 at 12:03

This guy is awesome, get through all parts starting from 1 ending with 5:



Just to summarize what is there on the link (using Mac):

First you need to download geth, the go etherum platform.

  1. Create a folder and create a genesis file inside that folder, call it customGenesis.json, which contains your blockchain details. Make it similar to the following, just change the chain ID:

     "config": {
        "chainId": 2017,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    "alloc"      : {},
    "coinbase"   : "0x0000000000000000000000000000000000000000",
    "difficulty" : "0x400",
    "extraData"  : "0x",
    "gasLimit"   : "0x8000000",
    "nonce"      : "0x0000000000000042",
    "mixhash"    : "0x0000000000000000000000000000000000012345678765545432233567778987",
    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp"  : "0x00"
  2. Create another folder which will hold the node information, (folder_of_your_first_node)

  3. Open the Terminal to create the first node using the blockchain genesis file:

    geth --datadir (folder_of_your_first_node) init (folder_of_your_genesis_file)/customGenesis.json
  4. Start the network using the first blockchain node, for the networkid select any unique number, make it big:

    geth --datadir (folder_of_your_first_node) --networkid 77665533
  5. Now the blockchain is ready and up and running, start a new Terminal window to access your node:

    geth attach (folder_of_your_first_node)/geth.ipc
  6. Now you are inside the node of the blockchain, create an account:

    Passphrase:(select a password)
    Repeat passphrase: (repeat the password)
    (you should see the address of your account here)
  7. You can start mining for ethers, which you will need to deploy the contract:

  8. Wait for some time, a minute, then stop mining:


End of Article

Now I avoided what has been mentioned in the article to deploy contracts, where you can download the default Mist and start it using your private network, this will make deploying your contracts easier (using third new Terminal:

open -a /Applications/Mist.app --args --rpc  (folder_of_your_first_node)/geth.ipc

You should see your first account full of ethers :). Enjoy!

Another thing worth to mention her, after you deploy your first contract using Mist, you need to go back to your second Terminal (where you are inside the node) and start mining again, otherwise, your contact deployment transaction will not be processed:


Check the Mist, and make sure that the transaction at the bottom of the screen already processed, then you can go back and stop mining:

  • Hi there. Link-only answers are discouraged because the link could go dead or be moved at any time, making your answer obsolete. Can you edit your answer to summarise the steps from the link? Commented Dec 11, 2017 at 10:51
  • @RichardHorrocks with my pleasure :)
    – Shadi
    Commented Dec 11, 2017 at 12:09

I followed this documentation and had a private chain running in minutes. http://www.ethdocs.org/en/latest/network/test-networks.html#id3

  • Please give a better description of how you achieved it. Providing links without much context doesn't help many users.
    – Malone
    Commented Nov 22, 2017 at 16:26
  • 1
    You cannot get a better description than I followed the documentation exactly as it is written. There is no need to elaborate any further as it is explained in great detail step by step at the link provided.
    – Lismore
    Commented Nov 23, 2017 at 16:08
  • Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – Malone
    Commented Nov 23, 2017 at 16:17
  • It does not "theoretically answer the question", it answers the question and provides a link to the steps I followed to get the result that this question poster is seeking. "Preferable to include the essentials parts of the answer", "I followed this documentation", that is the essential part of the answer. Answers should be about quality not the quantity of the text in your answer. If someone can achieve the exact result as me by following the documentation at the link provided why make it anymore complex with more subjective interpretation of a clear set of steps already verified to work,
    – Lismore
    Commented Nov 23, 2017 at 16:30
  • Trying to give you advice that the community agrees with, if I don’t others will. Take it or leave it.
    – Malone
    Commented Nov 23, 2017 at 16:33

Just to update with new tools this thread. There is a nice tool to help building private testnet for tests! uppeth: https://blog.ethereum.org/2017/04/14/geth-1-6-puppeth-master/

Geth 1.6 ships a new tool called puppeth, which aims to solve this particular pain point. Puppeth is a CLI wizard that aids in creating a new Ethereum network down to the genesis, bootnodes, signers, ethstats, faucet, dashboard and more, without the hassle that it would normally take to configure all these services one by one.

Here you get a live demo during Devcon3: https://www.youtube.com/watch?v=T5RcjYPTG9g&list=PLaM7G4Llrb7xnKb_SeaKZ27opvaIjlBv5&index=1


Create a folder and create a genesis file inside that folder, call it genesis.json

    "nonce"     : "0x0000000000000055",
    "mixHash"   : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "difficulty": "0x20000",
    "gasLimit"  : "0x800000",
    "timestamp" : "0x0",
    "extraData" : "",
    "coinbase"  : "0x0000000000000000000000000000000000000000",
    "alloc"     : {},
    "config"    : {
        "chainId": 100,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0

then genesis.json init commend run and genesis inti commend:

geth --datadir "D:\bolckchain\chaindata" init "c\genesis.json"

D:\bolckchain\chaindata meanies all data store this directory and c\genesis.json meanies this directory genesis file .

Then Private Network create commend run :

geth --networkid 13 --port 30303 --datadir "D:\bolckchain\chaindata" console

Then this commend run and private network create : this network check :

$ admin 

then networkid = 13 .

This port 30303 port changeable example : 60606 this port o use

thanks try it and private network create then mist or ethereum wallet run



If you wanna setup a proof-of-authority private network, I've published a detailed step by step guide on medium.


in a nutshell, you need at least 2 nodes for PoA clique consensus engine

create a workspace

$ mkdir devnet
$ cd devnet 
devnet$ mkdir node1 node2

create 1 account per node

devnet$ geth --datadir node1/ account new
devnet$ geth --datadir node2/ account new

create a genesis file with puppeth

$ puppeth

initialize your nodes

devnet$ geth --datadir node1/ init genesis.json
devnet$ geth --datadir node2/ init genesis.json

create a bootnode

devnet$ bootnode -genkey boot.key

start your bootnode

devnet$ bootnode -nodekey boot.key -verbosity 9 -addr :30310

start node 1:

devnet$ geth --datadir node1/ --syncmode 'full' --port 30311 --rpc --rpcaddr 'localhost' --rpcport 8501 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://3ec4fef2d726c2c01f16f0a0030f15dd5a81e274067af2b2157cafbf76aa79fa9c0be52c6664e80cc5b08162ede53279bd70ee10d024fe86613b0b09e1106c40@' --networkid 1515 --gasprice '1' -unlock '0x87366ef81db496edd0ea2055ca605e8686eec1e6' --password node1/password.txt --mine

start node 2:

geth --datadir node2/ --syncmode 'full' --port 30312 --rpc --rpcaddr 'localhost' --rpcport 8502 --rpcapi 'personal,db,eth,net,web3,txpool,miner' --bootnodes 'enode://3ec4fef2d726c2c01f16f0a0030f15dd5a81e274067af2b2157cafbf76aa79fa9c0be52c6664e80cc5b08162ede53279bd70ee10d024fe86613b0b09e1106c40@' --networkid 1515 --gasprice '0' --unlock '0x08a58f09194e403d02a1928a7bf78646cfc260b0' --password node2/password.txt --mine

open a javascript console to node 1:

devnet$ geth attach node1/geth.ipc

connect Mist to node 1:

devnet$ mist --rpc node1/geth.ipc

use a python or javascript web3 libraries to make JSON-RPC calls to your blockchain.

I hope this helps. Enjoy :)


I just wrote an article that goes over how to create a private ethereum blockchain using geth and go-ethereum. Let me know if you have any questions.


  • 4
    Whilst this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference.
    – q9f
    Commented Jan 3, 2017 at 12:02

You can use parity for a development network

Install Parity

bash <(curl https://get.parity.io -kL)

Start your private ethereum network

parity --chain dev

Browse at localhost:8180. There you can start developmenrt of smart contracts.

For further configuring the network

You can have a look at wiki if you want to further add any customisations to the network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.