4

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.

  • did you start mining? – Achala Dissanayake Jul 25 '18 at 16:31
  • Yes, I did. It didn't increase the balance. – raghav Jul 25 '18 at 16:51
2

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.

  • I just have one account currently and eth.coinbase gives the address of that account(which is eth.accounts[0]). The coinbase is getting set to that account successfully. – raghav Jul 25 '18 at 17:00
  • eth.blockNumber returns 0 too – raghav Jul 25 '18 at 17:06
  • It's been around 4 minutes after miner.start and blocknumber is still zero. eth.hashrate is still returning 0. – raghav Jul 25 '18 at 17:17
-1

The issue was that the blocks were not getting mined. The first block was mined after 20 minutes of miner.start(), after which the block generation speed shortened. The balance in the coinbase account started increasing when blocks were mined successfully.

  • when a block is mined you get a message on the console – Nulik Jul 25 '18 at 20:49
  • No, we don't. However, we get a message when a contract gets mined. – raghav Jul 26 '18 at 6:14
  • well, then increase verbosity level – Nulik Jul 26 '18 at 13:15
  • @Nulik how to increate verbosity level? – Ahmed Numaan Apr 3 at 3:24
  • add -verbosity 6 to commandline – Nulik Apr 3 at 16:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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