Integration Overview
Learn the general principles of integrating with THORChain

Overview

  1. 1.
    Connect to a self-hosted or public Midgard
  2. 2.
    Get the /inbound_addresses
  3. 3.
    Build the transaction with the correct memo and correct gas price.
  4. 4.
    Send the vault the transaction and wait for execution

Connecting

First, you need to connect to THORChain. You can use the official clients which have SSL, or run your own node, host it on SSL. See connecting to THORChain for the details.

Get The Asgard Vault

Vaults are fetched from the /inbound_addresses endpoint. This is the vault that users send funds to, which is monitored and processed by THORChain.
For Swapping, you will need to display the trade pairs
Use the /pools endpoint of Midgard to retrieve all swappable assets on THORChain.

Build The Transaction

The most important details in the transaction:
{
"from":"", // the user
"to":"", // the vault
"amount:"", // the amount to send (swap, add liquidity)
"memo":"", // the transaction intent
"gas_rate":"" // always set to next-block rates
}
If the memo is not correctly formed, it the Tx will be refunded. The memos can be found here:
Always use a "fast" or "fastest" fee, if the transaction is not confirmed in time, it could be abandoned by the network. You should allow your users to cancel or re-try with higher fees.

Send The Transaction

You send the transaction to the Asgard Vault for processing by THORChain. You can use any wallet library, like bitcoinjs or use the xchainjs which wraps all the respective chains.

Wait for Processing

THORChain will pick up and process the transaction once it is confirmed on chain. The transaction is either processed or refunded. You can query for the successful transaction on Midgard.
Copy link
Outline
Overview