美文网首页
以太坊节点连接

以太坊节点连接

作者: tianlei | 来源:发表于2018-01-15 12:38 被阅读978次

    1.genesis.json

    {
        "config": {
                "chainId": 123456,
                "homesteadBlock": 0,
                "eip155Block": 0,
                "eip158Block": 0
        },
        "nonce": "0x0000000000000042",
        "difficulty": "0x020000",
        "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "coinbase": "0x0000000000000000000000000000000000000000",
        "timestamp": "0x00",
        "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
        "extraData": "0x11bbe8db4e347b4e8c937c1c8370e4b5ed33adb3db69cbdb7a38e1e50b1b82fa",
        "gasLimit": "0x4c4b40",
        "alloc": {}
        }
    

    2.运行节点

    首先进入到私链根目录,如果没有data文件夹和genesis.json请先创建genesis.json文件内容见第一步

    文件目录

    2.1只在第一次初始化的时候运行

    geth --datadir data init genesis.json  
    

    如果出现含有一下内容,说明初始化成功

    INFO [01-15|12:43:09] Writing custom genesis block
    INFO [01-15|12:43:09] Successfully wrote genesis state      database=lightchaindata   hash=611596…424d04
    

    2.2运行节点

    //mac username 更换为自己的用户名称 /Users/username/Library/Ethereum/geth.ipc
    geth --datadir data  --networkid 19890802  console --ipcpath   /Users/username/Library/Ethereum/geth.ipc --rpcapi personal,db,eth,net,web3   --rpc console
    
    //windows
    geth --datadir data  --networkid 19890802  console  --rpcapi personal,db,eth,net,web3   --rpc console
    

    3.连接到183服务器

    admin.addPeer("enode://7cd1b51119f7480a4849cc87a3aa06659833108e6a70c470d02a8967b4385a8dc52fae1488610a2a2002dd89239d7e212c60e90fb86a5964b503fba2a493468b@47.96.161.183:30303")
    

    相关文章

      网友评论

          本文标题:以太坊节点连接

          本文链接:https://www.haomeiwen.com/subject/izmroxtx.html