zoukankan      html  css  js  c++  java
  • 以太坊私有链

    用到的端口 TCP 30303 8545

    sudo apt-get update
    sudo apt-get installsoftware-properties-common
    sudo add-apt-repository -y ppa:ethereum/ethereum
    sudo add-apt-repository -y ppa:ethereum/ethereum-dev
    sudo apt-get update
    sudo apt-get install ethereum

    apt-get install ethminer GPU挖矿工具

    piccgenesis.json

    {
    "config": {
    "chainId": 15,
    "homesteadBlock": 0,
    "eip155Block": 0,
    "eip158Block": 0
    },
    "coinbase" : "0x0000000000000000000000000000000000000000",
    "difficulty" : "0x40000",
    "extraData" : "",
    "gasLimit" : "0xffffffff",
    "nonce" : "0x0000000000000000",
    "mixhash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
    "timestamp" : "0x00",
    "alloc": { }
    }


    basepath=$(cd `dirname $0`; pwd)
    获取当前的目录
    geth --datadir "$basepath/chain" init piccgenesis.json
    创建数据存放地址并初始化创世块
    geth --identity "etherum" --rpc --rpccorsdomain "*" --datadir "$basepath/chain" --port "30303" --rpcapi "db,eth,net,web3" --networkid 18 console --nodiscover

    RPC

    geth.exe --datadir D:Ethereum --rpc --rpccorsdomain "*" --rpcapi "db,eth,net,web3" console --rpcaddr 0.0.0.0

    json rpc 

    {"jsonrpc":"2.0","method":"eth_blockNumber","params":["0x5325FA1961a5ba119724956B03610C221eF40295", "latest"],"id":1}

    创建新账号
    personal.newAccount()
    或者 personal.newAccount("123456")
     
    查看节点信息
    admin.nodeInfo
     
    挖矿
    开始挖矿 miner.start(1)
    停止挖矿 miner.stop()
     
    查看当前矿工账号
    eth.coinbase 默认为第一个账户
     
    修改矿工账号
    miner.setEtherbase(eth.accounts[1])
     
    查看账户信息
    eth.accounts[0]
     
    查看账户余额
    eth.getBalance(eth.accounts[0])
    或者 web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")
     
    解锁账号
    personal.unlockAccount(eth.accounts[0])
    使用账户资金前都需要先解锁账号
     
    转账eth.sendTransaction({from:eth.accounts[0],to:"0x587e57a516730381958f86703b1f8e970ff445d9",value:web3.toWei(3,"ether")})
    使用 txpool.status 可以看到交易状态
     
    查看区块数据
    eth.blockNumber
    eth.getTransaction("0x0c59f431068937cbe9e230483bc79f59bd7146edc8ff5ec37fea6710adcab825")
    eth.getBlock(1) 通过区块号查看区块
  • 相关阅读:
    Linux | Ubuntu 生成二维码实例
    Ubuntu 添加wine安装程序的快捷方式
    mysql 中文 排序
    Received disconnect from **.**).***.*** port 22:2: Too many authentication failures 解决办法
    php 数组与URL相互转换
    ssh `快捷键` 快速链接服务器
    使用ssh生成密钥并保存在不同的文件(ubuntu)
    H5移动端调试 weinre
    简单的 图片下载 php
    linux 系统生成二维码
  • 原文地址:https://www.cnblogs.com/ahuo/p/8137910.html
Copyright © 2011-2022 走看看