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

Was this helpful?

  1. API Integration
  2. Basic API - Single Step
  3. API Reference

Check Approve Transaction Status

Check status of approve transaction

PreviousCheck Transaction StatusNextGet Address Assets & Balances

Last updated 9 months ago

Was this helpful?

Check Approval API

In EVM, TRON and STARKNET blockchains where returns a non-null value for approve transaction (e.g. approveData and approveTo fields in case of the EVM), you need to use these values to prepare the approve transaction for the user and call isApproved periodically to see if the approval transaction is completed. After a successful check, you should ask the user to sign the main transaction.

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 the route.

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.

const transaction = await rango.isApproved(
    requestId = 'e4b0d1e7-ae1f-4aed-ab91-f1ea3ba9383b',
    txId = '0xd7a18c6e2f9afe5aefd1b5969f753513f01c6670a4fc57a2d1349ad539ae2f7f'
)
const response = await axios.get('https://api.rango.exchange/basic/is-approved', {
  params: {
    'requestId': 'e4b0d1e7-ae1f-4aed-ab91-f1ea3ba9383b',
    'txId': '0xd7a18c6e2f9afe5aefd1b5969f753513f01c6670a4fc57a2d1349ad539ae2f7f',
    'apiKey': 'c6381a79-2817-4602-83bf-6a641a409e32'
  }
});
curl --request GET \
     --url 'https://api.rango.exchange/basic/is-approved?requestId=e4b0d1e7-ae1f-4aed-ab91-f1ea3ba9383b&txId=0xd7a18c6e2f9afe5aefd1b5969f753513f01c6670a4fc57a2d1349ad539ae2f7f&apiKey=c6381a79-2817-4602-83bf-6a641a409e32' 

You could stop checking is-approved method if:

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

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

  3. 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 * String

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

    • Example: e4b0d1e7-ae1f-4aed-ab91-f1ea3ba9383b

  • txId * String

    • Description: Transaction hash that wallet returned for approve transaction.

    • Example: 0xd7a18c6e2f9afe5aefd1b5969f753513f01c6670a4fc57a2d1349ad539ae2f7f

function isApproved(requestId: string, txId?: string)

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.

  • requiredApprovedAmount

    • Description: Required amount to be approved by user

  • currentApprovedAmount

    • Description: Current approved amount by 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": "success",
    "currentApprovedAmount": "0.903658",
    "requiredApprovedAmount": "0.903658"
}

πŸ¦„
βš™οΈ
Check Approval TX Statusrango-exchange
Check Approval Transaction Status Swagger
Logo
swap