Setup a Local Ethereum Test Blockchain

♦ Version: 2, 07/10/2015

♦ License: Beerware Version 42++

This guide is continually updated on the wiki. Please see there to get the latest version: http://tech.lab.carl.pro/kb/ethereum/testnet_setup.

 

Introduction

Setting-up a local test Ethereum network is very useful for playing around, test free of Ether charge and develop – and it’s also very easy and fast.

On this page, I have compiled one (of many) procedures describing how to do that. The aim was to explain a lot and make the procedure clear, so the page has become quite large. However, the entire process takes only 5 minutes and consists of around 5 Linux commands to execute (provided that Ethereum clients are installed and operational).

The tutorial will be updated over time, new ideas added and improvements made. So be sure to check back from time to time :)

To read more about the terminology encountered in the divers screens, have a look at my Technical Blockchain Encyclopaedia.

Note: Ξ (Xi Uppercase) is the official currency symbol for Ether. I generally use ≢ to indicate Test-Ether or False-Ether, when this difference matters.

Set-Up Procedure

Prerequisite: UBUNTU, Mint or another UBUNTU based flavor ready for use. Ethereum client installed and operational.

1) Blockchain data and account directory

By default, the Ethereum client stores the Blockchain data and the account data in the “.ethereum” folder in the user’s home directory. When installing a test Blockchain, potentially in parallel to the official Blockchain, we have 2 easy options to direct Ethereum to use a different data directory than the one of the principal chain:

1) For each client command invocation, we specify the alternative data directory.
2) We create a different user account that handles all things around the test Blockchain.

The second solution is my favorite since it’s very easy to do on a Linux system and switching users adhoc is simple using the ‘su‘ command.

The procedure described on this page uses the Linux user account ‘testnet1‘ as in charge for the alternative Blockchain.

If you opt for using a different data directory instead, just specify the parameter “– -datadir <datadirectory>” in all Ethereum tool commands.

2) Custom Genesis Block

Download link: customgenesis.json

The Genesis block is the start block of the Blockchain – the first block, block 0, the only block that does not point to a predecessor block. It’s the entry point into the Blockchain database. The Genesis data defines initial parameters of the database and defines a cryptographically valid entry block. For more info, read here:The Blockchain Genesis Block.

In order to set-up our private Ethereum Blockchain, we need to provide our own customised Genesis block. Since we don’t want to do heavy lifting to mine blocks, ie. allowing fast, single-threaded CPU mining, and we don’t want to be limited by Gas prices and limits, we set the various parameters accordingly.

The Genesis block does not define to which Blockchain a Miner connects to. Any Miner can mine on any Blockchain. A specific Blockchain is targeted by connecting to the corresponding peer-to-peer network. By default, geth uses a discovery protocol to find reachable peer Miners. When there are multiple Blockchains running on the same physical network, –networkid is used to specify which Miner group/network to connect to. If not specified, “1” is used, which is the ID of the public Frontier network. Alternatively, it is also possible to explicitly define peers using the –bootnodes, in combination with –nodiscover to prevent geth from looking for peers. Note that you have to work on the same Genesis block than the other peers in your group, otherwise all your mined Blocks will be rejected by the consensus rules.

The consequence of what has been said in the previous paragraph is that we can use the same Genesis block for multiple test networks.

{
    "nonce": "0x0000000000000042", 
    "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "difficulty": "0x4000", 
    "alloc": {},
    "coinbase": "0x0000000000000000000000000000000000000000", 
    "timestamp": "0x00", 
    "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 
    "extraData": "Custem Ethereum Genesis Block", 
    "gasLimit": "0xffffffff"
}

 

mixhashA 256-bit hash which proves, combined with the nonce, that a sufficient amount of computation has been carried out on this block: the Proof-of-Work (PoF).

The combination of nonce and mixhash must satisfy a mathematical condition described in the Yellowpaper, 4.3.4. Block Header Validity, (44). It allows to verify that the Block has really been cryptographically mined, thus, from this aspect, is valid.

