Atomex: cross-chain atomic swaps on practice

Introducing a multi-crypto desktop wallet with built-in hybrid exchange

Baking Bad
Sep 25 · 5 min read

A thorny developing process is starting to bear its first fruits: Atomex has been finally released in the mainnet. Our team has made up an exciting journey from the pure atomic swap protocol to the fully-fledged application, and now we can say “Yes, it works!”.
We want to thank all the early testers for their feedback, it is very important for us!

The idea behind

Our goal is to create a product for crypto enthusiasts, for those who believe in ideas behind the blockchain technology and who is paranoid in a good sense.

If TCP/IP is a protocol used to transfer information on the Internet, the blockchain is the same for e-money and other classes of assets. However, there is still an interchain gap which leads to an inconvenient value separation.
The atomic swap protocol which we will examine a little further effectively closes that gap in a trustless way, relying on an essentially simple idea. Banks or another trusted third-parties are being replaced by a smart contract, and this is one of the few cases when it can be done with just the data available on-chain (without oracles or other off-chain data providers).

Atomic swap basics

Before we move on to the practical part, let’s dive a bit into the protocol details. Let’s say Alice wants to buy some ETH for XTZ and Bob has agreed to make a deal. There are two possible outcomes, either the transaction will take place or will be canceled.

Initialization phase

Requirement: lock_time_b < lock_time_a
To prevent the case when Alice first makes a refund and then redeems Bob’s funds.

Successful redeem

Simplified scheme of an XTZ/ETH swap (success case)

Refund case

We will not consider the cases when something goes wrong during the initialization phase (they are rather trivial) but will examine the case when Alice doesn’t redeem Bob’s ETH for some reason, i.e. secret is not revealed and lock_time_b has passed.

Simplified scheme of an XTZ/ETH swap (refund case)

That’s enough theory

Time to see Atomex in action! We’ll start from a multi-crypto setup with some XTZ and ETH on our balance. With regard to the above scheme we are Bob, and our counterparty is Alice.

Create new conversion

Choose the “Conversion” tab and set the ETH amount we want to exchange for XTZ. Check the deal terms and then press “Convert”.

Step 0. The user creates a new conversion

A new сonversion appears in the table with the status “In Progress”.
Actually, that’s all we need to make an atomic swap through Atomex wallet. But let’s follow the internal process spawned by our actions.

Under the hood: Alice locks XTZ

First, check out recent operations for the Atomex smart contract in the Tezos blockchain:

Step 1. Alice locks XTZ

This is a transaction sent by Alice, these locked funds are going to be ours in the end. Mind the hash field passed via parameters.

Under the hood: Bob (us) locks ETH

Once the XTZ transaction is confirmed, Bob sends an ETH transaction. We can see that it contains the same hash :

Step 2. Bob locks ETH

Under the hood: Alice redeems ETH

Another contract invocation from Alice’s side. She receives our ETH in exchange for secret and Bob picks it up:

Step 3. Alice redeems ETH

Under the hood: Bob (us) redeems XTZ

Finally, Bob unlocks XTZ using the collected secret :

Step 4. Bob redeems XTZ

The status of our conversion changes to “Completed”, everything is ok.

Side notes

All the internal actions you saw are performed by the Atomex wallet in the background process so it’s necessary to keep it online until the swap is done. In our example of an XTZ/ETH conversion, it takes only 8 minutes for the whole thing, however, it depends on the particular blockchain confirmation time.

We are currently working on making different order types available. As soon as the Atomex swaps market will be consistent enough it will be possible to place limit orders through the Atomex app.

How to set up Atomex wallet

Check out our tutorial.

Any feedback is highly appreciated, if you have a feature request or a bug report please welcome to our Telegram chat. And don’t forget to follow us on Twitter!

Cheers!

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Baking Bad

Written by

Baking-bad.org, Audit & Rating of Tezos bakers. Active Tezos tools contributor. Author of better-call.dev, Pytezos, Netezos, TzKT.io, atomex.me

Coinmonks

Coinmonks

Coinmonks is a non-profit Crypto educational publication. Follow us on Twitter @coinmonks Our other project — https://coincodecap.com

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade