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.

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

2 Answers 2

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.

3
  • 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
    Commented Jul 25, 2018 at 17:00
  • eth.blockNumber returns 0 too
    – raghav
    Commented Jul 25, 2018 at 17:06
  • It's been around 4 minutes after miner.start and blocknumber is still zero. eth.hashrate is still returning 0.
    – raghav
    Commented Jul 25, 2018 at 17:17
0

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.

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

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.