Transactions APIs
1. Create Transaction (Test)
In the Basic API, you could get the transaction via swap endpoint (the tx
field). Please check this link for more information on this:
2. Check Transaction Status (Test)
After that user signed a transaction on his/her wallet you should call this endpoint periodically to see what's the status of that transaction.
This endpoint is not suitable for checking approval tx and it is only for the original transaction. For checking approval transaction status, please check this section.
In on-chain transactions, you could also check transaction status by checking transaction receipt (via RPC) if you prefer. But in cross-chain swaps (bridges, ...) it's necessary to use this endpoint to make sure outbound transaction (transaction on destination chain) succeeeds without any problem.
Check Transaction Status Request
Param | Description |
---|---|
requestId * | The unique ID which is generated in the swap endpoint. |
txId * | Tx hash that wallet returned, e.g. 0xa1a37ce2063c4764da27d990a22a0c89ed8... |
Check Transaction Status Response
Field | Description |
---|---|
status | Status of the transaction, while the status is |
error | A message in case of failure, that could be shown to the user. |
output | The output asset and amount, could be different from the destination asset in case of failures and refunds. These are different output types possible:
|
explorerUrl | List of explorer URLs for the transactions of this swap. (Inbound TX link, Outbound TX link, ...) |
diagnosisUrl | If a refund is needed for the swap, we will return a diagnosis URL for the user. This URL will guide him on how to refund his/her money. Sample value: https://rango.exchange/diagnosis/wormhole |
bridgeData | Status of bridge. At the moment, this field is only filled when we have a bridge/swap transaction between two EVM chains. (e.g. from Polygon to Avax) |
3. Check Approval Status (Test)
In EVM
, TRON
and STARKNET
txType
blockchains where swap
returns a non-null value for approve tx (e.g. approveData
and approveTo
fields in case of the EVM
), you need to use these values to show approve transaction to the user and call isApproved
periodically to see if the approval tx is completed. After a successful check, you should create the main transaction.
Notice:
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.
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.
You could stop checking approval endpoint 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 and enter another approve amount in MetaMask instead of default approve amount proposed by Rango API) => !
isApproved && txStatus === 'success'
Check Approval Request
Param | Description |
---|---|
requestId * | The unique ID which is generated in the best route endpoint. |
txId * | Tx hash that wallet returned for approve tx, e.g. 0xa1a37ce2063c4764da27d990a22a0c89ed8... |
Check Approval Response
Field | Description |
---|---|
isApproved | A flag which indicates that the approve tx is done or not. |
txStatus | Status of approve transaction in blockchain (possible values are if |
requiredApprovedAmount | Required amount to be approved by user |
currentApprovedAmount | Current approved amount by user |
4. Report Transaction Failure
Use it when the user rejects the transaction in the wallet or the wallet fails to handle the transaction. Calling this endpoint is not required, but is useful for reporting and we recommend calling it.
It's an optional action and does not affect the flow of swap, but it can help us improve our API if the data is informative enough
Report Failure Request
Param | Description |
---|---|
requestId * | The unique ID which is generated in the best route endpoint. |
eventType * | Type of failure. possible values are:
|
reason * | Failure reason |
tags | An optional dictionary of pre-defined tags. Current allowed tags are |
Last updated