OSDN Git Service

update
[bytom/shuttle.git] / README.md
1 Shuttle
2 ========
3
4 [![MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](./LICENSE)
5
6 - [1 Background](#1-background)
7 - [2 Install](#2-install)
8   - [2.1 Requirements](#21-requirements)
9   - [2.2 Install bytom node](#22-install-bytom-node)
10   - [2.3 Build from source code](#23-build-from-source-code)
11 - [3 Usage](#3-usage)
12   - [3.1 Swap assets in bytom or vapor](#31-swap-assets-in-bytom-or-vapor)
13   - [3.2 Launch bytom node](#32-launch-bytom-node)
14   - [3.3 Create account and issue your asset](#33-create-account-and-issue-your-asset)
15   - [3.4 Deploy contract](#34-deploy-contract)
16   - [3.5 Call contract](#35-call-contract)
17 - [4 Contributing](#4-contributing)
18 - [5 License](#5-license)
19
20 ## 1 Background
21
22 Shuttle is designed to help swap different assets in bytom.
23
24 ## 2 Install
25
26 ### 2.1 Requirements
27
28 - [Go](https://golang.org/doc/install) version 1.12 or higher, with `$GOPATH` set to your preferred directory
29
30 ### 2.2 Install bytom node
31
32 Firstly, you should install and configure bytom node, see also: [Bytom repository](https://github.com/Bytom/bytom).
33
34 ### 2.3 Build from source code
35
36 This BTM swap tool is still in beta, so repository code will be changed frequently. You can build tool from source code directly.
37
38 ```shell
39 $ git clone https://github.com/Bytom/shuttle.git $GOPATH/src/github.com/shuttle
40 $ cd $GOPATH/src/github.com/shuttle
41 $ make install
42 ```
43
44 Shuttle help information:
45
46 ```shell
47 $ swap -h
48 swap is a commond line client for bytom contract
49
50 Usage:
51   swap [flags]
52   swap [command]
53
54 Available Commands:
55   callHTLC       call HTLC contract for asset swapping
56   callTradeoff   call tradeoff contract for asset swapping
57   cancelHTLC     cancel HTLC contract for asset swapping
58   cancelTradeoff cancel tradeoff contract for asset swapping
59   deployHTLC     deploy HTLC contract
60   deployTradeoff deploy tradeoff contract
61   help           Help about any command
62
63 Flags:
64   -h, --help   help for swap
65
66 Use "swap [command] --help" for more information about a command.
67 ```
68
69 or remove shuttle:
70
71 ```shell
72 $ cd $GOPATH/src/github.com/shuttle
73 $ make clean
74 ```
75
76 ## 3 Usage
77
78 ### 3.1 Swap assets in bytom or vapor
79
80 For example, in bytom blockchain, account a1 has 200 BTC, account a2 has 10 BTM, they can swap their assets using shuttle follow:
81
82 ### 3.2 Launch bytom node
83
84 For testing, you can launch bytom solonet node.
85
86 ```shell
87 $ bytomd init --chain_id=solonet --home $HOME/bytom/solonet # init bytom solonet node
88 $ bytomd node --home $HOME/bytom/solonet --mining           # launch bytom solonet node and start mining
89 ```
90
91 ### 3.3 Create account and issue your asset
92
93 You should create several accounts and issue your asset for testing, more details:
94
95 - [Managing Accounts](https://github.com/Bytom/bytom/wiki/Managing-Accounts)
96 - [Assets registration](https://github.com/Bytom/bytom/wiki/Advanced-Transaction#assets-registration)
97
98 ### 3.4 Deploy contract
99
100 ```shell
101 $ cd $GOPATH/src/github.com/btm-swap-tool/cmd
102 $ ./cmd deploy 10CJPO1HG0A02 12345 --amountLocked 20000000000 --amountRequested 1000000000 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --assetRequested ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --cancelKey 3e5d7d52d334964eef173021ef6a04dc0807ac8c41700fe718f5a80c2109f79e --seller 00145dd7b82556226d563b6e7d573fe61d23bd461c1f --txFee 40000000
103 --> contractUTXOID: ad1e72021352ade9e0fef7b1c52cc070bfcb1429f885a540f00f8b957e941b2d
104 ```
105
106 Then, wait about 2.5 minutes, and a new block will be mined, the contract will be confirmed.
107
108 ### 3.5 Call contract
109
110 ```shell
111 $ ./cmd call 10CKAD3000A02 12345 00140fdee108543d305308097019ceb5aec3da60ec66 ad1e72021352ade9e0fef7b1c52cc070bfcb1429f885a540f00f8b957e941b2d
112 --> txID: 762d6912e126ac3937cee54db8898af09abc5633c8b78682fa0cc23d89a518a9
113 ```
114
115 When the transaction will be confirmed in a new block, the whole BTM swap is successful.
116
117 ## 4 Contributing
118
119 Welcome to [open an issue](https://github.com/Bytom/btm-swap-tool/issues/new) or submit PRs. This project exists thanks to all the people who contribute.
120
121 ## 5 License
122
123 [MIT](./LICENSE) © 2019 Bytom