The value is a reduced representation (using a simple Fowler–Noll–Vo hash function) of the set of values selected from the DAG data file during mining calculation. This selection pick follows the implemented Estah' Hashimoto algorithm, which depends on the given Block header. The applied mixhash is re-determined for each hash operation that a Miner performs while searching for the correct Block nonce (cf. ASIC resistance, high IO). The final Block mixhash is the value leading to the valid Block. The reason why this value is part of the Block descriptor is that it becomes part of the //parentHash// of the next Block. By this, a potential attacker would need correct DAG data files to create illegal Blocks.
nonceA 64-bit hash, which proves, combined with the mix-hash, that a sufficient amount of computation has been carried out on this block: the Proof-of-Work (PoF).

The combination of nonce and mixhash must satisfy a mathematical condition described in the Yellowpaper, 4.3.4. Block Header Validity, (44), and allows to verify that the Block has really been cryptographically mined and thus, from this aspect, is valid.

The nonce is the cryptographically secure mining proof-of-work that proves beyond reasonable doubt that a particular amount of computation has been expended in the determination of this token value. (Yellowpager, 11.5. Mining Proof-of-Work).

The final nonce value is the result of the the mining process iteration, in which the algorithm was able to discover a nonce value that satisfies the Mining Target. The Mining Target is a cryptographically described condition that strongly depends on the applied . Just by using the nonce Proof-of-Work, the validity of a Block can verified very quickly.
difficultyA scalar value corresponding to the difficulty level applied during the nonce discovering of this block. It defines the Mining Target, which can be calculated from the previous block’s difficulty level and the timestamp. The higher the difficulty, the statistically more calculations a Miner must perform to discover a valid block. This value is used to control the Block generation time of a Blockchain, keeping the Block generation frequency within a target range. On the test network, we keep this value low to avoid waiting during tests since the discovery of a valid Block is required to execute a transaction on the Blockchain.
allocAllows to define a list of pre-filled wallets. That's a Ethereum specific functionality to handle the "Ether pre-sale" period. Since we can mine local Ether quickly, we don't use this option.
coinbaseThe 160-bit address to which all rewards (in Ether) collected from the successful mining of this block have been transferred. They are a sum of the mining eward itself and the Contract transaction execution refunds. Often named "beneficiary" in the specifications, sometimes "etherbase" in the online documentation. This can be anything in the Genesis Block since the value is set by the setting of the Miner when a new Block is created.
timestampA scalar value equal to the reasonable output of Unix’ time() function at this block inception.

This mechanism enforces a homeostasis in terms of the time between blocks. A smaller period between the last two blocks results in an increase in the difficulty level and thus additional computation required to find the next valid block. If the period is too large, the difficulty, and expected time to the next block, is reduced.

The timestamp also allows to verify the order of block within the chain (Yellowpaper, 4.3.4. (43)).

Note: Homeostasis is the property of a system in which variables are regulated so that internal conditions remain stable and relatively constant.
parentHashThe Keccak 256-bit hash of the entire parent block’s header (including its nonce and mixhash). Pointer to the parent block, thus effectively building the chain of blocks. In the case of the Genesis block, and only in this case, it's 0.
extraDataAn optional free, but max. 32 byte long space to conserve smart things for ethernity on the Blockchain. :-)
gasLimitA scalar value equal to the current chain-wide limit of Gas expenditure per block. High in our case to avoid being limited by this threshold during tests. Note: this does not indicate that we should not pay attention to the Gas consumption of our Contracts.

Note: The geeky values for nonce and mixhash in the above example are taken from the official Genesis extraction script, as distributed at the Frontier release. They satisfy the Block validity condition described in the specifications.

3) Set-up Procedure

Note: This procedure is just one of multiple variants. You could just start the geth with all parameters at the same time and let it run. Personally, I prefer a separation in order to divide everything in dedicated scripts later on.

