区块链热度回升,以太坊区块链搭建

日期:2019-09-17编辑作者:区块链

图片 1

'hash': '6cf99d59ee667dd56cdc34c5b4f5349fdc2377ea9b715c27d1a9d2ba17796636',

增加节点

先是要领会本身的节点音讯,在Geth命令行界面下输入指令,注意分寸写

admin.nodeInfo

显示结果为:

> admin.nodeInfo
{
  enode: "enode://5231f4677b0576292a6d7cd11890218ae2f84336338a4ce7b08e296aa3b9007c8dc728bf26b2e10a3de9afb4d5272ab13e86030a1e7db42474d6577aad174d09@[::]:30303?discport=0",
  id: "5231f4677b0576292a6d7cd11890218ae2f84336338a4ce7b08e296aa3b9007c8dc728bf26b2e10a3de9afb4d5272ab13e86030a1e7db42474d6577aad174d09",
  ip: "::",
  listenAddr: "[::]:30303",
  name: "Geth/v1.8.4-stable-2423ae01/linux-amd64/go1.10",
  ports: {
    discovery: 0,
    listener: 30303
  },
  protocols: {
    eth: {
      config: {
        chainId: 10,
        eip150Hash: "0x0000000000000000000000000000000000000000000000000000000000000000",
        eip155Block: 0,
        eip158Block: 0,
        homesteadBlock: 0
      },
      difficulty: 131072,
      genesis: "0x5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0",
      head: "0x5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0",
      network: 1
    }
  }
}

其中

 enode: "enode://5231f4677b0576292a6d7cd11890218ae2f84336338a4ce7b08e296aa3b9007c8dc728bf26b2e10a3de9afb4d5272ab13e86030a1e7db42474d6577aad174d09@[::]:30303?discport=0"

正是和谐节点的音信,注意要把“0.0.0.0“换到你和谐的IP。将以此新闻发送给别的节点,在其他节点的命令行中输入:

admin.addPeer("enode://5231f4677b0576292a6d7cd11890218ae2f84336338a4ce7b08e296aa3b9007c8dc728bf26b2e10a3de9afb4d5272ab13e86030a1e7db42474d6577aad174d09@192.168.1.121:30303?discport=0")

一经增多职业有成,输入admin.peers会显示出新加上的节点。

> admin.peers
[{
    caps: ["eth/63"],
    id: "5231f4677b0576292a6d7cd11890218ae2f84336338a4ce7b08e296aa3b9007c8dc728bf26b2e10a3de9afb4d5272ab13e86030a1e7db42474d6577aad174d09",
    name: "Geth/v1.8.4-stable-2423ae01/linux-amd64/go1.10",
    network: {
      inbound: false,
      localAddress: "192.168.1.112:42702",
      remoteAddress: "192.168.1.121:30303",
      static: true,
      trusted: false
    },
    protocols: {
      eth: {
        difficulty: 131072,
        head: "0x5e1fc79cb4ffa4739177b5408045cd5d51c6cf766133f23f7cd72ee1f8d790e0",
        version: 63
      }
    }
}]
> 

以太坊的热度自7月首始重操旧业,原因一方面是大众对区块链才干的鲜明,另一方面是拘押政策把区块链公司重新拉回对技艺自己的思维,对实业落地的布署。

....:

出殡交易

解锁账户

> personal.unlockAccount(eth.accounts[0])


Unlock account 0x20869f8cb579e7712f60167d3d153d3f038960c9
Passphrase: 
true

出殡交易

> eth.sendTransaction({from: "0x20869f8cb579e7712f60167d3d153d3f038960c9", to: "0x25df465d9d9060423ce46137ca25aa5a10fd9a2f", gas:31000, 'gasPrice': web3.toWei(300, 'gwei'), "value": "1"})
"0xe4ecfa81d367d2906e87a0f45b5bb90a0424f58bbd74d896ef217f3d5f132533"

这会儿交易已经交付到区块链,再次回到了交易的hash,但还未被管理,要使交易被管理,必须求挖矿。

贸易成功后再对方账户上抽出

> web3.fromWei(web3.eth.getBalance(eth.accounts[0]))
5.006300000000000001

