bottos 安裝和使用
環境搭建
- 下載大於1.11版本的golang
- 配置GOPATH
- 將程式碼拷貝到$GOPATH/src/github.com目錄下
- 進入到程式碼目錄執行:
$go build
- 在程式碼根目錄會生產一個bottos的可執行檔案
- 進入到bcli目錄
$cd bcli
- 編譯bcli
$go build
- 這樣會在bcli目錄下生產一個bcli的可執行檔案
節點啟動
-
通過對程式碼的編譯,會得到
bottos
和bcli
這2個可執行檔案,bottos
是用於啟動節點的,bcli
通過restful API和節點進行通訊的命令列工具,它的功能包括,檢視區塊資料,建立帳戶,發交易等 -
配置檔案:
config.toml
和genesis.toml
config.toml
:
# Configuration for Bottos Node [Node]# 鏈資料的儲存目錄 DataDir = "./datadir" [Rest]# Restful API Server的監聽埠 RESTPort = 8689 RESTHost = "localhost" [P2P] P2PPort = 9868 P2PServAddr = "192.168.0.20" PeerList = [] [Delegate] Prate = 0 Solo = true [Delegate.SignKey]# 節點用來簽名和驗證的公鑰和私鑰 PrivateKey = "b799ef616830cd7b8599ae7958fbee56d4c8168ffd5421a16025a398b8a4be45" PublicKey = "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f" [Plugin] [Plugin.MongoDB] URL = "mongodb://bottos:[email protected]:27017/bottos" [Plugin.Wallet] WalletDir = "" WalletRESTPort = 6869 WalletRESTHost = "localhost" [Log] Config = "./corelog.xml"
genesis.toml
:和chainID內容有關,不同的內容將產生不同的ChainID
# Initial configuration for the Genesis Node GenesisTime = "2018-08-01T12:00:00" # 合約帳戶bottos驗證簽名所用的公鑰 GenesisKey = "0454f1c2223d553aa6ee53ea1ccea8b7bf78b8ca99f3ff622a3bb3e62dedc712089033d6091d77296547bc071022ca2838c9e86dec29667cf740e5c9e654b6127f"
- 啟動創世節點:
$ bottos --delegate bottos --enable-wallet
-
bcli
命令:
NAME: Bottos bcli tool - a tool that makes user communicate with bottos blockchain USAGE: bcli [global options] command [command options] [arguments...] VERSION: 0.0.1 COMMANDS: getinfoget chain information getblockget block information gettableget table information accountcreate or get account transferfor user transfering bto transactionget or push transactions contractget or deploy contract p2pfor p2p connection delegatefor delegate operations walletFor wallet operations genesisfor genesis node operations help, hShows a list of commands or help for one command GLOBAL OPTIONS: --servaddr value(default: "127.0.0.1:8689") --help, -hshow help --version, -vprint the version
建立錢包
- 當創世節點起來之後,需要先用bottos帳戶的私鑰來建立一個叫做bottos的錢包:
$ ./bcli wallet create --account bottos
按照提示輸入錢包命令和以及帳戶的私鑰b799ef616830cd7b8599ae7958fbee56d4c8168ffd5421a16025a398b8a4be45
- 檢視帳戶的餘額:
$ ./bcli account get --username bottos
建立帳戶
- 建立帳戶之前,需要為帳戶生成公鑰匙和私鑰:
$ ./bcli wallet generatekey
public_key: 040b73ef7a3095089499818a9fd6b4a03f1c0a0d2dddcc2d8b87b6d9ba729dd9364e508ef8381d2e69f3f05d981267f145e707e5a1eaa9ab90579ea523475cb2d4private_key: b2b504852287be2e5e9359d99fa20c7103a96557634fdd5a067500e10bd3d1b9
-
解鎖bottos帳戶的錢包:
bottos需要引薦人來建立帳戶,這裡的引薦人帳戶就是
bottos
,首先解鎖bottos
帳戶的錢包:
$ ./bcli wallet unlock --account bottos
- 建立lisa帳戶:
./bcli account create --username lisa --pubkey 040b73ef7a3095089499818a9fd6b4a03f1c0a0d2dddcc2d8b87b6d9ba729dd9364e508ef8381d2e69f3f05d981267f145e707e5a1eaa9ab90579ea523475cb2d4
轉賬
新建立的帳戶餘額為0:
$ ./bcli account get --username lisa
Account: lisaBalance: 0.00000000 BTO
檢視區塊資訊
檢視最新區塊
$./bcli getblock