mac 搭建geth私链

下载geth客户端

  1. 直接去官网下载Go Ethereum
  2. geth 可执行文件移动到/usr/local/bin
  3. 创建文件夹 xxx/local_ethereum_blockchain
  4. 创建genesis.json文件
  5. {
      "config": {
        "chainId": 1111111,
        "homesteadBlock": 0,
        "eip150Block": 0,
        "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "eip155Block": 0,
        "eip158Block": 0,
        "byzantiumBlock": 0,
        "constantinopleBlock": 0,
        "petersburgBlock": 0,
        "istanbulBlock": 0,
        "ethash": {}
      },
      "nonce": "0x0",
      "timestamp": "0x5ddf8f3e",
      "extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "gasLimit": "0x47b760",
      "difficulty": "0x00002",
      "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
      "coinbase": "0x0000000000000000000000000000000000000000",
      "alloc": {},
      "number": "0x0",
      "gasUsed": "0x0",
      "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000"
    }
    
  6. 初始化节点 geth --datadir xxx/local_ethereum_blockchain/node init dcpc/local_ethereum_blockchain/genesis.json
  7. 启动创始节点 nohup geth --datadir xxx/local_ethereum_blockchain/node --nodiscover --maxpeers 2000 --ws --ws.addr 0.0.0.0 --ws.port 9900 --ws.api db,eth,net,web3 --http --http.port 8080 --http.addr 0.0.0.0 --http.corsdomain * --port 8000 --http.api db,eth,net,web3 --networkid 1369 --allow-insecure-unlock &  
  8. 进入客户端 geth attach xxx/local_ethereum_blockchain/node/geth.ipc
  9. 得到初始节点信息  admin.nodeInfo
  10. 创建账号

         personal.newAccount()   

        Passphrase: 输入账号密码

        Repeat passphrase: 再次输入账号密码

        //挖矿

        miner.start(1)

  1. 启动其他的节点 nohup geth --datadir xxx/local_ethereum_blockchain/node --nodiscover --networkid 1369 --port 8000 &
  2. //链接节点 需要填初始节点信息                                   admin.addPeer("enode://b7b65c949b51491c204dd8d62889b991c70940636717cf733482373a017e94167283cd2215357d0f5a3adfb77f48b9634f45022ba9ec07cfa68f0ec87c600d18@127.0.0.1:8000?discport=0")
  3. 转帐      eth.sendTransaction({from:eth.accounts[0],to:"xxxxxx", value: web3.toWei(3, "ether")})

 

​​​​​​​

 

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值