OSDN Git Service

update
[bytom/shuttle.git] / README.md
1 BTM Swap Tool
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 Launch bytom node](#31-launch-bytom-node)
13   - [3.2 Create account and issue your asset](#32-create-account-and-issue-your-asset)
14   - [3.3 Deploy contract](#33-deploy-contract)
15   - [3.5 Call contract](#35-call-contract)
16 - [4 Contributing](#4-contributing)
17 - [5 License](#5-license)
18
19 ## 1 Background
20
21 BTM swap tool is designed to help swap different assets in bytom.
22
23 ## 2 Install
24
25 ### 2.1 Requirements
26
27 - [Go](https://golang.org/doc/install) version 1.12 or higher, with `$GOPATH` set to your preferred directory
28
29 ### 2.2 Install bytom node
30
31 Firstly, you should install and configure bytom node, see also: [Bytom repository](https://github.com/Bytom/bytom).
32
33 ### 2.3 Build from source code
34
35 This BTM swap tool is still in beta, so repository code will be changed frequently. You can build tool from source code directly.
36
37 ```shell
38 $ git clone https://github.com/Bytom/btm-swap-tool.git $GOPATH/src/github.com/btm-swap-tool
39 $ cd $GOPATH/src/github.com/btm-swap-tool/cmd
40 $ go build main.go
41 ```
42
43 ## 3 Usage
44
45 ### 3.1 Launch bytom node
46
47 For testing, you can launch bytom solonet node.
48
49 ```shell
50 $ bytomd init --chain_id=solonet --home $HOME/bytom/solonet # init bytom solonet node
51 $ bytomd node --home $HOME/bytom/solonet --mining           # launch bytom solonet node and start mining
52 ```
53
54 ### 3.2 Create account and issue your asset
55
56 You should create several accounts and issue your asset for testing, more details:
57
58 - [Managing Accounts](https://github.com/Bytom/bytom/wiki/Managing-Accounts)
59 - [Assets registration](https://github.com/Bytom/bytom/wiki/Advanced-Transaction#assets-registration)
60
61 ### 3.3 Deploy contract
62
63 ```shell
64 $ cd $GOPATH/src/github.com/btm-swap-tool/cmd
65 $ ./cmd deploy 10CJPO1HG0A02 12345 --amountLocked 20000000000 --amountRequested 1000000000 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --assetRequested ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --cancelKey 3e5d7d52d334964eef173021ef6a04dc0807ac8c41700fe718f5a80c2109f79e --seller 00145dd7b82556226d563b6e7d573fe61d23bd461c1f --txFee 40000000
66 --> contractUTXOID: ad1e72021352ade9e0fef7b1c52cc070bfcb1429f885a540f00f8b957e941b2d
67 ```
68
69 Then, wait about 2.5 minutes, and a new block will be mined, the contract will be confirmed.
70
71 ### 3.5 Call contract
72
73 ```shell
74 $ ./cmd call 10CKAD3000A02 12345 00140fdee108543d305308097019ceb5aec3da60ec66 ad1e72021352ade9e0fef7b1c52cc070bfcb1429f885a540f00f8b957e941b2d
75 --> txID: 762d6912e126ac3937cee54db8898af09abc5633c8b78682fa0cc23d89a518a9
76 ```
77
78 When the transaction will be confirmed in a new block, the whole BTM swap is successful.
79
80 ## 4 Contributing
81
82 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.
83
84 ## 5 License
85
86 [MIT](./LICENSE) © 2019 Bytom