Atomic swaps on SwapMarket

0xcert
0xcert
5 min readMar 15, 2019

--

SwapMarket, the first dapp built with the 0xcert Framework, sources its power from the potent atomic operations on the blockchain.

On February 28, an atomic operation on SwapMarket performed the first many-to-many asset swap on the planet!

Atomic operation is the optimal way of swapping digital assets (both ERC-721 NFTs and ERC-20 fungible tokens) in bundles in a decentralized way and without the risk of losing traded assets.

Within the 0xcert Framework, the atomic operation is a set of instructions for an order to be executed in a single mutation and with only two possible outcomes — either a fruitful exchange of assets or abolishment of the exchange process and return to its starting point.

How does atomic operation work

Atomic operations are orders between a Maker and a Taker. The Maker creates an order, and the Taker executes it, and multiple parties can participate in the swap.

The 0xcert Framework allows for multiple actions to be performed in such a manner. At this point, atomic operation within the Framework supports the

  • transfer of digital assets (ERC-721) and values (ERC-20) and
  • creation (minting) of new assets (ERC-721).

To ensure that a specific trade between parties is reached to its fullness, the 0xcert Framework provides an automatized atomic swap. This way, an atomic transaction can only conclude in two possible ways:

a) Successful swap for both trading parties or
b) Abolished swap and reversed transaction without any asset loss.

The steps of the atomic operation progress automatically. Only once the final condition is met, the atomic operation is settled automatically, no sooner and in no other way. The transaction process is locked from start to finish and thus atomic (indivisible), which removes the possibility for any third scenario where one party could take unfair advantage over the other.

A swap agreement is set between two or more trading parties in an off-chain environment, while the agreement execution and settlement provided by the atomic operation is done entirely on decentralized storage. This enables verification and tracking of each step of the operation at any time.

Atomic swapping on SwapMarket

SwapMarket is not a general marketplace where you could sell or buy freely available and listed assets. Instead, it’s a decentralized exchange for arbitrary swaps, and the steps of the swap operation adhere to this principle.

Step #1: Define participants

First, you need to define who will participate in a swap. The Maker (or you) begins the order by entering the data of all the trading parties.

You are the Maker or the initiator of an order, and the Taker is the one executing it. Of course, other asset owners can be invited to the party, too.

Here, you’ll need to insert all participants’ (nick)names and their wallet addresses.

Step #2: Define assets

Next comes the essence of the atomic operation — the goodies you’d like to swap. These can be either:

  • ERC-721 non-fungible tokens/crypto-collectibles
  • ERC-20 fungible tokens
  • and even CryptoKitties.

SwapMarket is one of the rare platforms that allows you to add multiple tokens and create asset bundles in combos that suit you best.

SwapMarket detects the assets available for swap automatically, so you don’t have to worry about remembering everything you have in stock. You just browse through your assets that SwapMarket supports and pick the ones you grew tired of and would like to swap.

Please note that due to safety reasons, SwapMarket does not support tokens that are built on other, yet unconfirmed standards, therefore they might not appear among your options for swap even though they are safely stored in your wallet.

Step #3: Sign your order

Once you’ve decided on the subject of your order, it’s time to sign it. If the order preview looks fine, it’s ready to go.

Also, don’t forget to set the expiration period within which the Taker should confirm and execute the transaction. If they fail to do so in time, the order is abolished, and no assets are transferred.

Step #4: Execute the swap

By now, a link should appear as the last requirement for the swap’s execution. You should send this link to the Taker via an arbitrary communication channel.

The swap is in their hands now. As soon as the Taker clicks on the link the Maker (you) provides, the assets start their journey to their new owners’ wallets.

Step #5: Check your wallet

Congrats! You’re now a proud owner of a new batch of assets. Within a few minutes after the completion of the swap, your wallet should be richer for a new addition.

You can check the status of your swap in the Swaps menu tab or on EtherScan, searching by your wallet address.

That’s it! It’s done faster than you can say non-fungible token.

Swap or build!

Now that you know how easy it is, you’re ready to swap your heart out.

To learn more about the process of atomic operation, here is a nice article for you.

Or, if you’re inspired by the ease of use and the power of atomic swaps on SwapMarket, why not try building your own decentralized app? The 0xcert Framework will provide you with an easy-to-use JavaScript library with top-notch functions for decentralized operation and implementation of non-fungible tokens (NFTs).

Build your own dapp

The 0xcert Framework is free and open-source, and we’d appreciate every new star on our GitHub. If you get stuck or would like some help from fellow devs, join our Gitter channel.

We’ll see you on the dapp’s side!

Originally published at 0xcert.org.

--

--

0xcert
0xcert
Editor for

Your ID, degree, artwork or house. 0xcert-ified on the blockchain⛓→ https://0xcert.org/