How to swap using hybrix cli-wallet

Swapping one asset for another can currently only be done on the command line. If you are not comfortable working in the terminal, and are not willing to try out beta software, then please stop here.

If you are still reading, hooray! Swapping between ledgers using hybrix cli-wallet takes just a few simple steps.

1) Make sure you have downloaded hybrix cli-wallet and can use it.

2) You should have a hybrix account with some HY tokens on it. You can check the balance as follows. This example shows a balance of about 10.99 HY.

$ ./cli-wallet -b hy
[.] balance: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

10.992102709728414289

3) Swap deals are made using the deal engine. Let us start by looking at the available pairs. (NOTE: in beta testing we have only two bridge pairs available.)

$ ./cli-wallet -M deal pairs
[.] module: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

[ “eth.hy/tomo.hy”, “tomo.hy/eth.hy” ]

4) Suppose we want to move our HY from the Ethereum blockchain to the Tomo blockchain. We will need to make a proposal with the amount we want to move. In our example we will move to HY from Ethereum to Tomochain. So we add three arguments: what we want to swap (eth.hy), what we want to receive (eth.hy), and the amount we want to receive (the amount 2).

$ ./cli-wallet -M deal proposal eth.hy tomo.hy 2
[.] module: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

{
  "id":"62f96a6a1234dbb0",
  "ask":{
    "symbol":"eth.hy",
    "amount":"2.03000000000000000",
    "target":"0xa7c2e624e1c477d3fe2a4127564a3c980b1fca58",
    "txid":null
  },
  "bid"{
    "symbol":"tomo.hy",
    "amount":"2.00000000000000000",
    "target":"0xfd9eb537df909144f14084d75fa88142bc80eb57",
    "txid":null
  },
  "fees":{
    "symbol":"eth.hy",
    "allocator":"0.010000000000000000",
    "network":"0.002"
  },
  "type":"autonomous",
  "creation":"1608559420",
  "deadline":"1608563020"
}

The proposal shows us we need to pay 2.03 HY on Ethereum to receive 2 HY on Tomochain. It also shows where the payment will go, which is target 0xa7c2... We see the fees that will be payed in which denomination and the amount that will go to the allocator and the network.

5) Now we can choose to accept the deal. To do this we need to add the deal ID as argument. When we accept the deal using cli-wallet the amount needed will automatically be paid to the network and the swap will take place.

$ ./cli-wallet -M deal accept 62f96a6a1234dbb0
[.] module: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

0x5496d381d8b2c6ae028c69f90a643f1c453bbfd0381df9d0af0e20b09a04dadd

We are returned a transaction ID of the amount we have sent.

6) All we need to do now is keep track of our progress. How is the deal going? To find out, we check the status of the deal.

$ ./cli-wallet -M deal status 62f96a6a1234dbb0

[.] module: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

{
  "id":"62f96a6a1234dbb0",
  "ask":{
    "symbol":"eth.hy",
    "amount":"0.203000000000000000",
    "target":"0xa7c2e624e1c477d3fe2a4127564a3c980b1fca58",
    "txid":0x5496d381d8b2c6ae028c69f90a643f1c453bbfd0381df9d0af0e20b09a04dadd
  },
  "bid":{
    "symbol":"tomo.hy",
    "amount":"0.2",
    "target":"0xfd9eb537df909144f14084d75fa88142bc80eb57",
    "txid":null
  },
  "fees":{
    "symbol":"eth.hy",
    "allocator":"0.001000000000000000",
    "network":"0.002"
  },
  "type":"autonomous",
  "creation":"1608559420",
  "deadline":"1608563020",
  "progress":"0.125",
  "status":"confirming"
}

We can see that our transaction has been accepted, and that it is confirming. So the deal is underway, and it should be a matter of time until it is finished.

7) Let us wait a few minutes and then take another peek at the status of our swap deal.

$ ./cli-wallet -M deal status 62f96a6a1234dbb0
[.] module: [▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓] 100%, eta: 0.0s

{
  "id":"62f96a6a1234dbb0",
  "ask":{
    "symbol":"eth.hy",
    "amount":"0.203000000000000000",
    "target":"0xa7c2e624e1c477d3fe2a4127564a3c980b1fca58",
    "txid":0x5496d381d8b2c6ae028c69f90a643f1c453bbfd0381df9d0af0e20b09a04dadd
  },
  "bid":{
    "symbol":"tomo.hy",
    "amount":"0.2",
    "target":"0xfd9eb537df909144f14084d75fa88142bc80eb57",
    "txid":0xa643f1c453bbfd0381df9d0af0e20b09a04dadd5496d381d8b2c6ae028c69f90
  },
  "fees":{
    "symbol":"eth.hy",
    "allocator":"0.001000000000000000",
    "network":"0.002"
  },
  "type":"autonomous",
  "creation":"1608559420",
  "deadline":"1608563020",
  "progress":"0.65",
  "status":"remitting"
}

Now you've almost completed your swap! Our transaction has been confirmed, and the allocation has sent us our requested amount. The status is now ‘remitting’, and once there are enough confirmations on the blockchain the status will be ‘done’, and our progress level will be set to 1. That means the swap is done, and we will have TOMO.HY tokens in our account.

So keep checking occasionally to see if the status turns to 'done'. (If it doesn't, please contact our support (support@hybrix.io), so we can help you.)

Congratulations! You have just made your first cross-ledger swap using hybrix!

Stay in touch! 💌

Subscribe to our newsletter and receive the latest updates, straight to your inbox.