Step-by-step guide for cross-chain AtomicSwap exchange at MyKeepWallet.com

Gregory
4 min readOct 26, 2020

Dear users! The safety of your funds is very important to us. This is not an official wallet of KEEP Network project. This wallet is non-custodial, which means that private keys are stored on your device and not on the mykeepwallet.com server. Anyway, we do not recommend to use it with large amount of assets.

For more safety, you can connect to wallet via MetaMask. It will work with AtomicSwap exchange as well.

If you haven’t already, please firstly check out article about main features of MyKeepWallet.com.

What is AtomicSwap?

An atomic swap is a smart contract technology that enables the exchange of one cryptocurrency for another without using centralized intermediaries, such as exchanges.

Atomic swaps can take place directly between blockchains of different cryptocurrencies, or they can be conducted off-chain, away from the main blockchain.

Basically it’s a P2P exchange of funds.

How do atomic swaps work?

Atomic swap protocols are designed in a way that prevents any of the involved parties from cheating. To understand how they work, let’s imagine that Alice wants to exchange her TBTC (http://tbtc.network/) for Bob’s Bitcoins (BTC).

First, Alice deposits her TBTC into a contract address that acts like a safe. When this safe is created, Alice also generates a key to access it. She then shares a cryptographic hash of this key with Bob. Note that Bob can’t access the TBTC yet because he only has the hash of the key and not the key itself.

Next, Bob uses the hash provided by Alice to create another safe contract address, in which he deposits his BTC. To claim the BTC, Alice is required to use that same key and, by doing so, she reveals it to Bob (thanks to a special function called hashlock). This means that as soon as Alice claims the BTC, Bob is able to claim the TBTC and the swap is complete.

Using AtomicSwap exchange at MyKeepWallet.com

So let’s see how it works in a real life. As we said previously we will assume that Alice has TBTC and wants to exchange for Bob’s BTC:

Alice has TBTC and wants to get BTC
Bob has BTC and wants to get TBTC
  1. Alice goes to Exchange section and creates a new offer with the specified parameters (exchange rate, enable/disable partial fills) that she is interested in. Once the offer is created it appears on the offers list and becomes available to other users. MyKeepWallet.com does not take any service fee for the swap, but there is a miner fee that can’t be avoid. All the commissions are showed before the swap.
Alice creates an offer, which will be available to other users

2. When Alice created an offer, Bob can see it in available offers on the Exchange. Bob is satisfied with the conditions (commission and exchange rate) of an offer and decided to perform the exchange. So he accepts an offer and confirms it.

Bob accepts Alice’s offer

3. The exchange process is completely automatic and looks the same for both participants. It is also accompanied by hints from the system. Therefore, even a not very experienced user can make an exchange.

If for some reason the swap is stuck, you can try to reload a page. If you accidentally closed the page, the history of all swaps and links to them are always available at the bottom of the page in Transactions section.

Exchange process is completely automatic

4. When the exchange is done, users can check the transactions of the swap and their balances in the wallet.

Alice got her BTC and Bob got his TBTC, the exchange finished successfully

That’s all. Both users got what they wanted and did not use centralized exchanges. This way people can make exchanges with each other. MyKeepWallet.com currently supports KEEP, TBTC, USDT, BTC and ETH, which means that users can make an exchange between them and the amount of liquidity directly depends on the users themselves.

WARNING
Sometimes it happens that for some reason the swap can’t be done (the other person went offline/or any errors occurred during the exchange, etc.). Please don’t worry in this case, your deposited funds will be automatically returned if the swap isn’t complete (this usually takes 3–4 hours). Anyway, we do not recommend you to use exchange with large amount of sums to avoid uncomfortable situations.

Additional resources:

--

--