以太坊私有节点搭建

我们可以通过搭建以太坊的私有节点,模拟以太坊挖矿、交易、部署运行智能合约,从而达到测试开发的目的。下面具体说明搭建过程:

1. 创建新帐号

    geth --datadir {eth_dir} account new    //其中 eth_dir 是私有节点的数据目录

      //该命令会在 {eth_dir}目录下生成keystore目录,目录下会有相应的帐号文件

2. 创建 genesis.json 文件,保存创世纪块的配置信息

{
"config": {
        "chainId": 1,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {
    "f985f8578206c6d317785cf131682259bf84588f": {"balance": "100000001"}    //红色部分代表帐号,来自上个命令生成的帐号文件的address属性
    },
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x4c4b40",
  "nonce"      : "0x0001000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}

3.初始化创世纪块

geth --datadir {eth_dir}  init  {./genesis.json}    

4. 启动以太坊工作节点

geth --verbosity 6 --datadir e:/eth_dir --networkid 13579 --etherbase f985f8578206c6d317785cf131682259bf84588f 
    --port 30303 --rpcport 8545 --rpcaddr localhost --rpc --rpccorsdomain http://localhost:3000
    --ws --wsorigins "http://localhost:3000" --wsport 8546 --unlock f985f8578206c6d317785cf131682259bf84588f
    --nodiscover --mine --minerthreads 1 --password e:/eth_dir/passwd console 2>>eth_output.log
原文地址:https://www.cnblogs.com/hzhuxin/p/9962493.html