ubuntu环境搭建私有链
时间: 2023-11-29 15:46:45 浏览: 169
geth 搭建 私有链节点
为在Ubuntu上搭建私有链,您需要遵循以下步骤:
1.安装geth客户端
```shell
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
```
2.创建创世块genesis.json文件
```shell
{
"config": {
"chainId": 15,
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"difficulty": "200",
"gasLimit": "2100000",
"alloc": {
"0x0000000000000000000000000000000000000001": {"balance": "111111111"},
"0x0000000000000000000000000000000000000002": {"balance": "222222222"}
}
}
```
3.初始化私有链
```shell
geth --datadir /path/to/chaindata init /path/to/genesis.json
```
4.启动私有链
```shell
geth --datadir /path/to/chaindata --networkid 15 console
```
5.创建账户
```shell
personal.newAccount()
```
6.启动挖矿
```shell
miner.start()
```
7.停止挖矿
```shell
miner.stop()
```
阅读全文