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
  • Check Approval Status API
  • Check Approval Request
  • Check Approval Response

Was this helpful?

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

Check Approve Transaction Status

Check status of approve transaction

PreviousCheck Transaction StatusNextReport Transaction Failure

Last updated 8 months ago

Was this helpful?

Check Approval Status API

When createTransaction returns an approval transaction (i.e. isApprovalfield is true in transaction), and the user signs that transaction, you could periodically call check-approval to see if the approval transaction is completed. After a successful check, you should call createTransaction again to receive the main transaction.

const transaction = await rango.checkApproval({
    requestId: "b3a12c6d-86b8-4c21-97e4-809151dd4036", // bestRoute.requestId
    txId: "0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f" // optional
})
const response = await axios.get('https://api.rango.exchange/tx/b3a12c6d-86b8-4c21-97e4-809151dd4036/check-approval', {
  params: {
    'txId': '0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f',
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
curl --request GET \
     --url 'https://api.rango.exchange/tx/b3a12c6d-86b8-4c21-97e4-809151dd4036/check-approval?txId=0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f&apiKey=c6381a79-2817-4602-83bf-6a641a409e32' 

For checking approval transaction status, you could check it directly from the RPC endpoint if you prefer and skip calling Rango API for this purpose.

Caution

It is important to use approve transaction data generated by Rango API and not hard-coding something on your client side for creating approve transaction, because for some protocols (some bridges), the contract that should be approved is dynamically generated via their API based on route.

You could stop checking approval method if:

  • Approval transaction succeeded. => isApproved === true

  • Approval transaction failed. => !isApproved && txStatus === 'failed'

  • Approval transaction succeeded but currentApprovedAmount is still less than requiredApprovedAmount (e.g. user changed transaction data in wallet and enter another approve amount in MetaMask instead of default approve amount proposed by Rango API) => !isApproved && txStatus === 'success'

Check Approval Request

  • requestId *

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

    • Example: b3a12c6d-86b8-4c21-97e4-809151dd4036

  • txId

    • Description: Transaction hash returned by wallet

    • Example: 0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f

public async checkApproval(
    requestId: string,
    txId?: string
): Promise<CheckApprovalResponse>;

Check Approval Response

  • isApproved

    • Description: A flag which indicates that the approve tx is done or not.

  • txStatus

    • Description: Status of approve transaction in blockchain (possible values are success, running and failed)

      if isArppoved is false and txStatus is failed, it means that approve transaction is failed in the blockchain.

  • currentApprovedAmount

    • Description: Required amount to be approved by the user.

  • requiredApprovedAmount

    • Description: Current approved amount by the user.

export type CheckApprovalResponse = {
  isApproved: boolean
  txStatus: TransactionStatus | null
  requiredApprovedAmount: string | null
  currentApprovedAmount: string | null
}

export enum TransactionStatus {
  FAILED = 'failed',
  RUNNING = 'running',
  SUCCESS = 'success',
}
{
  "isApproved": true,
  "txStatus": "suuccess",
  "currentApprovedAmount": 100020003000,
  "requiredApprovedAmount": 100020003000
}

🦎
⚙️
Check Approval TX Statusrango-exchange
Check Approve Transaction Status
Logo