Integration Overview
Learn the general principles of integrating with THORChain

Overview

Read Only Applications

Dashboards, explorers etc
  1. 1.
    Connect to Midgard to get rich data about the system, included time-series graphs and aggregated values like TotalVolume etc.
  2. 2.
    Connect to THORNode (or proxied via Midgard) to drill into the state-machine and access the current state (or historical just by adding a ?height=1234 to specify a certain height.
  3. 3.
    Connect to RPC to get information about the Ledger, which is not specific to THORChain, such as /genesis or account/transaction information

Write Applications

Wallets, interfaces etc.
These applications require first-principle thinking and excellent understanding of how the system works.
  1. 1.
    Connect to a trusted THORNode or connect to several public THORNodes and ensure they all agree
  2. 2.
    Get the /inbound_addresses
  3. 3.
    Compose 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.
If you don't need SSL, you can connect to any of the non-SSL public nodes (ie, just their IP address). Web applications need SSL, but mobile and desktop apps don't.

Get The Vault

Vaults are fetched from the /inbound_addresses endpoint.
https://thornode.thorchain.info/thorchain/inbound_addresses
If you connect to public THORNodes, you must be conscious of the fact that you can be phished and could send money to the WRONG vault. You should do safety checks, ie, comparing with other nodes, or even inspecting the vault itself for presence of funds. You should also consider running your own 'fullnode' instance to query for trusted data.
Never cache vault addresses, they churn regularly.
Check for the halted parameter and never send funds if it is set to true

Build The Transaction

The most important details in the transaction:
1
{
2
"from":"", // the user
3
"to":"", // the vault
4
"amount:"", // the amount to send (swap, add liquidity)
5
"memo":"", // the transaction intent
6
"gas_rate":"" // always set to next-block rates
7
}
Copied!
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 can user any wallet library, like bitcoinjs or use the xchainjs which wraps all the respective chains.
Last modified 7d ago