Skip to content

Processing InstantDEX swap on barterDEX

SHossain edited this page Mar 23, 2018 · 6 revisions


Fastest swaps are here now as InstantDEX Swap. All nodes can be doing this at the same time, any bob to any alice. All you need to have is some amount of KMD deposit for dynamic trust. It does require a deposit that matches your trade size.

If you are selling 20 at at time, deposit 20. If you are selling 50 at a time, deposit 50. And, you can trade without any deposit if you want to wait for coin confirmations. Use InstantDEX swap, just wait for deposit coin confirmations, you can sell all. The deposit just has to cover the amount you have pending in swaps, not anything regarding your total amount.

You can see your balance using the regular balance API. After verification your zcredits will be displayed with your KMD balance like this:



You can deposit KMD using the following script into b addresses which will accrue interest as well. This will allow you to do InstantDEX swaps which finishes a swap within 5-20 seconds. The more KMD you deposit for InstantDEX trading, the more limit you can have. It is a timelocked deposit, keeps the honest traders honest. Gives other traders the assurance that you have a valid deposit to cover any hack attempt.

instantdex_deposit the values are 1 to 52 weeks and the amount (minimum of 10.0001). These figures are calibrated to the 5% APR, ie. 1 weeks interest is approx the BOTS 0.1% fee, 52 weeks is the most the 5% APR accrues, 10.0001 KMD is min required for interest. It can take few minutes (about 10 confirmations) for the LP nodes to recognise you. This creates a dynamic trust between nodes and swaps are faster. Just issue normal buy and the LP nodes will respond with InstantDEX swaps.

It creates a binary file in DB with the unique deposit txids on an append only basis. The first time, it seeds it with the contents of the existing instantdex.json files. from the deposits file the instantdex_address_append.json is directly created and the instantdex.json file is created by removing the already spent deposits.

Sample script:

curl --url "" --data "{\"userpass\":\"$userpass\",\"method\":\"instantdex_deposit\",\"weeks\":1,\"amount\":10.0001,\"broadcast\":1}"

weeks:1 means it will be there for 300 hours or 1 week time. Don't set to week:0 unless you are only testing.

Sample Output:

"scriptPubKey":{"hex":"a914d9da8e493573be957273f842617132c361546e7b87"}}, {"satoshis":"1000003","scriptPubKey":{"hex":"76a914928104f862284623c4e744009923356ff4832ba388ac"}}, {"satoshis":"124620441","scriptPubKey":{"hex":"76a9140c1007fc1f406a0a519886c0e59327e9c43a634088ac"}}]},


For 0conf deposits claim can take extra time. The extra time can be up to a week as it operates on a weekly cycle. Best is to make the 0conf deposit on Saturdays. Friday is safest anywhere in the world.

After the deposit is expired, you can claim at any time, though it is rounded up to the next week boundary. You need to use ./claim API to claim your 0conf deposit (zcredits) back. All of your deposits are secured as long as you have the txid handy. If you use week:0 you need to save the details of timestamp and the b address that the funds were sent in order to use with the ./claim script to claim it back.

Minutes or hours is not long enough. Remember, the point here is to resolve any blockchain attacks.

claim API will display the balance of the 0conf deposit txid along with interest and wait time to claim. This will claim the deposit instantly if it already expired and ready to claim.

Sample File Contents:

curl --url "" --data "{\"userpass\":\"$userpass\",\"method\":\"instantdex_claim\"}"



Manually Enable 0conf deposits to work with the GUI

You need to put the txid of the 0conf / instantdex deposit in an instantdex.json and/or instantdex_address.json file inside DB dir. If the file is not preset in the DB folder, create the file manually. The DB dir is located C:/Users/<username>/AppData/Roaming/BarterDEX/DB in Windows and ~/.BarterDEX/DB in Linux. The content inside the JSON file should look like following:

1 txid


2 or more txid


[Note: If you are using Windows, please use 1 txid at a time. Claim for multiple txid may not work together. Claim single txid each time.]

Then delete any deposit.address binary file for your address i.e.: deposits.RPZVpjptzfZnFZZoLnuSbfLexjtkhe6uvn, all this is in DB dir. Don't delete any dir in here.

Next time you start BarterDEX, it should then generate a deposits.<address> with the binary of the txid and necessary files. If Electrum mode does not work for you, try with native KMD wallet.

Negative zcredits balance is the balance being used for 0conf trade, will be available after the next notarized block.

Clone this wiki locally
You can’t perform that action at this time.