(NB. Lines with # are comment and are not to be typed.)

tasha@HOST:~$ # Switch the terminal to the testnet1 user  
tasha@HOST:~$ #   su = substitute user
tasha@HOST:~$ #    - = start a login shell ie. switch to shell environment of the target user

tasha@HOST:~$ su - testnet1
 
testnet1@HOST:~$ # Go to our working directory
testnet1@HOST:~$ cd ~
testnet1@HOST:~$ cd testnet       (# chose your favourite directory)
 
testnet1@HOST ~/testnet $ # Create the Genesis block data file
testnet1@HOST ~/testnet $ # (if you haven't downloaded the file attached to this page)
testnet1@HOST ~/testnet $ nano customgenesis.json

testnet1@HOST ~/testnet $ # ... then copy the above text block into the file and save.

 
testnet1@HOST ~/testnet $ # Invoke the geth client to set-up the Ethereum environment.
testnet1@HOST ~/testnet $ # 
testnet1@HOST ~/testnet $ # If your home directory has not yet an Ethereum blockchain data installed,
testnet1@HOST ~/testnet $ # you should get prompted by geth to accept the Terms of Usage.
testnet1@HOST ~/testnet $ # If this does not happen, please verify your set-up.
testnet1@HOST ~/testnet $ # 
testnet1@HOST ~/testnet $ # You may change the network ID if you have multiple test Blockchains in 
testnet1@HOST ~/testnet $ # your network. By this, you still can use the node discovery mode later.
testnet1@HOST ~/testnet $ #
testnet1@HOST ~/testnet $ # This operation does not mine yet. When it finishes work, type 'exit' or
testnet1@HOST ~/testnet $ # hit CTRL+C to exit the tool.
testnet1@HOST ~/testnet $ # 

testnet1@HOST ~/testnet $ geth --genesis customgenesis.json --networkid 1100 -nodiscover -maxpeers 0  console
 
=======================================
Disclaimer of Liabilites and Warranties
=======================================
 
THE USER EXPRESSLY KNOWS AND AGREES THAT THE USER IS USING THE ETHEREUM PLATFORM AT THE USER’S SOLE
RISK. THE USER REPRESENTS THAT THE USER HAS AN ADEQUATE UNDERSTANDING OF THE RISKS, USAGE AND
INTRICACIES OF CRYPTOGRAPHIC TOKENS AND BLOCKCHAIN-BASED OPEN SOURCE SOFTWARE, ETH PLATFORM AND ETH.
THE USER ACKNOWLEDGES AND AGREES THAT, TO THE FULLEST EXTENT PERMITTED BY ANY APPLICABLE LAW, THE
DISCLAIMERS OF LIABILITY CONTAINED HEREIN APPLY TO ANY AND ALL DAMAGES OR INJURY WHATSOEVER CAUSED
BY OR RELATED TO RISKS OF, USE OF, OR INABILITY TO USE, ETH OR THE ETHEREUM PLATFORM UNDER ANY CAUSE
OR ACTION WHATSOEVER OF ANY KIND IN ANY JURISDICTION, INCLUDING, WITHOUT LIMITATION, ACTIONS FOR
BREACH OF WARRANTY, BREACH OF CONTRACT OR TORT (INCLUDING NEGLIGENCE) AND THAT NEITHER STIFTUNG
ETHEREUM NOR ETHEREUM TEAM SHALL BE LIABLE FOR ANY INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY OR
CONSEQUENTIAL DAMAGES, INCLUDING FOR LOSS OF PROFITS, GOODWILL OR DATA. SOME JURISDICTIONS DO NOT
ALLOW THE EXCLUSION OF CERTAIN WARRANTIES OR THE LIMITATION OR EXCLUSION OF LIABILITY FOR CERTAIN
TYPES OF DAMAGES. THEREFORE, SOME OF THE ABOVE LIMITATIONS IN THIS SECTION MAY NOT APPLY TO A USER.
IN PARTICULAR, NOTHING IN THESE TERMS SHALL AFFECT THE STATUTORY RIGHTS OF ANY USER OR EXCLUDE
INJURY ARISING FROM ANY WILLFUL MISCONDUCT OR FRAUD OF STIFTUNG ETHEREUM.
 
Do you accept this agreement? [y/N] y
 
I0920 08:59:31.695411   10724 flags.go:405] WARNING: No etherbase set and no accounts found as default
I0920 08:59:31.695693   10724 database.go:73] Alloted 16MB cache to /home/testnet1/.ethereum/chaindata
I0920 08:59:31.787327   10724 database.go:73] Alloted 16MB cache to /home/testnet1/.ethereum/dapp
I0920 08:59:31.876773   10724 backend.go:291] Protocol Versions: [61 60], Network Id: 1100
I0920 08:59:31.877152   10724 backend.go:303] Successfully wrote genesis block. New genesis hash = 6e92f8b23bcdfdf34dc813cfaf1d84b71beac80530506b5d63a2df10fe23a660
I0920 08:59:31.877198   10724 backend.go:328] Blockchain DB Version: 3
I0920 08:59:31.877317   10724 chain_manager.go:237] Last block (#0) 6e92f8b23bcdfdf34dc813cfaf1d84b71beac80530506b5d63a2df10fe23a660 TD=16384
I0920 08:59:31.887129   10724 cmd.go:125] Starting Geth/v1.1.0/linux/go1.4.2
I0920 08:59:31.887308   10724 server.go:311] Starting Server
I0920 08:59:31.887480   10724 backend.go:557] Server started
I0920 08:59:31.887528   10724 server.go:552] Listening on [::]:30303
I0920 08:59:31.887985   10724 ipc_unix.go:104] IPC service started (/home/testnet1/.ethereum/geth.ipc)
instance: Geth/v1.1.0/linux/go1.4.2
 datadir: /home/testnet1/.ethereum
