OSDN Git Service

move request handle methods to API struct (#470)
[bytom/bytom.git] / README.md
1 Bytom
2 =====
3 [![Build Status](https://travis-ci.org/Bytom/bytom.svg)](https://travis-ci.org/Bytom/bytom)
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   * [Initialize](#initialize)
17   * [launch](#launch)
18     * [Dashboard](#dashboard)
19   * [Create key](#create-key)
20   * [Create account](#create-account)
21     * [Multi-signature account](#multi-signature-account)
22   * [Create asset](#create-asset)
23     * [Multi-signature asset](#multi-signature-asset)
24   * [Sending transaction](#sending-transaction)
25     * [Issue](#issue)
26       * [`build-transaction`](#build-transaction)
27       * [`sign-submit-transaction`](#sign-submit-transaction)
28     * [Spend](#spend)
29       * [`create-account-receiver`](#create-account-receiver)
30       * [`build-transaction`](#build-transaction-1)
31       * [`sign-submit-transaction`](#sign-submit-transaction-1)
32     * [Transfer BTM](#transfer-btm)
33 * [Running Bytom in Docker](#running-bytom-in-docker)
34 * [Contributing](#contributing)
35 * [License](#license)
36
37 <!-- vim-markdown-toc -->
38
39 ## What is Bytom?
40
41 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.
42
43 In the current state `bytom` is able to:
44
45 - Manage key, account as well as asset
46 - Send transactions, i.e., issue, spend and retire asset
47
48 ## Build from source
49
50 ### Requirements
51
52 - [Go](https://golang.org/doc/install) version 1.8 or higher, with `$GOPATH` set to your preferred directory
53
54 ### Installation
55
56 Ensure Go with the supported version is installed properly:
57
58 ```bash
59 $ go version
60 $ go env GOROOT GOPATH
61 ```
62
63 #### Get the source code
64
65 ``` bash
66 $ git clone https://github.com/Bytom/bytom $GOPATH/src/github.com/bytom
67 ```
68
69 #### Build
70
71 ``` bash
72 $ cd $GOPATH/src/github.com/bytom
73 $ make bytomd    # build bytomd
74 $ make bytomcli  # build bytomcli
75 ```
76
77 When successfully building the project, the `bytom` and `bytomcli` binary should be present in `cmd/bytomd` and `cmd/bytomcli` directory, respectively.
78
79 ## Example
80
81 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`. This section won't cover all the commands of `bytomd` and `bytomcli` at length, for more information, please the help of every command, e.g., `bytomcli help`.
82
83 ### Initialize
84
85 First of all, initialize the node:
86
87 ```bash
88 $ cd ./cmd/bytomd
89 $ ./bytomd init --chain_id testnet
90 ```
91
92 There are two options for the flag `--chain_id`:
93
94 - `testnet`: connect to the testnet.
95 - `mainnet`: standalone mode.
96
97 After that, you'll see `.bytomd` generated in current directory, then launch the node.
98
99 ### launch
100
101 ``` bash
102 $ ./bytomd node --mining
103 ```
104
105 available flags for `bytomd node`:
106
107 ```
108       --auth.disable                Disable rpc access authenticate
109       --mining                      Enable mining
110       --p2p.dial_timeout int        Set dial timeout (default 3)
111       --p2p.handshake_timeout int   Set handshake timeout (default 30)
112       --p2p.laddr string            Node listen address.
113       --p2p.max_num_peers int       Set max num peers (default 50)
114       --p2p.pex                     Enable Peer-Exchange
115       --p2p.seeds string            Comma delimited host:port seed nodes
116       --p2p.skip_upnp               Skip UPNP configuration
117       --prof_laddr string           Use http to profile bytomd programs
118       --wallet.disable              Disable wallet
119       --web.closed                  Lanch web browser or not
120 ```
121
122 Given the `bytomd` node is running, the general workflow is as follows:
123
124 - create key, then you can create account and asset.
125 - send transaction, i.e., build, sign and submit transaction.
126 - query all kinds of information, let's say, avaliable key, account, key, balances, transactions, etc.
127
128 #### Dashboard
129
130 Access the dashboard:
131
132 ```bash
133 $ open http://localhost:9888/
134 ```
135
136 ### Create key
137
138 You can create a key with the following command:
139
140 ```bash
141 $ ./bytomcli create-key alice 123
142 {
143   "alias": "alice",
144   "file": "/Users/xlc/go/src/github.com/bytom/cmd/bytomd/.bytomd/keystore/UTC--2018-01-02T07-40-49.900440000Z--b6700ba3-befd-4750-9e58-df91eba15e25",
145   "xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
146 }
147 ```
148
149 list the keys:
150
151 ```bash
152 $ ./bytomcli list-keys
153 ```
154
155 ### Create account
156
157 Create an account named `alice`:
158
159 ```bash
160 $ ./bytomcli create-account alice 674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb
161 {
162   "alias": "alice",
163   "id": "08FTNE7000A02",
164   "keys": [
165     {
166       "account_derivation_path": [
167         "010100000000000000"
168       ],
169       "account_xpub": "f78fa93f009b7baba1b42dca21d06a7902c41ce5fd8f16db625ca41b95a60116cb3bf87c7a098fad9172db5e7481cd4225bb6032b56a310462677fd030243e48",
170       "root_xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
171     }
172   ],
173   "quorum": 1,
174   "tags": null
175 }
176 ```
177
178 Check out the new created account:
179
180 ```bash
181 $ ./bytomcli list-accounts
182 ```
183
184 #### Multi-signature account
185
186 ```bash
187 $ ./bytomcli list-keys
188 0 :
189 {
190   "alias": "alice",
191   "file": "/Users/xlc/go/src/github.com/bytom/cmd/bytomd/.bytomd/keystore/UTC--2018-01-02T07-40-49.900440000Z--b6700ba3-befd-4750-9e58-df91eba15e25",
192   "xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
193 }
194 1 :
195 {
196   "alias": "bob",
197   "file": "/Users/xlc/go/src/github.com/bytom/cmd/bytomd/.bytomd/keystore/UTC--2018-01-02T07-41-35.458581000Z--7115fa1c-a5cd-4374-a747-75d038c402a9",
198   "xpub": "db0abf717c37fb01cb89d06a01d087f24a15d07e99d297b3c02642c46166e2103a7525ec85a2c8050a02b5864fd295ee933c09ca341b296a55e0f804ecb9d9a3"
199 }
200 ```
201
202 ```bash
203 $ ./bytomcli create-account multi_account 674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb db0abf717c37fb01cb89d06a01d087f24a15d07e99d297b3c02642c46166e2103a7525ec85a2c8050a02b5864fd295ee933c09ca341b296a55e0f804ecb9d9a3 -q 2
204 {
205   "alias": "multi_account",
206   "id": "08FR9JDE00A02",
207   "keys": [
208     {
209       "account_derivation_path": [
210         "010100000000000000"
211       ],
212       "account_xpub": "f78fa93f009b7baba1b42dca21d06a7902c41ce5fd8f16db625ca41b95a60116cb3bf87c7a098fad9172db5e7481cd4225bb6032b56a310462677fd030243e48",
213       "root_xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
214     },
215     {
216       "account_derivation_path": [
217         "010100000000000000"
218       ],
219       "account_xpub": "b29be450d0b5b1e233bfa61cc4312c64287a9179d2981510c660fcb4e978fbb8a1d4e4c00882f77b492733e477c19dc2d617ff34216821106078c05ef888c274",
220       "root_xpub": "db0abf717c37fb01cb89d06a01d087f24a15d07e99d297b3c02642c46166e2103a7525ec85a2c8050a02b5864fd295ee933c09ca341b296a55e0f804ecb9d9a3"
221     }
222   ],
223   "quorum": 2,
224   "tags": null
225 }
226 ```
227
228 ### Create asset
229
230 Create an asset named `gold`:
231
232 ```bash
233 $ ./bytomcli create-asset gold 674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb
234 {
235   "alias": "gold",
236   "definition": {},
237   "id": "ff34b6aea66cbd13bfaf918294e0d45fe5ac89854875aadcabb54d92bffebb27",
238   "issuance_program": "766baa200677273bad4aecb9fb90f99d41dda6bb233a138e1a6ad4aeb334241171c5df075151ad696c00c0",
239   "keys": [
240     {
241       "asset_derivation_path": [
242         "000200000000000000"
243       ],
244       "asset_pubkey": "0677273bad4aecb9fb90f99d41dda6bb233a138e1a6ad4aeb334241171c5df07df57895f7e9c2adb909db2299dd061e60b365c0d008a1a2a14b97f56f19642d7",
245       "root_xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
246     }
247   ],
248   "quorum": 1,
249   "tags": {}
250 }
251 ```
252
253 Check out the new created asset:
254
255 ```bash
256 $ ./bytomcli list-assets
257 ```
258
259 #### Multi-signature asset
260
261 ```bash
262 $ ./bytomcli create-asset silver 674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb db0abf717c37fb01cb89d06a01d087f24a15d07e99d297b3c02642c46166e2103a7525ec85a2c8050a02b5864fd295ee933c09ca341b296a55e0f804ecb9d9a3
263 {
264   "alias": "silver",
265   "definition": {},
266   "id": "6465c855881d2add50769242c0e85e4c9ef5ba8b258e6933cb41fcbb17a88b26",
267   "issuance_program": "766baa207a40f1fa20149154b0c4092f151685cdf5a6bec93a8d5c9b00299730476436c6206b4bb7ee5bf3d4ab4a0c625d3dd36b42fbe21e3f3e6f972a6b0590de022960b55152ad696c00c0",
268   "keys": [
269     {
270       "asset_derivation_path": [
271         "000300000000000000"
272       ],
273       "asset_pubkey": "7a40f1fa20149154b0c4092f151685cdf5a6bec93a8d5c9b00299730476436c65434ac760f1b3ee35776e50ff13503079981c16263c2eaa4d3548b7cd936b533",
274       "root_xpub": "674b0d709c5c2f6eb49e5f205c4393e91f1fa745ff62954b67be546925480af57f12a20b2f963a489a71c61b40d5fa08e8c522c8f2d49eaa1213dcb0a4350afb"
275     },
276     {
277       "asset_derivation_path": [
278         "000300000000000000"
279       ],
280       "asset_pubkey": "6b4bb7ee5bf3d4ab4a0c625d3dd36b42fbe21e3f3e6f972a6b0590de022960b5e70f2162d1a5314d140139da7947680289ad961e25266d5631b0de3732a547c3",
281       "root_xpub": "db0abf717c37fb01cb89d06a01d087f24a15d07e99d297b3c02642c46166e2103a7525ec85a2c8050a02b5864fd295ee933c09ca341b296a55e0f804ecb9d9a3"
282     }
283   ],
284   "quorum": 1,
285   "tags": {}
286 }
287 ```
288
289 ### Sending transaction
290
291 Every asset-related action is trigger via sending a transaction, which requires two steps to complete, i.e., `build-transaction` and `sign-subit-transaction`. Don't forget to enable `--mining`.
292
293 #### Issue
294
295 ##### `build-transaction`
296
297 Let's say, issue 10000 gold to alice:
298
299 ```bash
300 $ ./bytomcli build-transaction -t issue alice gold 10000 --alias
301 Template Type: issue
302 {"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019c01019901fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000130cd016ea069766baa2074615605ef8fd37176bb5a75ec3d51d080a2e3a5441e84e255a339ea9ee117805151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100012c00088fccd0ad39658582ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e004f64eaa1cae4cf14f775251c5eb786376d2cf218e488dcea79826b9ce56d0a000000012b766baa20279bdb8c0925d3bbf27f3262e40567d176ade2a64ee0201217651f278a4133405151ad696c00c000020153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa2017a127adf137d75730fa7098028204ea04e20a6ceb415961a6d0def86bc1015d5151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e012b766baa201f7c723946d2a49af4e069b8df25c98d347d9e720e440a32131c07f7aecf930a5151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","4d00000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["000300000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}
303 ```
304
305 The response of `build-transaction` will be used in the following `sign-submit-transaction` command.
306
307 ##### `sign-submit-transaction`
308
309 ```bash
310 $ ./bytomcli sign-submit-transaction '{"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019c01019901fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000130cd016ea069766baa2074615605ef8fd37176bb5a75ec3d51d080a2e3a5441e84e255a339ea9ee117805151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100012c00088fccd0ad39658582ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e004f64eaa1cae4cf14f775251c5eb786376d2cf218e488dcea79826b9ce56d0a000000012b766baa20279bdb8c0925d3bbf27f3262e40567d176ade2a64ee0201217651f278a4133405151ad696c00c000020153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa2017a127adf137d75730fa7098028204ea04e20a6ceb415961a6d0def86bc1015d5151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e012b766baa201f7c723946d2a49af4e069b8df25c98d347d9e720e440a32131c07f7aecf930a5151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","4d00000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["000300000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}'
311 {
312   "txid": "69eb0c8f7622c350e0b253a55bfbdc2ec06a396ca488ea34a104696c6cf9adda"
313 }
314 ```
315
316 When the transaction is on-chain, query the balances:
317
318 ```bash
319 # alice should have 10000 gold now
320 $ ./bytomcli list-balances
321 0 :
322 {
323   "account_alias": "alice",
324   "account_id": "08FU3M22G0A02",
325   "amount": 10000,
326   "asset_alias": "gold",
327   "asset_id": "ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60"
328 }
329 1 :
330 {
331   "account_alias": "alice",
332   "account_id": "08FU3M22G0A02",
333   "amount": 135408000000000,
334   "asset_alias": "btm",
335   "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
336 }
337 ```
338
339 #### Spend
340
341 Alice pays Bob `<payment_amount>`, e.g., 1000, `gold`:
342
343 ##### `create-account-receiver`
344
345 Before you transfer an asset to another account, you have to know his `control_program`. This means the receiver needs to send you his `control_program` first.
346
347 ```bash
348 $ ./bytomcli create-account-receiver bob
349 {
350   "control_program": "766baa20510e0df72e4e01363fdb07d57b8417a19c6517aad8cd6129f495c52188c246f25151ad696c00c0",
351   "expires_at": "2018-02-01T17:55:10.895099+08:00"
352 }
353 ```
354
355 ##### `build-transaction`
356
357 ```bash
358 # ./bytomcli build-transaction -t spend <sender_account> <asset> <amount> --alias -r <receiver_control_program>
359 $ ./bytomcli build-transaction -t spend alice gold 1000 --alias -r 766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0
360 Template Type: spend
361 {"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd029301a069766baa2033400ee7b1c93955b4c6d9532141e1bca263c3f546f409b1b75984f2fe8a1ba05151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a0001000193010190011fd6fe88a17024f66671e32147fb42c6f8a8f48e7c3af1f7ff79df4d80388bf1ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e01012b766baa201f7c723946d2a49af4e069b8df25c98d347d9e720e440a32131c07f7aecf930a5151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100030153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa2018c27de38474915cd491bedd21625506629d1d09437536932f697d62663034e05151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60a846012b766baa202b39e0425fab029c4dfa48dea8e17aa0a89eae22c1fe357d015b233d5facd0e05151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60e807012b766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","7501000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","6500000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}
362 ```
363
364 ##### `sign-submit-transaction`
365
366 ```bash
367 $ ./bytomcli sign-submit-transaction '{"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd029301a069766baa2033400ee7b1c93955b4c6d9532141e1bca263c3f546f409b1b75984f2fe8a1ba05151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a0001000193010190011fd6fe88a17024f66671e32147fb42c6f8a8f48e7c3af1f7ff79df4d80388bf1ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60904e01012b766baa201f7c723946d2a49af4e069b8df25c98d347d9e720e440a32131c07f7aecf930a5151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100030153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa2018c27de38474915cd491bedd21625506629d1d09437536932f697d62663034e05151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60a846012b766baa202b39e0425fab029c4dfa48dea8e17aa0a89eae22c1fe357d015b233d5facd0e05151ad696c00c00000014fab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60e807012b766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","7501000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","6500000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}'
368
369
370 {
371   "txid": "a07a2289682d66de2affd7d2aa5bb4420171a2c4edb91d6bada3021af2214872"
372 }
373 ```
374
375 ```bash
376 $./bytomcli list-balances
377 0 :
378 {
379   "account_alias": "alice",
380   "account_id": "08FU3M22G0A02",
381   "amount": 9000,
382   "asset_alias": "gold",
383   "asset_id": "ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60"
384 }
385 1 :
386 {
387   "account_alias": "alice",
388   "account_id": "08FU3M22G0A02",
389   "amount": 310752000000000,
390   "asset_alias": "btm",
391   "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
392 }
393 2 :
394 {
395   "account_alias": "bob",
396   "account_id": "08FU3U04G0A04",
397   "amount": 1000,
398   "asset_alias": "gold",
399   "asset_id": "ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60"
400 }
401 ```
402
403 #### Transfer BTM
404
405 ```bash
406 # ./bytomcli build-transaction -t spend <sender_account> <asset> <amount> --alias -r <receiver_control_program>
407 $ ./bytomcli build-transaction -t spend alice btm 100000000000 --alias -r 766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0
408 Template Type: spend
409 {"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd02d601a069766baa20b06f9f698226dd2ba4e6d9db2d32db68ce3c9b2a35ad5b5570d2159e01d394af5151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd024801a069766baa2068ea529208b33a5294ee96f7ee0ce43609addd7a89f1b4c0ed1ded25841948d15151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100030153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa20c37b4dfcabed2ef74fb05122f10729629c15b71914d151730f933e5a4d4a271d5151ad696c00c000000153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80f0d586a00f012b766baa206e58e27b81bef8c5c993491859ee35572515ad048db8147146ed590ac95c1daa5151ad696c00c000000153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80d0dbc3f402012b766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","ba01000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","2901000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}
410 ```
411
412 ```bash
413 $ ./bytomcli sign-submit-transaction '{"allow_additional_actions":false,"local":true,"raw_transaction":"07010002019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd02d601a069766baa20b06f9f698226dd2ba4e6d9db2d32db68ce3c9b2a35ad5b5570d2159e01d394af5151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100019d01019a01fb77ab11fafc5cf0446d552724aed272b71cfc7ac7d032d2b1de8890e482d0beffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80c0b1ca9412000131cd024801a069766baa2068ea529208b33a5294ee96f7ee0ce43609addd7a89f1b4c0ed1ded25841948d15151ad696c00c0a7ffc6f8bf1ed76651c14756a061d662f580ff4de43b49fa82d80a4b80f8434a000100030153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80e6ecc09412012b766baa20c37b4dfcabed2ef74fb05122f10729629c15b71914d151730f933e5a4d4a271d5151ad696c00c000000153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80f0d586a00f012b766baa206e58e27b81bef8c5c993491859ee35572515ad048db8147146ed590ac95c1daa5151ad696c00c000000153ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80d0dbc3f402012b766baa2012ba2491f96011afe9ad1ad6423887b1f2b904e5e8185cdb47d14fb2f7aa19615151ad696c00c0000000","signing_instructions":[{"position":0,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","ba01000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]},{"position":1,"witness_components":[{"keys":[{"derivation_path":["010100000000000000","2901000000000000"],"xpub":"f6f2a78fa8242bf09d073af8c0272272d4b53b3f8469ec2906fe9eae513bd7236653f4227aec2bafc6a301a35dda53e824ae7d4f7db25f83d4666d6e3e30628f"}],"quorum":1,"signatures":null,"type":"signature"}]}]}'
414
415
416 {
417   "txid": "91a265de33ffd709bb7135bd6c7a0e4e487e771d553a07f0b5513185ee79d3e0"
418 }
419 ```
420
421 ```bash
422 $ ./bytomcli list-balances
423 0 :
424 {
425   "account_alias": "alice",
426   "account_id": "08FU3M22G0A02",
427   "amount": 9000,
428   "asset_alias": "gold",
429   "asset_id": "ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60"
430 }
431 1 :
432 {
433   "account_alias": "alice",
434   "account_id": "08FU3M22G0A02",
435   "amount": 530924000000000,
436   "asset_alias": "btm",
437   "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
438 }
439 2 :
440 {
441   "account_alias": "bob",
442   "account_id": "08FU3U04G0A04",
443   "amount": 1000,
444   "asset_alias": "gold",
445   "asset_id": "ab9df804775507462b17cdcdf101feb2ab4fc049092e8557a3a70a67cc2f0d60"
446 }
447 3 :
448 {
449   "account_alias": "bob",
450   "account_id": "08FU3U04G0A04",
451   "amount": 100000000000,
452   "asset_alias": "btm",
453   "asset_id": "ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"
454 }
455 ```
456
457 ## Running Bytom in Docker
458
459 Ensure your [Docker](https://www.docker.com/) version is 17.05 or higher.
460
461 ```bash
462 $ docker build -t bytom .
463 ```
464
465 ## Contributing
466
467 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!
468
469 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!
470
471 ## License
472
473 [AGPL v3](./LICENSE)