區塊鏈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

?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容