coinbase: null
at block: 0 (Thu, 01 Jan 1970 01:00:00 CET)
modules: admin:1.0 db:1.0 debug:1.0 eth:1.0 miner:1.0 net:1.0 personal:1.0 shh:1.0 txpool:1.0 web3:1.0
> exit
I0920 08:59:35.111892   10724 chain_manager.go:459] Chain manager stopped
I0920 08:59:35.111913   10724 handler.go:165] Stopping ethereum protocol handler...
I0920 08:59:35.111933   10724 handler.go:175] Ethereum protocol handler stopped
I0920 08:59:35.111949   10724 transaction_pool.go:138] Transaction pool stopped
I0920 08:59:35.111969   10724 backend.go:686] Automatic pregeneration of ethash DAG OFF (ethash dir: /home/testnet1/.ethash)
I0920 08:59:35.126425   10724 database.go:167] flushed and closed db: /home/testnet1/.ethereum/chaindata
I0920 08:59:35.126590   10724 database.go:167] flushed and closed db: /home/testnet1/.ethereum/dapp
testnet1@HOST ~/testnet $
 

testnet1@HOST ~/testnet $ # Now we need to create an Ethereum account that we used to mine,
testnet1@HOST ~/testnet $ # that will receive mining rewards and that we can use to test contracts
testnet1@HOST ~/testnet $ # and spend Ether.
testnet1@HOST ~/testnet $ # 
testnet1@HOST ~/testnet $ # Without this 'coinbase' set, as indicated by 'coinbase: null' above,
testnet1@HOST ~/testnet $ # geth will refuse to mine. When not specified otherwise in the command line, 
testnet1@HOST ~/testnet $ # geth uses the first account as default account.

testnet1@HOST ~/testnet $ geth account new
 
Your new account is locked with a password. Please give a password. Do not forget this password.
Passphrase: 
Repeat Passphrase: 
Address: {6050679a421c13f6d76ed3cc0f8464ebc930a803}
 
testnet1@HOST ~/testnet $ # 

Mine the local Blockchain

When working with the local Blockchain, we need the run a Miner in order to have our transactions executed and included in the Blockchain. At the same time, we get some free test-ether that we can play with. Note that it makes no sense to keep the miner running when the test network is not used, and it makes no sense neither to use other resources than the CPU for mining. With a Difficulty configured as low as in our custom Genesis block, the miner will find a valid block during each operation.

When starting the miner for the first time, the DAG file is generated. The Blockchain becomes operational for testing as soon as the 5 first blocks are mined and confirmed.

