1

I want to develop a dapp and deploy on geth. I have installed geth and mist wallet. Now, when I am starting miner.start(1) to make some ethers for account. It is showing me null and no ether is getting generated. I have geth running on 1 terminal window, Mist wallet opened and geth console running on 2nd terminal window. I am following a tutorial on youtube and in that miner.start(2) returns true and mining starts within no time. Please help how I can generate ether for my private network.

My genesis.json is

{
  "alloc": {
  "0x0000000000000000000000000000000000000001": {"balance": "111111111"},
  "0x0000000000000000000000000000000000000002": {"balance": "222222222"}
  },
  "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

Please help in how to solve miner.start() issue.

niksmac
  • 9,673
  • 2
  • 40
  • 72
UbuntuCoder
  • 141
  • 1
  • 5
  • https://ethereum.stackexchange.com/questions/743/getting-more-ether-on-a-private-test-net. check this. – Prashant Prabhakar Singh Aug 09 '17 at 06:48
  • @PrashantPrabhakarSingh that question didn't help me. I have added my one of my account in alloc. still it is not showing anything in the ethereum wallet. – UbuntuCoder Aug 09 '17 at 08:59
  • Lower the difficulty level to "0x400", try with miner.start(1) it may take some time to generate the DAG. Also every time you modify the genesis requires a restart geth <other params> removedb & geth <other params> init genesis.json – Ismael Aug 09 '17 at 17:16
  • @Ismael I have lowered the difficulty level to "0x200" and set alloc to my accounts as well as coinbase to one of my account. But the main thing is miner.start(1) is returning me null and is doing nothing. – UbuntuCoder Aug 10 '17 at 04:20
  • Which version of geth are you using? I have 1.6.7 in both windows and linux working as expected. You can try adding --datadir <directory> to point an empty directory to discard any problems with your old data directory. – Ismael Aug 10 '17 at 15:30
  • Which command do you use to start geth? You can try first inside an Ubuntu VM to discard any problem with your computer. I've followed this tutorial without problems https://alanbuxton.wordpress.com/2017/07/19/first-steps-with-ethereum-private-networks-and-smart-contracts-on-ubuntu-16-04/. – Ismael Aug 10 '17 at 15:34
  • @Ismael I have 1.6.6 version in mac. I am using these two commands to run geth "geth --datadir=./chaindata init "/genesis.json" "
    "geth --datadir=./chaindata --port 30309" . After that in another console, I use "geth attach". And after that when I try miner.start(1) , console shows null and does nothing. I will try to follow the tutorial which you have mentioned. If there is something wrong in my approach, please tell
    – UbuntuCoder Aug 11 '17 at 04:56
  • @Ismael what does miner.start(1) return when you execute the same command. null or true ? – UbuntuCoder Aug 11 '17 at 05:28
  • If I execute miner.start(1) in the attached geth it does return null. But in the geth instance it start displaying messages like Updated mining thread, Starting mining operation, Commit new mining work. – Ismael Aug 11 '17 at 18:22
  • @Ismael finally, I can see these messages which you have written. Thank you. Now when I try eth.getBalance(eth.coinbase) It is returning 0. Can you help me on this – UbuntuCoder Aug 16 '17 at 04:44
  • Does eth.coinbase contain a valid address? Also check eth.accounts[0]. But I'd recommend to ask a new question anyway, because people tend to do not look at old questions. You can answer this question with your solution so it can helps other in a similar situation. – Ismael Aug 17 '17 at 04:17
  • @Ismael Sure.. I have set eth.coinbase. Moreover, now I am getting ether as well as blocks in my private blockchain. I will post the solution once I complete the transaction between the 2 accounts. – UbuntuCoder Aug 17 '17 at 04:23
  • @Ismael Can you help me in this? https://ethereum.stackexchange.com/questions/24818/read-function-returning-blank-array-in-geth – UbuntuCoder Aug 25 '17 at 04:06
  • @niksmac Can you help me in this question? https://ethereum.stackexchange.com/questions/24818/read-function-returning-blank-array-in-geth – UbuntuCoder Aug 29 '17 at 04:58

1 Answers1

1

I finally got the answer of my question. After following the steps till genesis.json and making the directory, all we need to do is to make some accounts first. It is required as the 0th which is the 1st account is set as the coinbase automatically. We can set any other account as coinbase also. But it is important because when we mine, there has to be some account which takes the ether. So, after making the account, check eth.coinbase ,it should be same as 0th account.

Then just do miner.start() It will return null where the confusion was. It will return you null but the mining will actually start. It will give you a msg like this

INFO [08-16|10:26:51] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=204.377µs

And after waiting for some time (around 2-3 hours) your coinbase or 0th account will get ether and blocks will get generated.

INFO [08-16|11:32:58] Successfully sealed new block            number=1 hash=6a867b…8d7b13
INFO [08-16|11:32:58]  mined potential block                  number=1 hash=6a867b…8d7b13
INFO [08-16|11:32:59] Commit new mining work                   number=2 txs=0 uncles=0 elapsed=36.597ms

As you can see, it took more than an hour to have some activity. So, have patience and go with it.

I'm sharing this link which I believe is very much helpful. https://alanbuxton.wordpress.com/2017/07/19/first-steps-with-ethereum-private-networks-and-smart-contracts-on-ubuntu-16-04/

After following this link, you can do transactions between 2 accounts. You can deploy smart contracts on geth.

If you have any problem in any of the steps. Feel free to comment or message.

UbuntuCoder
  • 141
  • 1
  • 5