Table of Contents

Underlying Cross-Chain Trade Functionality of Qortal

This page is in need of updates as well, but the concepts here are still applicable. The primary trade platform for Qortal now, that leverages the cross-blockchain trade capability Qortal provides, is Q-Trade, available as both a Q-App accessible on Qortal directly, and via the Qortal Chromium Extension + Q-Trade website on https://qort.trade. Regardless of the trade frontend utilized, the backend is all done by the Qortal Core, and leverages the same primary components.

Primary Trade Components

The two primary components of a TRUE cross-blockchain trade taking place with the assistance of Qortal, are:

ACCT AT- ATs are Qortal 'smart contracts' (for lack of an easier explanation). They are much more optimal and lower-requirement SmartContract system, that allow the automation of transactions on the Qortal Blockchain. They are a Turing Complete hardware-level code language written by the CIYAM Developers. The specific type of AT utilized for a Cross-Blockchain Trade, is the 'ACCT AT' or 'Atomic Cross-Chain Trade' Automated Transaction. This AT's job is simply to 'lock' QORT so that the issuer of the AT cannot spend it, during the trade process. The ACCT AT is where the QORT that is 'listed' for 'sale' is stored, after the 'sell' is initiated by the seller account.

Qortal Core 'Tradebot' - The 'tradebot' of the Qortal Core is a means to automate the various transactions required to complete a true cross-blockchain trade. Each cross-blockchain trade requires multiple steps to complete. Each step requires a transaction on the chains involved in the would-be trade. The tradebot automates the process of creating these transactions, thus allowing the users initiating the trades to click a single button, and nothing more. Essentially the tradebot is given authority to act on behalf of the account trading, by the account owner. The Tradebot then automates the various stages of the cross-blockchain trade, making it so that the trade can take place 'immediately'.

The Tradebot initiates 'MESSAGE' transactions to the AT, and executes transactions on the 'foreign chain' involved in the trade, so that the trade can take place without any further human interaction aside from the clicking of 'buy' or 'sell' on any of the various trade interfaces for Qortal.

The Tradebot runs on the node on which the trade is initiated. In the most optimal case, the node will be on your local computer. However, utilizing a node on a remote machine and/or a public node is also possible, but the details change a bit depending on whether a node is local or not. More details will come soon regarding the various differences.

For the latter portion of this page, the assumption is that the user is running Qortal in the most optimal fashion, having both Qortal Hub, and the Qortal Core running on their local computer, not accessing a remote node they own, nor a publicly run remote node.

TO HAVE A SUCCESSFUL TRADE:

1) You need to make sure your core is running and 2) You do NOT delete or mess with your db.

How can you trade?

To trade, two things are needed:

1) If you want to buy QORT, you need to fund your LTC wallet and 2) If you want to sell QORT, you must have QORT.

People involved in a Trade:

- Bob: Bob has QORT and wants to sell QORT to get LTC

- Alice: Alice has LTC and wants to buy QORT with LTC

The Trade Process

Bob want to sell 30 QORT for a total of 0.02 LTC, he goes to the Trade Portal and places a sell order.

What happens when Bob places a sell order?

1) Immediately Bob places a sell order, an instance of a Tradebot will be created and he issues the DEPLOY_AT transaction. 2) When the Tradebot is created, Bob will see a PENDING order in "MY ORDERS".

PENDING means:

1) The Tradebot has been created and it is waiting for the DEPLOY_AT transaction. 2) The DEPLOY_AT transaction has not been included into the block. 3) The DEPLOY_AT transaction failed.

DEPLOY_AT transaction is a normal transaction which creates the AT and the trade offer. Just like a REWARD_SHARE transaction that must be included into the block for the Reward Share Key to work, the DEPLOY_AT must be included into the block in order for the AT to be created. Once this happens, the status of the order in "MY ORDERS" will be LISTED.

This means if your order is showing PENDING, the AT was not created. At this point, your QORT is still in your wallet.

LISTED means:

1) The order was successfully created and will be listed in "OPEN MARKET SELL ORDERS" and 2) The order is waiting for a buyer.

Right now, Bob has placed an order to sell 30 QORT for a total of 0.02 LTC

To Buy:

Alice comes online and sees Bob's order and she's interested. She clicks on the order to buy it.

What happens when Alice clicks on Buy?

As soon as Alice clicks on buy, a Tradebot will be created and the Tradebot funds P2SH-A with LTC:

Alice's Tradebot waits for that to appear in the Bitcoin blockchain, so until then her order is PENDING. Once the P2SH-A funding confirms, Alice's Tradebot can MESSAGE Bob's Tradebot with the details and so her order will be in TRADING

Next Step:

Bob's Tradebot recieves the MESSAGE and sends its own message to the AT and the Tradebot locks the AT to trading with Alice. At this point, Bob's order is in TRADING.

Once Alice's Tradebot notices that Bob's AT is locked to her, she goes ahead to fund P2SH-B and then waits until Bob REDEEM's P2SH-B. At this point, her order is still in TRADING.

1) Bob's Tradebot finds P2SH-B on the Bitcoin blockchain and can send secret-B to P2SH-B. Alice uses secret-B and secret-A to redeem the QORT from the AT, so until Alice does this, Bob's order is still in TRADING. 2) After Alice redeems QORT from AT, Bob can extract secret-A and capture the actual LTC funds from P2SH-A to his own Bitcoin account and hence his order will be completed and will be moved to "MY HISTORIC TRADES".

Once all these steps are done, Alice should have her QORT and Bob should have his LTC

What if something goes wrong?

If something goes wrong then the Tradebot will process a REFUND:

1) Bob's Tradebot refunds Bob his QORT and 2) Alice's Tradebot refunds Alice her LTC.

Important Things to note:

1) The trade takes time and is dependent on the LTC network and 2) Your core MUST BE RUNNING for the trade to be successful.

Trading For QORT Walkthrough

See The QORT Coin page with subsection ‘Trading For QORT Walkthrough’ for info on how to obtain QORT in the Trade Portal. This same process can be used for other coins we support as well.