[Ethereum] Mining in private network not giving ether to coinbase account

coinbasego-ethereumminingprivate-blockchain

I am relatively new to Ethereum. I was trying to set up a private test network. I used the following genesis file:

{
"config": {
"chainId": 15, 
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "20",
"gasLimit": "2100000",
"alloc": {
"7df9a875a174b3bc565e6424a0050ebc1b2d1d82": 
    { "balance": "300000" },
"f41c74c9ae680c1aa78f42e5647a62f353b7bdde": 
    { "balance": "400000" }
}
}

The following commands were used to initialise and start the network:

geth --datadir "C:\Users\Mahe\Desktop\Ethereum\data" init "Path_to_genesis" 
geth --datadir "C:\Users\Mahe\Desktop\Ethereum\data" --nodiscover --networkid 65535 --port 60303 --rpc --rpccorsdomain "*" --rpcapi "web3,eth,personal,miner" console 2>Node2.log

The network started successfully, after which I created a new account and set it as coinbase. eth.coinbase is set and gives the address of the created account. However, there is no increase of ether in the created account upon mining(eth.getBalance(eth.accounts[0]) returns 0). Any help would be appreciated.

Best Answer

I think you need to start mining to get Ether. As described here in the github page you can do it using --mine command line option at the beginning or miner.start() in the console while running.

CPU Mining with Geth

At Frontier, the first release of Ethereum, you'll just need a) a GPU and b) an Ethereum client, Geth. CPU mining will be possible but too inefficient to hold any value.

At the moment, Geth only includes a CPU miner, and the team is testing a GPU miner branch, but this won't be part of Frontier.

The C++ implementation of Ethereum also offers a GPU miner, both as part of Eth (its CLI), AlethZero (its GUI) and EthMiner (the standalone miner).

NOTE: Ensure your blockchain is fully synchronised with the main chain before starting to mine, otherwise you will not be mining on the main chain.

When you start up your ethereum node with geth it is not mining by default. To start it in mining mode, you use the --mine command line option. The -minerthreads parameter can be used to set the number parallel mining threads (defaulting to the total number of processor cores).

geth --mine --minerthreads=4

You can also start and stop CPU mining at runtime using the console. miner.start takes an optional parameter for the number of miner threads.

> miner.start(8)
true
> miner.stop()
true

Based on the discussion had in the comments you need to,

  • properly set a coinbase account and
  • keep the miner started for a sufficient time rather than stopping it quickly

to get Ether into your account.

Related Topic