据链塔智库,前段时间,以太坊上的DApp数据达7七千克个,累计交易笔数为3.0036603亿,累计交易金额越过59亿ETH。以太坊的共计顾客已经超先生过3587万人,日均活跃人数多达20万人。

'startgas': 90000,

翻开帐户余额

翻开帐户余额的议程如下:

> web3.eth.getBalance("0x6426ea256ba1d45e966c9aabc0268594093251c4")
1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+77

以太币最小的单位是wei(19个0)

历次记一长串的地点很麻烦,咱们得以透过安装变量来acc0表示帐户1

> acc0 = web3.eth.accounts[0]

"0x6426ea256ba1d45e966c9aabc0268594093251c4"

翻开格式化的以太币

web3.fromWei(web3.eth.getBalance(acc0), 'ether')
1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+59

因为geth javascript console是基于javascript的,所以也能够创立js函数,查看全体帐户余额

> function checkAllBalances() {
      var totalBal = 0;
      for (var acctNum in eth.accounts) {
         var acct = eth.accounts[acctNum];
         var acctBal = web3.fromWei(eth.getBalance(acct), "ether");
          totalBal += parseFloat(acctBal);
          console.log("  eth.accounts[" + acctNum + "]: t" + acct + " tbalance: " + acctBal + " ether");
      }
      console.log("  Total balance: " + totalBal + " ether");
  };

> checkAllBalances()
  eth.accounts[0]:  0x6426ea256ba1d45e966c9aabc0268594093251c4  balance: 1.15792089237316195423570985008687907853269984665640564039457584007913129639927e+59 ether
  eth.accounts[1]:  0x9e8e4b905e054575a7495a6822545da82f197b13  balance: 0 ether
  Total balance: 1.157920892373162e+59 ether

> 

一经命令很多,可以保存到贰个剧本里,使用命令载入脚本:loadScript('/path/script/here.js')

5.2 pyethapp调节台的中坚命令

伊始挖矿和休憩挖矿

挖矿实施以下命令:

 miner.start()

推行今后,通过刚才查看日志的不二等秘书技tail -f eth_output.log,能够看到类似上边包车型地铁日志,因为唯有发送交易才会自行挖矿,所以会显得如下消息。

INFO [04-19|16:30:08] Commit new mining work                   number=1 txs=0 uncles=0 elapsed=175.12µs
INFO [04-19|16:30:16] Generating DAG in progress               epoch=0 percentage=0 elapsed=6.662s
INFO [04-19|16:30:23] Generating DAG in progress               epoch=0 percentage=1 elapsed=12.780s
INFO [04-19|16:30:29] Generating DAG in progress               epoch=0 percentage=2 elapsed=19.418s
INFO [04-19|16:30:35] Generating DAG in progress               epoch=0 percentage=3 elapsed=24.970s

亟需在开辟意况下,能力扩充挖矿,修改上述命令为:

geth   --datadir "./chaindev"   --nodiscover    console 2>>eth_output.log  --dev --dev.period 1

挖矿实施以下命令:

 miner.start()

出现如下音信代表开头挖矿了

INFO [04-19|16:57:28] Successfully sealed new block            number=1 hash=eb3609…3747ef
INFO [04-19|16:57:28] 
		

本文由云顶娱乐发布于区块链,转载请注明出处:区块链热度回升,以太坊区块链搭建

关键词:

厦大设立区块链研商为主,区块链推动了红客行

三是以绿色发展理念为指导,引导数字经济健康发展; 【区块链促进了黑客行业,黑客又促使区块链行业更加健康安...

详细>>

电子小票是区块链技艺的老将应用,又一区块链

原标题:尼科西亚开出首张区块链电子收据 ,又一区块链应用场景落地 二零一八年6月十一日,布拉迪斯拉发国贸旋...

详细>>

IPO前夜危机爆发,淡马锡正式否认参与比特大陆

根据淡马锡在8月30日发布的官方声明,新加坡投资公司淡马锡已正式否认参与比特大陆的首次公开募股(IPO)投资。...

详细>>

IPO前夜危机爆发,淡马锡正式否认参与比特大陆

根据淡马锡在8月30日发布的官方声明,新加坡投资公司淡马锡已正式否认参与比特大陆的首次公开募股(IPO)投资。...

详细>>