Ubuntu 20.0.4部署 以太坊私有链

Ubuntu 20.0.4部署 以太坊私有链,第1张

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]) // 获取初始账户的余额.

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/925716.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-16
下一篇 2022-05-16

发表评论

登录后才能评论

评论列表(0条)

保存