SwapMarket is the first decentralized application built with the 0xcert Framework and leverages the power of atomic operations on the blockchain.
On February 28, SwapMarket produced the first many-to-many asset swap on the planet via an atomic operation!
Atomic operation is a perfect way to swap digital assets (both ERC-721 non-fungible tokens as well as ERC-20 fungible tokens) in batches and in a decentralized way, without risking the loss of traded assets.
The 0xcert Framework provides atomic operations as a set of instructions for an order. Such order is executed in one single mutation where only two outcomes are possible – either a successful exchange of assets or cancellation of the exchange process and return to its starting point.
How does atomic operation work
Atomic operations are transactions or orders between a Maker and a Taker. The Maker starts an order, the Taker executes it, and multiple parties can join the trade or swap.
The 0xcert Framework performs multiple actions within an atomic swap. Currently, atomic operation provides the:
- transfer of digital assets (ERC-721 non-fungible tokens) and values (ERC-20 fungible tokens) and
- creation (minting) of new assets (ERC-721 non-fungible tokens).
To guarantee that a specific transaction between trading parties is fully executed, the 0xcert Framework automatizes the atomic swap. This way, an atomic transaction can only end up with two possible results:
- a) Successful swap transaction for both trading parties or
- b) Cancelled swap and abolished transaction without any loss of assets.
The steps of an atomic operation follow an automatic sequence. Only once the end condition is fulfilled, the atomic swap is settled automatically, no earlier and in no other way. The process of an atomic transaction is locked from start to finish which makes it atomic (indivisible), and by that eliminates the possibility for any unwanted scenario that would jeopardize the safety or ownership of traded assets.
A swap trade agreement is set between two or more parties off-chain, and the execution of the agreement and its settlement via atomic operation is completed entirely on decentralized storage or blockchain. This makes the verification and tracking much easier and reliable.
Atomic swaps on SwapMarket
First off, you should note that SwapMarket is not a typical marketplace where one could sell or buy publicly listed assets. Rather, it’s a decentralized exchange (DEX) for arbitrary swaps, and the sequence of the steps required for a swap operation is aligned with this concept.
Step #1: Define trading parties
First, you should define the participants that will join in a swap. The Maker (or you) launches the order by inserting the data of all the trading parties.
The Maker (you) initiates an order, and the Taker executes it. Of course, other asset traders can join the swap, too.
Here, you’ll need to enter every participant’s (nick)name and their wallet address.
Step #2: Define traded assets
Next, you come to the whole point of the atomic operation – the assets you’d like to exchange. These can be either:
- ERC-721 non-fungible tokens/crypto-collectibles
- ERC-20 fungible tokens
- even CryptoKitties.
SwapMarket is one of the rare DEXes where you can add multiple (various) tokens and combine them in asset bundles.
SwapMarket detects the assets that are available for swap automatically, so you don’t have to remember all your stock – just choose the assets you want to swap.
Due to safety reasons, SwapMarket currently does not support exchange of tokens that are built on yet unconfirmed standards, so it could happen that they don’t appear as options for swap.
Step #3: Sign the order
Once you’ve chosen the assets to swap, it’s time to sign it. Check the order preview and if it looks fine, it’s ready for signing.
You also shouldn’t forget to set the expiration period of the order – the Taker should confirm and execute the transaction before it’s over. If they don’t, the order is cancelled, and assets remain in their owners’ wallets.
Step #4: Execute the swap
In the fourth step, you should see a link should on SwapMarket as the last requirement for executing the swap. Make sure you send this link to the Taker so that they confirm it and bring the swap to the end.
As soon as the Taker clicks on that link, the assets start being transferred to the wallets of their new owners.
Step #5: Check your wallet
Within a few minutes after the execution of the swap, you should find new assets added to your wallet.
Swap or build!
SwapMarket provides an extremely easy and intuitive way of swapping digital assets in a decentralized way.
If you’re interested in exploring atomic operations further, this article could help.
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!