以太坊联盟链怎么搭建?

请先 登录 后评论

1 个回答

Tiny熊
  擅长:智能合约,以太坊
  1. 准备创始文件(init.json)
    大概是这样:
{
"config": {
"chainId": 1234,
"homesteadBlock": 0,
"eip150Block": 0,
"eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"eip155Block": 0,
"eip158Block": 0,
"byzantiumBlock": 0,
"constantinopleBlock": 0,
"petersburgBlock": 0,
"ethash": {}
},
"nonce": "0x0",
"timestamp": "0x5dcba32c",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x97b760",
"difficulty": "0x200000",
"mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"coinbase": "0x0000000000000000000000000000000000000000",
"alloc": {
"你的初始账号 1": {
"balance": "0x200000000000000000"
},
"你的初始账号 2": {
"balance": "0x200000000000000000"
},
"你的初始账号 3: {
"balance": "0x200000000000000000"
}
},
"number": "0x0",
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
}
  1. 初始化世纪块
geth --datadir data init init.json
  1. 启动节点,开始挖矿
geth --datadir data --networkid 1234 --unlock '挖矿账号' --password 'pwd.txt' --rpc --mine --allow-insecure-unlock console

这时候,找到enode, 以供其他节点链接:

enode://xxx@peerIP:30303

使用:

miner.start() 开启挖矿

  1. 其他节点加入
geth --datadir data --syncmode 'full' --networkid 1234 --bootnodes 'enode:// xxxx@ip:30303'
--unlock '挖矿账号2' --password 'pwd.txt' --mine

这样就搭建好了两个节点,其他的节点同理。

请先 登录 后评论
  • 1 关注
  • 0 收藏,255 浏览
  • jamesdev 提出于 2021-06-19 08:46