Rango Docs
API SwaggerWidget PlaygroundAppWebsite
  • 👋Welcome to Rango
  • 🏠Introduction
  • 💁How It Works
  • ✅Integrations
  • ⚖️Rango vs. Competitors
  • 🔐Security
  • 🛣️Roadmap
  • 🦎Tokenomics
  • 💰Airdrop
  • ❓FAQ
  • 🐞Bug Bounty
  • API Integration
    • 🔡Terminology
    • 🚄API Key & Rate Limits
    • 🤝Choosing the Right API
    • 🦄Basic API - Single Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Quote
        • Create Transaction (Swap)
        • Check Transaction Status
        • Check Approve Transaction Status
        • Get Address Assets & Balances
        • Get Token Balance
        • Report Transaction Failure
        • Get Direct Tokens
        • Get Custom Token
        • Message Passing
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
      • ✅Integration Checklist
    • 🦎Main API - Multi Step
      • 🛝API Flow
      • ⚙️API Reference
        • Get Blockchains & Tokens
        • Get Best Route
        • Get All Possible Routes
        • Confirm Route
        • Create Transaction
        • Check Transaction Status
        • Check Approve Transaction Status
        • Report Transaction Failure
        • Get Custom Token
        • Get Address Token Balance
      • 🎓Tutorial
        • 🍰SDK Example
      • 💰Monetization
      • 🎹Sample Transactions
  • ℹ️API Troubleshooting
  • Technical Docs
    • 🍔Swap Aggregation
    • 💰Monetization
    • ⛽Fee Structure
    • ⛽Network Fees and Gas Estimates
    • ⌛Stuck Transactions
  • Widget Integration
    • 🧩Overview
    • 🎇Quick Start
    • ⚙️Customization
    • 💰Monetization
    • 🛣️React Router
    • 🎵Events
    • 💳External Wallets
  • Smart Contracts
    • 👩‍💼Architecture
    • 🔎Audit Reports
    • 🏗️Deployment Addresses
    • 📩Message Passing
  • Ask for Integration
    • 🙋‍♂️DEXs & DEX Aggregators
    • 📱Rango Mobile SDK
  • Useful Links
    • Twitter
    • Discord Server
    • TG Announcements
    • TG Group
  • Terms of Use
  • Privacy policy
Powered by GitBook
On this page
  • Create Transaction API
  • Create Transaction Request
  • Create Transaction Response

Was this helpful?

  1. API Integration
  2. Main API - Multi Step
  3. API Reference

Create Transaction

Create the transaction for current step

PreviousConfirm RouteNextCheck Transaction Status

Last updated 8 months ago

Was this helpful?

Create Transaction API

When a user starts swapping or when a step of swap succeeds, to get the transaction for the next step, this method should be called.

In multi-step routes, you should loop over the routeResponse.route array and call this method (createTransaction) per each step.

const transaction = await rango.createTransaction({
    requestId: "1978d8fa-335d-4915-a039-77f1a17315f5", // bestRoute.requestId
    step: 1,
    userSettings: {
        slippage: 3,
        infiniteApprove: false
    },
    validations: {
        balance: true,
        fee: true,
        approve: true
     },
})
const response = await axios.post(
  'https://api.rango.exchange/tx/create',
  {
    'requestId': '1978d8fa-335d-4915-a039-77f1a17315f5',
    'step': 1,
    'userSettings': {
      'slippage': 3,
      'infiniteApprove': false
    },
    'validations': {
      'balance': true,
      'fee': true,
      'approve': true
    }
  },
  {
    params: {
      'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
    },
    headers: {
      'content-type': 'application/json'
    }
  }
);
curl --request POST \
     --url 'https://api.rango.exchange/tx/create?apiKey=c6381a79-2817-4602-83bf-6a641a409e32' \
     --header 'content-type: application/json' \
     --data '
{
  "requestId": "1978d8fa-335d-4915-a039-77f1a17315f5",
  "userSettings": {
    "slippage": 3,
    "infiniteApprove": false
  },
  "validations": {
    "balance": true,
    "fee": true,
    "approve": true
  },
  "step": 1
}
'

Create Transaction Request

  • requestId * String

    • Description: The unique ID which is generated in the best route endpoint.

  • step * Number

    • Description: The current step number in a multi-step route, starting from 1.

    • Example: 1

  • userSettings *

    • Description: User settings for the swap, including slippage and infinite approval.

  • validations *

    • Description: The validation checks we are interested to check by Rango before starting the swap.

export type CreateTransactionRequest = {
  requestId: string
  step: number
  userSettings: UserSettings
  validations: CreateTransactionValidation
}

export type UserSettings = {
  slippage: string
  infiniteApprove?: boolean
}

export type CreateTransactionValidation = {
  balance: boolean
  fee: boolean
  approve: boolean
}

Create Transaction Response

  • ok

    • Description: If true, Rango has created a non-null transaction, and the error message is null.

  • transaction

    • Description: Transaction's raw data. It is one of the transaction possible interfaces: EvmTransaction, CosmosTransaction, TransferTransaction (for UTXO), SolanaTransaction, StarknetTransaction, TronTransaction or null.

  • error

    • Description: Error message about the incident if ok == false.

  • errorCode

    • Description: Error code shows the type of error.

  • traceId

    • Description: Trace Id helps Rango support team to trace an issue.

export type CreateTransactionResponse = {
  error: string | null
  ok: boolean
  transaction: Transaction | null
}

export type Transaction =
  | EvmTransaction
  | CosmosTransaction
  | SolanaTransaction
  | TronTransaction
  | StarknetTransaction
  | TonTransaction
  | Transfer
  
export interface BaseTransaction {
  type: TransactionType
  blockChain: string
}

export interface EvmTransaction extends BaseTransaction {
  type: TransactionType.EVM
  isApprovalTx: boolean
  from: string | null
  to: string
  data: string | null
  value: string | null
  nonce: string | null
  gasLimit: string | null
  gasPrice: string | null
  maxPriorityFeePerGas: string | null
  maxFeePerGas: string | null
}

export interface SolanaTransaction extends BaseTransaction {
  type: TransactionType.SOLANA
  txType: 'LEGACY' | 'VERSIONED'
  from: string
  identifier: string
  recentBlockhash: string | null
  signatures: SolanaSignature[]
  serializedMessage: number[] | null
  instructions: SolanaInstruction[]
}

export interface CosmosTransaction extends BaseTransaction {
  type: TransactionType.COSMOS
  fromWalletAddress: string
  data: CosmosMessage
  rawTransfer: CosmosRawTransferData | null
}

export interface TronTransaction extends BaseTransaction {
  type: TransactionType.TRON
  isApprovalTx: boolean
  raw_data: TrxRawData | null
  raw_data_hex: string | null
  txID: string
  visible: boolean
  __payload__: object
}

export interface StarknetTransaction extends BaseTransaction {
  type: TransactionType.STARKNET
  isApprovalTx: boolean
  calls: StarknetCallData[]
}

export interface TonTransaction extends BaseTransaction {
  type: TransactionType.TON
  validUntil: number
  network?: TonChainID
  from?: string
  messages: TonMessage[]
}

export interface Transfer extends BaseTransaction {
  type: TransactionType.TRANSFER
  method: string
  asset: AssetWithTicker
  amount: string
  decimals: number
  fromWalletAddress: string
  recipientAddress: string
  memo: string | null
}
🦎
⚙️
🎹Sample Transactions
Create TXrango-exchange
Create Transaction Swagger
Logo