区块链2:windows搭建以太坊的私有区块链

一、下载和安装:

    1、下载

链接:https://pan.baidu.com/s/1qYYYYny

密码:47x0

    2、安装:比如安装到 D://work//geth 目录中

        安装完成之后的目录结构

    3、CMD进入终端

        geth -help  (geth -h)

二、创建创世区块

    1、拷贝sspgenesis.json 到 安装目录中 (D://work//geth)

    2、在CMD 终端,进入到安装目录中

        cd D://work//geth

        geth --datadir "D://work//geth//ichain" init sspgenesis.json

    3、启动命令

        geth  --identity "niubit" --rpc --rpcaddr "0.0.0.0" --port 30303 --rpccorsdomain "*" --datadir "cdata"  --networkid 999  --rpcport 9090 console

    4、后续的启动

        geth -datadir "D://work//geth//ichain" console

        geth -datadir "D://work//geth//ichain" console 2>> geth.log(geth -datadir "%cd%\chain" console 2>> geth.log)

    5、geth 和 eth

        geth 命令为服务端命令

        eth 命令为客户端命令

    6、创建账户:

        personal.newAccount()

        输入密码

        确认密码

三、常用命令

    退出:exit

    查询账户:eth.accounts  (eth.accounts[0])

    查询账户余额

    eth.getBalance(user1)

    当前区块

    eth.blockNumber

    开始挖矿 miner.start()

    结束挖矿 miner.stop()

    转账

    eth.sendTransaction({from:user1, to:user2, value:web3.toWei(3, "ether")})

    解锁账号

    personal.unlockAccount(user1, password)

    查看自己节点的信息

    admin.nodeInfo


    添加节点

    admin.addPeer(‘enode://1e3c1727cd3bee9f25edeb5dbb3b880e03e41f8eec99566557f3ee0422734a8fcad17c161aa93d61bdbfb28ed152c143c7eb501db58bc63502a104a84b62d742@192.168.1.101:30303’)

    查看添加新节点的信息

    admin.peers

    #将wei转换为ether

    web3.fromWei(21000000000000, 'ether')

    #检查交易池

    txpool.status

    #查看正在交易的数据

    eth.getBlock("pending",true).transactions

    #获取某个区块的信息

    eth.getBlock(294)

    #gas

    eth.estimateGas({from:eth.accounts[1], to: eth.accounts[2], value:50000000000000})

    eth.gasPrice

你可能感兴趣的:(区块链2:windows搭建以太坊的私有区块链)