Ubuntu 20.0.4部署 以太坊私有链

1. 安装 geth

wget https://gethstore.blob.core.windows.net/builds/geth-linux-amd64-1.10.16-20356e57.tar.gz
tar -zxvf geth-linux-amd64-1.10.16-20356e57.tar.gz
# 文件夹里边的 geth 可执行文件就事 geth , 可自行添加到环境变量

2. 初始化账户

mkdir data
geth account new --datadir ./data
# 然后输入两次密码就会生成一个账户

3. 准备 period 部署POS的配置

genesis.json

{
    "config": {
      "chainId": 1008,
      "homesteadBlock": 0,
      "eip150Block": 0,
      "eip155Block": 0,
      "eip158Block": 0,
      "byzantiumBlock": 0,
      "constantinopleBlock": 0,
      "petersburgBlock": 0,
      "ethash": {}
    },
    "difficulty": "1",
    "gasLimit": "8000000",
    "alloc": {
      "7df9a875a174b3bc565e6424a0050ebc1b2d1d82": { "balance": "300000" },
      "f41c74c9ae680c1aa78f42e5647a62f353b7bdde": { "balance": "400000" }
    }
  }

4. 初始化geth数据库

geth init --datadir data genesis.json

5. 启动 Geth 节点

geth --datadir ./data --networkid 1008  --http --http.addr 0.0.0.0 --http.vhosts "*" --http.api "db,net,eth,web3,personal" --http.corsdomain "*" --snapshot=false --mine --miner.threads 1 --allow-insecure-unlock  console 2> 1.log

6. 启动成功

可以在控制台输入

> eth.accounts // 获取 eth 上的账户
> eth.getBalance(eth.accounts[0]) // 获取初始账户的余额.
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值