Rev. | Zeit | Autor | Nachricht |
---|---|---|---|
806ca85 | 2019-10-09 21:48:51 | Chengcheng Zhang | blockcenter master refine add docs |
fca2b68 | 2019-10-09 21:40:24 | Chengcheng Zhang | rm codes |
ceb5ad3 | 2019-10-09 21:32:16 | Chengcheng Zhang | rm transaction_test.go |
cc55c40 | 2019-10-09 21:30:51 | Chengcheng Zhang | refine canceltradeoff |
e8d9f0d | 2019-10-09 18:29:30 | Chengcheng Zhang | refine calltradeoff |
84f5efb | 2019-10-09 16:00:31 | Chengcheng Zhang | refine deploytradeoff |
bf529fe | 2019-10-09 14:21:57 | Chengcheng Zhang | refine submit |
6bd9a90 | 2019-10-09 14:16:52 | Chengcheng Zhang | refine cancelhtlc |
e33079f | 2019-10-09 10:54:23 | Chengcheng Zhang | refine callhtlc |
ad8c1bb | 2019-10-08 23:14:07 | Chengcheng Zhang | refine deployhtlc |
Name | Rev. | Zeit | Autor | Nachricht |
---|---|---|---|---|
blockcenter | 806ca85 | 2019-10-09 21:48:51 | Chengcheng Zhang | add docs |
master | 806ca85 | 2019-10-09 21:48:51 | Chengcheng Zhang | add docs |
refine | 806ca85 | 2019-10-09 21:48:51 | Chengcheng Zhang | add docs |
cli | e0d58f1 | 2019-09-30 16:48:44 | Chengcheng Zhang | update |
equity | 886c420 | 2019-09-18 21:49:42 | Chengcheng Zhang | add equity |
Shuttle is designed to help swap different assets in bytom.
$GOPATH
set to your preferred directoryFirstly, you should install and configure bytom node, see also: Bytom repository.
Shuttle is still in beta, so repository code will be changed frequently. You can build tool from source code directly.
$ git clone https://github.com/Bytom/shuttle.git $GOPATH/src/github.com/shuttle
$ cd $GOPATH/src/github.com/shuttle
$ make install
Shuttle help information:
$ swap -h
swap is a commond line client for bytom contract
Usage:
swap [flags]
swap [command]
Available Commands:
callHTLC call HTLC contract for asset swapping
callTradeoff call tradeoff contract for asset swapping
cancelHTLC cancel HTLC contract for asset swapping
cancelTradeoff cancel tradeoff contract for asset swapping
deployHTLC deploy HTLC contract
deployTradeoff deploy tradeoff contract
help Help about any command
Flags:
-h, --help help for swap
Use "swap [command] --help" for more information about a command.
or remove shuttle:
$ cd $GOPATH/src/github.com/shuttle
$ make clean
You can swap assets in bytom or vapor:
For testing, you can launch bytom solonet node.
$ bytomd init --chain_id=solonet --home $HOME/bytom/solonet # init bytom solonet node
$ bytomd node --home $HOME/bytom/solonet --mining # launch bytom solonet node and start mining
You should create several accounts and issue your asset for testing, more details:
For example, in bytom blockchain, account a1 has 200 BTC, account a2 has 10 BTM, they can swap their assets using shuttle.
$ swap deployTradeoff -h
deploy tradeoff contract
Usage:
swap deployTradeoff <accountID> <password> [contract flags(paramenters and locked value)] [txFee flag] [URL flags(ip and port)] [flags]
Flags:
--amountLocked uint tradeoff contract locked value with amount
--amountRequested uint tradeoff contract paramenter with requested amount
--assetLocked string tradeoff contract locked value with assetID
--assetRequested string tradeoff contract paramenter with requested assetID
--cancelKey string tradeoff contract paramenter with seller pubkey for cancelling the contract
-h, --help help for deployTradeoff
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--seller string tradeoff contract paramenter with seller control-program
--txFee uint contract transaction fee (default 40000000)
$ swap deployTradeoff 10CJPO1HG0A02 12345 --amountLocked 20000000000 --amountRequested 1000000000 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --assetRequested ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --cancelKey 3e5d7d52d334964eef173021ef6a04dc0807ac8c41700fe718f5a80c2109f79e --seller 00145dd7b82556226d563b6e7d573fe61d23bd461c1f --txFee 40000000
--> contractUTXOID: 34996b0838108de8c614bc018e8fdbbfc08a47ffbe0fd6d7f41892b90de3999f
Then, wait about 2.5 minutes, and a new block will be mined, the contract will be confirmed.
$ swap callTradeoff -h
call tradeoff contract for asset swapping
Usage:
swap callTradeoff <accountID> <password> <buyer-program> <contractUTXOID> [txFee flag] [URL flags(ip and port)] [flags]
Flags:
-h, --help help for callTradeoff
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--txFee uint contract transaction fee (default 40000000)
$ swap callTradeoff 10CKAD3000A02 12345 00140fdee108543d305308097019ceb5aec3da60ec66 34996b0838108de8c614bc018e8fdbbfc08a47ffbe0fd6d7f41892b90de3999f
--> txID: 55e43274d2d92504a903a13e3f6517d63434fc19a2fa0e1fc0a9a5c8c75e8f6c
When the transaction will be confirmed in a new block, the whole swap is successful.
Now, account a1 get 10 BTM, and account a2 get 200 BTC.
If someone want to cancel this tradeoff transaction, he can call cancelTradeoff.
$ swap cancelTradeoff -h
cancel tradeoff contract for asset swapping
Usage:
swap cancelTradeoff <accountID> <password> <redeem-program> <contractUTXOID> [txFee flag] [URL flags(ip and port)] [flags]
Flags:
-h, --help help for cancelTradeoff
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--txFee uint contract transaction fee (default 40000000)
$ swap deployTradeoff 10CJPO1HG0A02 12345 --amountLocked 20000000000 --amountRequested 1000000000 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --assetRequested ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff --cancelKey 3e5d7d52d334964eef173021ef6a04dc0807ac8c41700fe718f5a80c2109f79e --seller 00145dd7b82556226d563b6e7d573fe61d23bd461c1f --txFee 40000000
--> contractUTXOID: e898ea907f8586b3211a46b69d0cddd363f8a850f559656570eb6afc6ac382c5
$ swap cancelTradeoff 10CJPO1HG0A02 12345 00145b0a81adc5c2d68a9967082a09c96e82d62aa058 e898ea907f8586b3211a46b69d0cddd363f8a850f559656570eb6afc6ac382c5
--> txID: 0f75db743196b8b2e514c49d6483dfba9bd5ab8e913a7559ecaea0324977313f
Now, account a1 cancel tradeoff transaction, and 200 BTC come back.
You can swap assets between bytom and vapor:
For testing, you can launch bytom and vapor solonet node.
Launch bytom solonet node:
$ bytomd init --chain_id=solonet --home $HOME/bytom/solonet # init bytom solonet node
$ bytomd node --home $HOME/bytom/solonet --mining # launch bytom solonet node and start mining
Launch vapor solonet node:
$ vapord init --chain_id=solonet --home $HOME/bytom/vapor-solonet # init vapor solonet node
$ vapord node --home $HOME/bytom/vapor-solonet --mining # launch vapor solonet node and start mining
$ swap deployHTLC -h
deploy HTLC contract
Usage:
swap deployHTLC <accountID> <password> [contract flags(paramenters and locked value)] [txFee flag] [URL flags(ip and port)] [flags]
Flags:
--amountLocked uint HTLC contract locked value with amount
--assetLocked string HTLC contract locked value with assetID
--blockHeight uint HTLC contract locked value with blockHeight
--hash string HTLC contract locked value with hash
-h, --help help for deployHTLC
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--recipient string HTLC contract paramenter with recipientPublicKey
--sender string HTLC contract paramenter with sender PublicKey
--txFee uint contract transaction fee (default 40000000)
$ swap deployHTLC 11BB7TC8G0A02 12345 --sender 7262584844d4c14f512d1b6c9838e62c320e1d7887e7185bfea920c72a944e44 --recipient 562013c2f9082f1db52a2571034428921dd6eec8c010c2b2387f5b6125ff4aa7 --blockHeight 1200 --hash 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --amountLocked 20000000000
--> contractUTXOID: e1b104a03f4135b45d1c4c5fabbdca4dd0555653a588b71d790d45c4ffb2c50e
$ swap callHTLC -h
call HTLC contract for asset swapping
Usage:
swap callHTLC <accountID> <password> <buyer-program> <preimage> <contractUTXOID> [txFee flag] [URL flags(ip and port)] [flags]
Flags:
-h, --help help for callHTLC
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--txFee uint contract transaction fee (default 40000000)
$ swap callHTLC 11BB86V300A04 12345 0014230cb75fcfcc70c580ce7f1d21c1e374d27334a8 68656c6c6f e1b104a03f4135b45d1c4c5fabbdca4dd0555653a588b71d790d45c4ffb2c50e
--> txID: df57b7906684e3d85adf59073ccbc0a3c5114b165626e9791f3269e9e57c319e
The account a5 in vapor has same steps.
$ swap cancelHTLC -h
cancel HTLC contract for asset swapping
Usage:
swap cancelHTLC <accountID> <password> <redeem-program> <contractUTXOID> [txFee flag] [URL flags(ip and port)] [flags]
Flags:
-h, --help help for cancelHTLC
--ip string network address (default "127.0.0.1")
--port string network port (default "9888")
--txFee uint contract transaction fee (default 40000000)
$ swap deployHTLC 11BB7TC8G0A02 12345 --sender 7262584844d4c14f512d1b6c9838e62c320e1d7887e7185bfea920c72a944e44 --recipient 562013c2f9082f1db52a2571034428921dd6eec8c010c2b2387f5b6125ff4aa7 --blockHeight 1200 --hash 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824 --assetLocked bae7e17bb8f5d0cfbfd87a92f3204da082d388d4c9b10e8dcd36b3d0a18ceb3a --amountLocked 20000000000
--> contractUTXOID: 68ed6b948b93544ea135482f1acd93d6b10cdc88f52d44133d264a5ee86b1ebd
$ swap cancelHTLC 11BB7TC8G0A02 12345 001434fec270871c1f3420db85831f59511b2dd2a026 68ed6b948b93544ea135482f1acd93d6b10cdc88f52d44133d264a5ee86b1ebd
--> txID: c70a467e94b287d29c6d91a2cb6f8ef3c7ef4dba315d99acf2dc9ff698996270
Now, account a4 cancel HTLC transaction, and 200 BTC come back.
The account a5 in vapor has same steps.
Welcome to open an issue or submit PRs. This project exists thanks to all the people who contribute.
MIT © 2019 Bytom