0

Here is my genesis.json file

{
    "config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
    },
    "gasLimit": "21000000",
    "difficulty": "20000",
    "alloc": {
      "6e8f98fa53bbb9ab8dad40af34b767172206099f":{"balance":500000000}
     }
}    

But I got the following error while init command in the genesis file

Fatal: invalid genesis file: json: cannot unmarshal number into Go struct field Genesis.alloc of type *math.HexOrDecimal256

1

Balance quantities have to go as strings, because they are big.Int numbers and are parsed from a string as input. Strings are used because no 64bit integer capabale of holding amounts with 18 zeros. So change this:

"6e8f98fa53bbb9ab8dad40af34b767172206099f":{"balance":500000000}

to this:

"6e8f98fa53bbb9ab8dad40af34b767172206099f":{"balance":"500000000"}

Also, you allocated 500 pico Ethers, you won't be able to transfer 1 Ether in your tests. To allocate 1 Ether you would need to add 18 zeros in the balance.

  • Do you have answer for this ethereum.stackexchange.com/questions/44861/… – iam batman Apr 5 '18 at 14:47
  • @iambatman ,yeah, you allocated 500 picoethers and gas price is measured in Gweis, it is 3 zeros more. – Nulik Apr 5 '18 at 14:50
  • I can't understand it – iam batman Apr 5 '18 at 14:51
  • @iambatman , allocate a balance 500 + 18 zeros, and it is going to work. – Nulik Apr 5 '18 at 14:52
  • You mean the gasLimit? – iam batman Apr 5 '18 at 14:53
0

Try with this version

{
    "config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
    },
    "gasLimit": "21000000",
    "difficulty": "20000",
    "alloc": {
      "6e8f98fa53bbb9ab8dad40af34b767172206099f":{"balance":"500000000"}
     }
}   

I just added quotation marks around the number "500000000"

  • Is it possible to add multiple jensis.json?? – iam batman Apr 5 '18 at 13:28
  • Why do you need multiple genesis blocks? – cleanunicorn Apr 5 '18 at 15:02

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.