环境搭建
- 下载大于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:bottos@127.0.0.1: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:
getinfo get chain information
getblock get block information
gettable get table information
account create or get account
transfer for user transfering bto
transaction get or push transactions
contract get or deploy contract
p2p for p2p connection
delegate for delegate operations
wallet For wallet operations
genesis for genesis node operations
help, h Shows a list of commands or help for one command
GLOBAL OPTIONS:
--servaddr value (default: "127.0.0.1:8689")
--help, -h show help
--version, -v print the version
创建钱包
- 当创世节点起来之后,需要先用bottos帐户的私钥来创建一个叫做bottos的钱包:
$ ./bcli wallet create --account bottos
按照提示输入钱包命令和以及帐户的私钥b799ef616830cd7b8599ae7958fbee56d4c8168ffd5421a16025a398b8a4be45
- 查看帐户的余额:
$ ./bcli account get --username bottos
创建帐户
- 创建帐户之前,需要为帐户生成公钥匙和私钥:
$ ./bcli wallet generatekey
public_key: 040b73ef7a3095089499818a9fd6b4a03f1c0a0d2dddcc2d8b87b6d9ba729dd9364e508ef8381d2e69f3f05d981267f145e707e5a1eaa9ab90579ea523475cb2d4
private_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: lisa
Balance: 0.00000000 BTO
查看区块信息
查看最新区块
$./bcli getblock
有疑问加站长微信联系(非本文作者)