網(wǎng)友推薦躏吊,首次使用markdown文本編輯器
明說(shuō)(01):從0開(kāi)始搭建區(qū)塊鏈開(kāi)發(fā)環(huán)境
安裝以太坊客戶(hù)端
測(cè)試用使用ubuntu 16.04 LTS
結(jié)論:軟件版本更新很快,跟教程相比運(yùn)行模式也有了不少變化~~不過(guò)很順利的完成了帐萎。
https://github.com/ethereum/go-ethereum/wiki/Installation-Instructions-for-Ubuntu
Installing from PPA
sudo apt-get install software-properties-common
sudo add-apt-repository -y ppa:ethereum/ethereum
sudo apt-get update
sudo apt-get install ethereum
查看幫助
$ geth -h
查看賬戶(hù)清單
$ geth account list
啟動(dòng)geth服務(wù)
$ geth --datadir "~ethdev" --dev
新sh連接geth控制臺(tái)
$ geth --dev console 2>>file_to_log_output
顯示賬戶(hù)
eth.accounts
//默認(rèn)有一個(gè)賬戶(hù)
創(chuàng)建兩個(gè)賬戶(hù)
personal.newAccount('123456')
personal.newAccount('123456')
用兩個(gè)變量代替兩個(gè)用戶(hù)
user1 = eth.accounts[0]
user2 = eth.accounts[1]
//查看余額
eth.getBalance(user1)
eth.getBalance(user2)
查看當(dāng)前區(qū)塊
eth.blockNumber
//返回0 初始區(qū)塊比伏,或者就是沒(méi)有。
新sh打開(kāi)日志
$ tail -f file_to_log_output
設(shè)置默認(rèn)賬戶(hù)
miner.setEtherbase(eth.coinbase)
開(kāi)始挖礦
miner.start()
null //返回值 此時(shí)已經(jīng)啟動(dòng)疆导,但沒(méi)有新交易的情況下赁项,待機(jī)。
eth.sendTransaction({from:user1,to:user2,value:web3.toWei(3,"ether")})
//從賬戶(hù)1,轉(zhuǎn)賬3以太幣給賬戶(hù)2
//日志顯示
INFO [03-01|20:53:35] Submitted transaction fullhash=0x28f6f6837f42d229170d41cfa838cce4fe9f74cb5600dfba4c3898d0afc8b49c recipient=0x2258eD686A46780B1c38AB59B468229b76309317
INFO [03-01|20:53:35] Commit new mining work number=1 txs=1 uncles=0 elapsed=584.898μs
INFO [03-01|20:53:35] Successfully sealed new block number=1 hash=d8e409…6c3211
INFO [03-01|20:53:35] ?? mined potential block number=1 hash=d8e409…6c3211
INFO [03-01|20:53:35] Commit new mining work number=2 txs=0 uncles=0 elapsed=568.863μs
WARN [03-01|20:53:35] Block sealing failed err="waiting for transactions"
//新塊行程了~~
//看一下 兩個(gè)賬戶(hù)的余額澈段。
//發(fā)現(xiàn)轉(zhuǎn)賬完成悠菜,交易被確認(rèn)。
關(guān)閉挖礦
miner.stop()
//再次轉(zhuǎn)賬
eth.sendTransaction({from:user1,to:user2,value:web3.toWei(3,"ether")})
//從賬戶(hù)1,轉(zhuǎn)賬3以太幣給賬戶(hù)2
查詢(xún)user2余額败富,未變化悔醋。
再次開(kāi)始挖礦
miner.start()
null //返回值 ,user2余額改變~
eth.blockNumber
日志.png
//2 已經(jīng)寫(xiě)入到第二個(gè)區(qū)塊兽叮。
附圖