搭建以太坊私链(基于geth客户端),创始区块配置,以分配初始以太币,启动geth参数。
更多区块链技术与应用分类:
使用geth客户端搭建私链,操作过程如下。
1.生成账户
geth account new
输入密码
生成keystore文件
(默认路径为C:\Users\Administrator.DESKTOP-WANGHAO\AppData\Roaming\Ethereum)
2.将上述keystore文件复制到自己数据目录data0下
3.创始区块配置并将生成的账户填入alloc字段中,以分配初始以太币,如下配置。
{
"config": {
"chainId": 1818,
"homesteadBlock": 1,
"eip150Block": 2,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 3,
"eip158Block": 3,
"byzantiumBlock": 4,
"clique": {
"period": 8,
"epoch": 30000
}
},
"nonce": "0x0",
"timestamp": "0x5bf8c0f7",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000e578252579e5f43fe124fe1d8236f0e5250c11970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x247b760",
"difficulty": "0x1",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"6e11589dd3372eab20dd4dfa2abc274ff1e109a4": {
"balance": "0x4000000000000000000000000000000000000000000000000000000000000000"
},
"c7f216bbeb04204cad94e58a3846ea3c4747095f": {
"balance": "0x4000000000000000000000000000000000000000000000000000000000000000"
},
"dc9abe9819ce6c411df3281a2033826f4af3ad7b": {
"balance": "0x4000000000000000000000000000000000000000000000000000000000000000"
},
"e578252579e5f43fe124fe1d8236f0e5250c1197": {
"balance": "0x4000000000000000000000000000000000000000000000000000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
4.将每个账户对应的密码文件(以回车换行)放入data0同级目录,存为pwd。
注意:
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000e578252579e5f43fe124fe1d8236f0e5250c11970000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
挖矿者的账户的keystore一定要有。
5.初始化geth
geth --datadir data0 init Genesis.json
6.启动geth
geth --networkid 1818 --datadir "./data0" --rpc -rpcaddr="0.0.0.0" --rpcport 7545 --rpcapi "web3,personal,admin,db,net,eth,miner,rpc,txpool,clique" --ws -wsaddr="0.0.0.0" --wsport 8546 --wsapi "web3,personal,admin,db,net,eth,miner,rpc,txpool,clique" --wsorigins "*" --unlock 0,1,2,3 --password pwd --targetgaslimit 0x247b760 --nodiscover --gcmode archive console
原文链接:使用geth搭建以太坊私链详细步骤