The commands below open various RPC/IPC interfaces to the network, which allows everyone able to connect to this machine to also control our miner and our wallet. It also allows execution from all domains (cf CORS). This is of course a security problem when done on a public network or/and using a real Ethereum wallet. If you wish to open more interfaces, just add the corresponding opcodes, as described in the documentation.

Important to note as well is the command –networkid 1100. This “logically” isolates the local network Ethereum peer-to-peer network from others, especially the public Ethereum networks. Our network has the ID 1100 and all Nodes/Miners wanting to connect to our local network have to specify this ID. -maxpeers is optional and just there to potentially limit “trouble” if ever something goes wrong.

testnet1@HOST ~/testnet $ # Runs the CPU miner:
testnet1@HOST ~/testnet $ # - Mines the local Blockchain and generates new Blocks
testnet1@HOST ~/testnet $ # - Includes our test transactions and executes our test contracts
testnet1@HOST ~/testnet $ # - Generates test-ether
testnet1@HOST ~/testnet $ # - Generates a DAG file when run the first time.
testnet1@HOST ~/testnet $ #
testnet1@HOST ~/testnet $ # Notes:
testnet1@HOST ~/testnet $ # - Change network ID if changed in the previous sections.
testnet1@HOST ~/testnet $ # - SECURITY WARNING: Opens RCP/IPC interfaces!
testnet1@HOST ~/testnet $ 
testnet1@HOST ~/testnet $ geth --mine -rpccorsdomain "*" --ipcapi "admin,eth,miner" --rpcapi "eth,web3" --networkid 1100 -nodiscover -maxpeers 5 --minerthreads 1

I0920 09:21:12.555430   10823 database.go:73] Alloted 16MB cache to /home/testnet1/.ethereum/chaindata
I0920 09:21:12.636374   10823 database.go:73] Alloted 16MB cache to /home/testnet1/.ethereum/dapp
I0920 09:21:12.646307   10823 backend.go:291] Protocol Versions: [61 60], Network Id: 1100
I0920 09:21:12.646503   10823 backend.go:328] Blockchain DB Version: 3
I0920 09:21:12.646767   10823 chain_manager.go:237] Last block (#0) 6e92f8b23bcdfdf34dc813cfaf1d84b71beac80530506b5d63a2df10fe23a660 TD=16384
I0920 09:21:12.654789   10823 cmd.go:125] Starting Geth/v1.1.0/linux/go1.4.2
I0920 09:21:12.655086   10823 server.go:311] Starting Server
I0920 09:21:12.655193   10823 server.go:552] Listening on [::]:30303
I0920 09:21:12.655394   10823 backend.go:640] Automatic pregeneration of ethash DAG ON (ethash dir: /home/testnet1/.ethash)
I0920 09:21:12.655456   10823 backend.go:647] checking DAG (ethash dir: /home/testnet1/.ethash)
I0920 09:21:12.655577   10823 backend.go:557] Server started
I0920 09:21:12.655900   10823 ipc_unix.go:104] IPC service started (/home/testnet1/.ethereum/geth.ipc)
I0920 09:21:12.655950   10823 miner.go:119] Starting mining operation (CPU=1 TOT=1)
I0920 09:21:12.656401   10823 worker.go:540] commit new work on block 1 with 0 txs & 0 uncles. Took 416.9µs
I0920 09:21:12.656481   10823 ethash.go:202] Generating DAG for epoch 0 (0000000000000000000000000000000000000000000000000000000000000000)
I0920 09:21:14.566221   10823 ethash.go:230] Still generating DAG: 0%
I0920 09:21:21.423904   10823 ethash.go:230] Still generating DAG: 1%
I0920 09:21:28.067961   10823 ethash.go:230] Still generating DAG: 2%
I0920 09:21:34.586718   10823 ethash.go:230] Still generating DAG: 3%
:
:
I0920 09:32:00.575130   10823 ethash.go:230] Still generating DAG: 98%
I0920 09:32:07.060124   10823 ethash.go:230] Still generating DAG: 99%
I0920 09:32:13.542035   10823 ethash.go:230] Still generating DAG: 100%
I0920 09:32:13.545446   10823 ethash.go:219] Done generating DAG for epoch 0, it took 11m0.888973073s
I0920 09:32:19.169934   10823 worker.go:322] ??  Mined block (#1 / f6d6142d). Wait 5 blocks for confirmation
I0920 09:32:19.170407   10823 worker.go:540] commit new work on block 2 with 0 txs & 0 uncles. Took 405.197µs
I0920 09:32:19.170776   10823 worker.go:540] commit new work on block 2 with 0 txs & 0 uncles. Took 298.979µs
I0920 09:32:25.413322   10823 worker.go:322] ??  Mined block (#2 / 41832182). Wait 5 blocks for confirmation
I0920 09:32:25.413782   10823 worker.go:540] commit new work on block 3 with 0 txs & 0 uncles. Took 384.003µs
I0920 09:32:25.414165   10823 worker.go:540] commit new work on block 3 with 0 txs & 0 uncles. Took 313.387µs
I0920 09:32:25.839043   10823 worker.go:322] ??  Mined block (#3 / 4f82f814). Wait 5 blocks for confirmation
I0920 09:32:25.839470   10823 worker.go:540] commit new work on block 4 with 0 txs & 0 uncles. Took 367.068µs
I0920 09:32:25.839832   10823 worker.go:540] commit new work on block 4 with 0 txs & 0 uncles. Took 294.022µs
:
:

