블록체인
[Ethereum] genesis 초기화 시 cannot unmarshal 에러 해결법
멍개.
2022. 8. 28. 07:12
안녕하세요 멍개입니다.
geth를 이용하여 네트워크 구축 시 genesis 파일을 만들게 됩니다.
{
"config": {
"chainId": 1234,
"homesteadBlock": 0,
"eip150Block": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"berlinBlock": 0,
"londonBlock": 0,
"ethash": {}
},
"alloc": {
"56aE1237F0D3E2F21683Bd04402092E26f469813":{"balance":"30000000000000000000000"},
"55e2d8BF452e1E7D70eb375B527fd38B281B00cF":{"balance":"30000000000000000000000" }
},
"coinbase": "0x56aE1237F0D3E2F21683Bd04402092E26f469813",
"difficulty": "0x20000",
"extraData": "",
"gasLimit": "0x2fefd8",
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
해당 내용으로 genesis.json으로 만들었다면 다음과 같이 genesis 초기화를 시킬 수 있습니다.
$ geth --datadir $PWD init genesis.json
Fatal: invalid genesis file: math/big: cannot unmarshal "\"0000000000000000000000000000000000000000000000000000000000000000\"" into a *big.Int
해당 에러는 0x000000이 Int 타입이 아니라 발생하는 에러입니다.
{
"config": {
"chainId": 1234,
"homesteadBlock": 0,
"eip150Block": 0,
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"istanbulBlock": 0,
"ethash": {}
},
"alloc": {
"56aE1237F0D3E2F21683Bd04402092E26f469813":{"balance":"30000000000000000000000"},
"55e2d8BF452e1E7D70eb375B527fd38B281B00cF":{"balance":"30000000000000000000000" }
},
"coinbase": "0x56aE1237F0D3E2F21683Bd04402092E26f469813",
"difficulty": "0x20000",
"extraData": "",
"gasLimit": "0x2fefd8",
"nonce": "0x0000000000000042",
"mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp": "0x00"
}
정상적으로 초기화되는 모습을 확인할 수 있습니다.