Check Approve Transaction Status

Check status of approve transaction

Check Approval API

In EVM, TRON and STARKNET blockchains where swap 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'
)

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

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

Last updated