4 [![MIT](https://img.shields.io/badge/license-MIT-brightgreen.svg)](./LICENSE)
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)
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)
22 Shuttle is designed to help swap different assets in bytom.
28 - [Go](https://golang.org/doc/install) version 1.12 or higher, with `$GOPATH` set to your preferred directory
30 ### 2.2 Install bytom node
32 Firstly, you should install and configure bytom node, see also: [Bytom repository](https://github.com/Bytom/bytom).
34 ### 2.3 Build from source code
36 This BTM swap tool is still in beta, so repository code will be changed frequently. You can build tool from source code directly.
39 $ git clone https://github.com/Bytom/shuttle.git $GOPATH/src/github.com/shuttle
40 $ cd $GOPATH/src/github.com/shuttle
44 Shuttle help information:
48 swap is a commond line client for bytom contract
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
64 -h, --help help for swap
66 Use "swap [command] --help" for more information about a command.
72 $ cd $GOPATH/src/github.com/shuttle
78 ### 3.1 Swap assets in bytom or vapor
80 For example, in bytom blockchain, account a1 has 200 BTC, account a2 has 10 BTM, they can swap their assets using shuttle follow:
82 ### 3.2 Launch bytom node
84 For testing, you can launch bytom solonet node.
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
91 ### 3.3 Create account and issue your asset
93 You should create several accounts and issue your asset for testing, more details:
95 - [Managing Accounts](https://github.com/Bytom/bytom/wiki/Managing-Accounts)
96 - [Assets registration](https://github.com/Bytom/bytom/wiki/Advanced-Transaction#assets-registration)
98 ### 3.4 Deploy contract
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
106 Then, wait about 2.5 minutes, and a new block will be mined, the contract will be confirmed.
108 ### 3.5 Call contract
111 $ ./cmd call 10CKAD3000A02 12345 00140fdee108543d305308097019ceb5aec3da60ec66 ad1e72021352ade9e0fef7b1c52cc070bfcb1429f885a540f00f8b957e941b2d
112 --> txID: 762d6912e126ac3937cee54db8898af09abc5633c8b78682fa0cc23d89a518a9
115 When the transaction will be confirmed in a new block, the whole BTM swap is successful.
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.
123 [MIT](./LICENSE) © 2019 Bytom