3

I have created a private blockchain as follows:

geth --rpc --nat none --dev --ipcpath "geth.ipc" init genesis.json

Then ran the following commands to enter the geth console and query the balance of an account:

geth
geth attach ipc:\\.\pipe\geth.ipc
eth.getBalance("0x4666f1ee6a79121e1cc0f98fa020c6be13052c8b")

However, this brings back '0' as the balance of the account, though in my genesis.json I give it an allocation of 300000. Adding 0x before the account in genesis.json or in the eth.getBalance command makes no difference.

My genesis.json file referenced here is as follows:

{
    "config": {
        "chainId": 15,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
    "difficulty": "0x400",
    "gasLimit": "2100000",
    "alloc": {
        "4666f1ee6a79121e1cc0f98fa020c6be13052c8b": { "balance": "300000" },
        "f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
    }
}
  • Did you reset your blockchain after modifying your genesis.json? I've tried your genesis.json and it worked correctly with geth 1.6.5. – Ismael Jul 2 '17 at 4:36
3

I believe the issue was I needed to create an account first with geth account new then put that account in the genesis.json file.

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.