Rango Docs
Search…
Overview

Introduction

Rango exchange provides a versatile API that helps dApps and wallets get free from hassles of connecting to dozens of blockchains, tracking transactions, verifying third-party providers, etc. The whole idea behind our API is to make it the easiest possible solution on the market.
The API consists of just a few endpoints that have abstracted away a very huge amount of complexity in the server's side, such that making a fully-working cross-chain dApp over cosmos, Ethereum-based blockchains and UTXOs is a piece of cake.
Before diving into the details, here are some links to the technical specifications of the API, in the swagger format:

API Key

Our service is currently free. But to use our API endpoints, you should request an API key, describing your dApp, the blockchains you like to connect to, and your dApp domain if it's a website to enable CORS headers for your API key. You should attach your API key to all your request as:
1
curl 'https://api.rango.exchange/path/to/resource?apiKey=<YOUR-API-KEY>'
Copied!

Sample Scenario

Here is the sample interaction scenario between a dApp and Rango API:
  1. 1.
    The user connects a wallet in dApp and gives the wallet address to dApp
  2. 2.
    dApp optionally calls getWalletDetails endpoint from Rango to get balances
  3. 3.
    Users or dApp selects to swap 1 x BSC.BNB to TERRA.UST
  4. 4.
    dApp calls getBestRoute endpoint [with checkPrerequisite flag = false] from Rango. Rango gives a path of:
    • Step 1: Swap BSC.BNB to BSC.UST via 1inch
    • Step 2: Swap BSC.UST to TERRA.UST via 1inch
  5. 5.
    The user clicks on confirm to start the swap.
  6. 6.
    dApp calls getBestRoute endpoint [with checkPrerequisite flag = true] from Rango. It's a bit slower since it checks balances and fees that are required to perform the swap
  7. 7.
    If validation fails in the response, dApp shows an error to the user and flow breaks.
  8. 8.
    If validation is true, repeat steps 9 to 14 for each swap in the getBestRoute response.
  9. 9.
    dApp calls createTransaction to get a transaction, if the transaction is an approval tx, determined by a flag in response, dApp sends it to the wallet for signing.
  10. 10.
    dApp calls checkApproval endpoint every 5 seconds until the result is approved
  11. 11.
    dApp calls createTransaction again to get the real transaction this time
  12. 12.
    dApp sends the tx to the wallet for signing
  13. 13.
    dApp calls checkTxStatus endpoint every 5 seconds to see if the step is successful or failed.
  14. 14.
    If the step is successful dApps repeats the process for the next step
  15. 15.
    If the step fails, dApp optionally calls reportTx endpoint to report the failure

Transactions

Rango currently supports around 20 blockchains as the source, and 23 as the destination, including multiple Cosmos-compatible blockchains, Ethereum-based L1 & L2, and traditional UTXO as BTC, LTC, BCH, etc. Other than that you can swap funds to Polkadot, Doge, and Tron, but swapping back from these three blockchains are not supported yet in Rango.
All in all, when you call our createTransaction endpoint, a transaction object is returned to you as the name indicates. At the current stage, we might only return 3 different types of objects which support all these 20 blockchains. The client doesn't mostly need to do any modifications to the response and should just send it to the wallet.
These three types include:
  1. 1.
    EVM Transaction: If the source of a step is an Ethereum compatible blockchain including Ethereum Mainnet, BSC, Avalanche, Harmony, Fantom, etc. we return an EVM transaction that contains a hex data and value that should be directly passed to the wallet to execute.
  2. 2.
    Transfer Transaction: If the source of a step is a UTXO blockchain that supports simple operations like transfer, a Transfer type of transaction is returned that contains the amount, symbol, destination wallet address, etc.
  3. 3.
    Cosmos Transaction: If the source of a step is Cosmos-based [Including Akash, Osmosis, Terra, Binance Chain (BNB)], then the result will be a Cosmos transaction that contains a list of Cosmos messages that should be passed to a wallet like Keplr.
There will be more types as Rango expands its territory to more blockchains (e.g. Solana). You can find the details of these types on the Swagger docs linked above this page.

Help

For any more information on how to use the API, contact Uchiha Sasuke from our dev team.