# Hit CTRL+C to interrupt...

^CI0920 09:32:59.097185   10823 cmd.go:134] Got interrupt, shutting down...
I0920 09:32:59.097329   10823 chain_manager.go:459] Chain manager stopped
I0920 09:32:59.097339   10823 handler.go:165] Stopping ethereum protocol handler...
I0920 09:32:59.097359   10823 handler.go:175] Ethereum protocol handler stopped
I0920 09:32:59.097370   10823 transaction_pool.go:138] Transaction pool stopped
I0920 09:32:59.097383   10823 backend.go:686] Automatic pregeneration of ethash DAG OFF (ethash dir: /home/testnet1/.ethash)
I0920 09:32:59.147738   10823 database.go:167] flushed and closed db: /home/testnet1/.ethereum/chaindata
I0920 09:32:59.147917   10823 database.go:167] flushed and closed db: /home/testnet1/.ethereum/dapp

Using the local Blockchain

Once the local Blockchain is ready, it can be employed using the classic Ethereum client applications. The condition is however, to execute them in the context of the testnet1 user, or to specify the alternative data directory to all tools.

As long as you have the main geth process handling the local Blockchain, running under the same user ID, a simple geth attach (in a different command window) works. (Note: I didn’t verify in the code, or the documentation on IPC. I found this out by testing).

When starting to use the local test network from different workstations, it is indispensable to specify the –networkid 1100. The usage of the Ethereum discovery protocol should be fine on LANs without additional “hops”, but it is also possible to explicitly specify the peer-to-peer “bootstrap” node via –bootnodes and to deactivate the node discovery mode with –nodiscover.

testnet1@ETHER-PI ~/testnet $ geth attach
modules: admin:1.0 eth:1.0 miner:1.0

# How many Ether do I have?
> web3.fromWei(eth.getBalance(eth.coinbase),"ether")
610

 

