OSDN Git Service

change 2node-test path and remove bytom
[bytom/bytom.git] / README.md
1 Bytom
2 =====
3
4 [![AGPL v3](https://img.shields.io/badge/license-AGPL%20v3-brightgreen.svg)](./LICENSE)
5
6 ## Table of Contents
7 <!-- vim-markdown-toc GFM -->
8
9 * [What is Bytom?](#what-is-bytom)
10 * [Build from source](#build-from-source)
11   * [Requirements](#requirements)
12   * [Installation](#installation)
13     * [Get the source code](#get-the-source-code)
14     * [Build](#build)
15 * [Example](#example)
16   * [Create and launch a single node](#create-and-launch-a-single-node)
17     * [Asset issuance test](#asset-issuance-test)
18   * [Set up a wallet and manage the key](#set-up-a-wallet-and-manage-the-key)
19   * [Multiple node](#multiple-node)
20 * [Contributing](#contributing)
21 * [License](#license)
22
23 <!-- vim-markdown-toc -->
24
25 ## What is Bytom?
26
27 Bytom is software designed to operate and connect to highly scalable blockchain networks confirming to the Bytom Blockchain Protocol, which allows partipicants to define, issue and transfer digitial assets on a multi-asset shared ledger. Please refer to the [White Paper](https://github.com/Bytom/wiki/blob/master/White-Paper/%E6%AF%94%E5%8E%9F%E9%93%BE%E6%8A%80%E6%9C%AF%E7%99%BD%E7%9A%AE%E4%B9%A6-%E8%8B%B1%E6%96%87%E7%89%88.md) for more details.
28
29 In the current state `bytom` is able to:
30
31 - Issue assets
32 - Manage account as well as asset
33
34 ## Build from source
35
36 ### Requirements
37
38 - [Go](https://golang.org/doc/install) version 1.8 or higher, with `$GOPATH` set to your preferred directory
39
40 ### Installation
41
42 Ensure Go with the supported version is installed properly:
43
44 ```bash
45 $ go version
46 $ go env GOROOT GOPATH
47 ```
48
49 #### Get the source code
50
51 ``` bash
52 $ git clone https://github.com/Bytom/bytom $GOPATH/src/github.com/bytom
53 ```
54
55 #### Build
56
57 - Bytomd
58
59 ``` bash
60 $ cd $GOPATH/src/github.com/bytom
61 $ make install
62 $ cd ./cmd/bytomd
63 $ go build
64 ```
65
66 - Bytomcli
67
68 ```go
69 $ cd $GOPATH/src/github.com/bytom/cmd/bytomcli
70 $ go build
71 ```
72
73 ## Example
74
75 Currently, bytom is still in active development and a ton of work needs to be done, but we also provide the following content for these eager to do something with `bytom`.
76
77 ### Create and launch a single node
78
79 When successfully building the project, the `bytom` and `bytomcli` binary should be present in `cmd/bytom/bytom` and `cmd/bytomcli/bytomcli`, respectively. The next step is to initialize the node:
80
81 ```bash
82 $ cd ./cmd/bytomd
83 $ ./bytomd init --home ./.bytom
84 ```
85
86 After that, you'll see `.bytom` generated in current directory, then launch the single node:
87
88 ``` bash
89 $ ./bytomd node --home ./.bytom
90 ```
91
92 #### Asset issuance test
93
94 Given the `bytom` node is running, the general workflow is as follows:
95
96 - create an account
97 - create an asset
98 - create/sign/submit a transaction to transfer an asset
99 - query the assets on-chain
100
101 Create an account named `alice`:
102
103 ```bash
104 $ ./bytomcli create-account alice
105 xprv:<alice_account_private_key>
106 responses:{acc04K9MCFBG0A04 alice [0xc4200966e0] 1 0xc4204be220}
107 account id:<alice_account_id>
108 ```
109
110 Create an asset named `gold`:
111
112 ```bash
113 $ ./bytomcli create-asset gold
114 xprv:<gold_asset_private_key>
115 xpub:[98 55 100 48 102 100 53 101 54 55 55 49 48 52 97 100 50 100 51 51 98 49 56 98 98 100 55 55 50 51 98 53 102 51 101 97 56 55 49 52 48 53 57 54 50 56 55 48 49 97 50 99 97 100 101 51 51 102 100 100 97 53 56 51 49 54 97 50 57 54 101 49 102 100 48 102 53 57 99 55 50 49 53 98 50 54 55 102 50 52 102 52 54 50 48 101 51 48 102 55 99 51 50 56 49 102 97 52 99 55 97 53 102 50 57 97 100 53 51 100 56 100 55 56 50 50 98 98]
116 responses:[{{4131000809721133708 15036469059929217352 9712753415038655527 16992088508821480533} gold [118 107 170 32 152 106 231 249 212 15 215 121 94 191 102 23 231 61 38 211 121 176 221 199 48 173 145 207 243 201 82 0 215 2 72 243 81 81 173 105 108 0 192] [0xc420020850] 1 0xc4204c1960 0xc4204c1980 true}]
117 asset id:<gold_asset_id>
118 ```
119
120 Now we can transafer `<gold_asset_amount>` gold to `alice` using a single command `sub-create-issue-tx`:
121
122 ```bash
123 $ ./bytomcli sub-create-issue-tx <alice_account_id> <gold_asset_id> <asset_private_key> <gold_asset_amount>
124 To build transaction:
125 -----------tpl:{version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078  [0xc4204c9060 0xc4204c91e0] true false}
126 ----------tpl transaction:version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078 
127 ----------btm inputs:&{1 [123 125] asset_id:</* proto: integer overflow */ >amount:1470000000000000000  [] []}
128 ----------issue inputs:&{1 [] 0xc4204c4120 [] []}
129 xprv_asset:a89d5d5fa68af8ca8408d405db180bc5b2652d7f34bca753531861be3c1cbb6216a296e1fd0f59c7215b267f24f4620e30f7c3281fa4c7a5f29ad53d8d7822bb
130 sign tpl:{version:1 serialized_size:314 result_ids:<71c3b949750c887e466422007cdd1a6a9f3449e3bacd43307e361e84d76fe37b> data:<130994550772:/* unknown wire type 7 */ 1642:/* unknown wire type 7 */ 10:17681930801800169409 159728:7652 9:4897805654558278394 9:/* unexpected EOF */ >min_time_ms:1506587706078 max_time_ms:1506588006078  [0xc4204c9060 0xc4204c91e0] true false}
131 sign tpl's SigningInstructions:&{0 [0xc420010670]}
132 SigningInstructions's SignatureWitnesses:&{0 [] [32 254 83 225 251 124 27 13 126 32 0 93 132 151 197 166 125 64 222 168 154 133 219 122 187 130 169 176 160 166 8 49 145 174 135] []}
133 submit transaction:[map[id:cc4313fbae424bb945029adef193154f34de324316036e510bcc751d0013ccb7]]
134 ```
135
136 Query the assets on-chain:
137 ```bash
138 $ ./bytomcli list-balances
139 0 ----- map[<gold_asset_id>:<gold_asset_amount>]
140 ```
141
142 ### Set up a wallet and manage the key
143
144 If you have started a bytom node, then you can create an account via `create-key password`, which will generate a `keystore` directory containing the keys under the project directory.
145
146 ```bash
147 $ ./bytomcli create-key account_name password   # Create an account named account_name using password
148 $ ./bytomcli delete-key password pubkey         # Delete account pubkey
149 $ ./bytomcli reset-password oldpassword newpassword pubkey  # Update password
150 ```
151
152 ### Multiple node
153
154 Get the submodule depenency for the two-node test:
155
156 ```bash
157 $ git submodule update --init --recursive
158 ```
159
160 Create the first node `bytomd0` and second node `bytomd1`:
161
162 ```bash
163 $ cd cmd/bytomd/2node-test
164 $ ./test.sh bytomd0  # Start the first node
165 $ ./test.sh bytomd1  # Start the second node
166 ```
167
168 Then we have two nodes:
169
170 ```bash
171 $ curl -X POST --data '{"jsonrpc":"2.0", "method": "net_info", "params":[], "id":"67"}' http://127.0.0.1:46657
172 ```
173
174 If everything goes well, we'll see the following response:
175
176 ```bash
177 {
178   "jsonrpc": "2.0",
179   "id": "67",
180   "result": {
181     "listening": true,
182     "listeners": [
183       "Listener(@192.168.199.178:3332)"
184     ],
185     "peers": [
186       {
187         "node_info": {
188           "pub_key": "03571A5CE8B35E95E2357DB2823E9EB76EB42D5CCC5F8E68315388832878C011",
189           "moniker": "anonymous",
190           "network": "chain0",
191           "remote_addr": "127.0.0.1:51058",
192           "listen_addr": "192.168.199.178:3333",
193           "version": "0.1.0",
194           "other": [
195             "wire_version=0.6.2",
196             "p2p_version=0.5.0",
197             "rpc_addr=tcp://0.0.0.0:46658"
198           ]
199         },
200 ......
201 ```
202
203 ## Contributing
204
205 Thank you for considering to help out with the source code! Any contributions are highly appreciated, and we are grateful for even the smallest of fixes!
206
207 If you run into an issue, feel free to [file one](https://github.com/Bytom/bytom/issues/) in this repository. We are glad to help!
208
209 ## License
210
211 [AGPL v3](./LICENSE)