15 thoughts on “Setup a Local Ethereum Test Blockchain”

    1. “hang” means that the app does not display anything anymore, does not move and is totally blocked? Is that what happens?

  1. I setup the private network as mentioned in the link: http://adeduke.com/2015/08/how-to-create-a-private-ethereum-chain/
    Initially my account has 10 ether. After I start the miner, ethers are automatically added to my account, but I don’t have any pending transaction in my private network. So from where could my miners are getting the ethers?

    Even though, I didn’t instantiate any transactions in my network, I could see the some transaction being recorded in the logs, once I start the miner.

    The log is as follows:
    miner.start()
    I0118 11:59:11.696523 9427 backend.go:584] Automatic pregeneration of ethash DAG ON (ethash dir: /Users/minisha/.ethash)
    I0118 11:59:11.696590 9427 backend.go:591] checking DAG (ethash dir: /Users/minisha/.ethash)
    I0118 11:59:11.696728 9427 miner.go:119] Starting mining operation (CPU=4 TOT=5)
    true
    > I0118 11:59:11.703907 9427 worker.go:570] commit new work on block 1 with 0 txs & 0 uncles. Took 7.109111ms
    I0118 11:59:11.704083 9427 ethash.go:220] Generating DAG for epoch 0 (size 1073739904) (0000000000000000000000000000000000000000000000000000000000000000)
    I0118 11:59:12.698679 9427 ethash.go:237] Done generating DAG for epoch 0, it took 994.61107ms
    I0118 11:59:15.163864 9427 worker.go:349]

    And my genesis block code is as follows:

    {
    “nonce”: “0xdeadbeefdeadbeef”,
    “timestamp”: “0x0”,
    “parentHash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,
    “extraData”: “0x0”,
    “gasLimit”: “0x8000000”,
    “difficulty”: “0x400”,
    “mixhash”: “0x0000000000000000000000000000000000000000000000000000000000000000”,
    “coinbase”: “0x3333333333333333333333333333333333333333”,
    “alloc”: {
    “0xb1316b6662e0dcb02352cc8c4c49c16e81bbdc42”: {
    “balance”: “10000000000000000000”
    }
    }
    }

    1. Hello, sorry for the late answer. Miners are (also) rewarded when their block is integrated in the blockchain. Blocks are added every “blocktime” seconds, even if they are empty (without transaction), and the miner that contributed that block obtains the Ether reward. In contrary to Bitcoin, Miners that are not “first” to find a block (ie. their block is “stale”) also get a small reward. These stale blocks are called Uncles. Long story short: the Ether you see comes from your Miner adding Blocks every X seconds.

  2. That last part, geth attach, is unclear. I mined six blocks using your approach but I get an error when I run geth attach

    geth attach
    Fatal: Unable to attach to geth node – dial unix /home/billmartin/.ethereum/geth.ipc: connect: connection refused

    Do I have to log in with my geth account first?

  3. regarding above post. Never mind. I figured to run geth in one window and geth attach in another window. I see I have 30 ether.

  4. Hi, nice tutorial. One question I had; If you wanted to secure the blockchain i.e. only allow a trusted set of nodes to connect to it how can that be done?

  5. Hey, very nice tutorial! But I am having some issues, when I give geth attach, it says “Fatal :Unable to attach to geth : open \\.\pipe\geth.ipc: The system cannot find the file specified. ” What should I do?

    1. Hi, I’m not sure what the problem here is. ‘Geth’ has evolved a lot in the lasts months. Could you post a question on the ethereum forum?

  6. I just want to say: You are absolutely awesome !
    Your articles and posts about Ethereum and ming is some of the best out there !
    Wish I have stumbled onto your work much, much earlier. It would have saved me some very late nights !

    Thanks again
    Albie

  7. Hi Tasha,

    When I open an Ethereum wallet (Mist), it says the number of peers is 0. Mist “sees” the ethers, but cannot send transactions to my local miner. Do I have to have a minimal number of peers before I can do this?
    Thanks!

    1. Hey,

      I suppose you are using you own local test network and want to use Mist on this network. Disclaimer: I don’t use Mist, so bear with me on the details :)

      When running a local chain, the entire “game” is between the “Blockchain Data” (files) < ==> “geth” (node that ‘runs’ the blockchain) < ==> “Mist” (that uses “geth” to interface the blockchain). As “Mist”, your miner connects to the same “geth” instance to interface with the same Blockchain.

      So in order to have “Mist” accessing the local chain, Mist needs to connect to the “geth” instance running on the node.

      Starting “Mist” starts a bundled “geth” node, whose target you can select in the “Mist” set-up screen. Local networks are not displayed, but you can interface with them by starting “geth” before the wallet. At start-up, you need to point “geth” to the local data (–datadir “….localchain/data/”). This makes your “geth” the node that runs the blockchain and that is used by all local applications to interface with the chain.

      (Source: http://ethereum.stackexchange.com/a/2557/228)

      I hope this helps!

Leave a Reply

Your email address will not be published. Required fields are marked *