# Check  Approve Transaction Status

## Check Approval Status API

When `createTransaction` returns an `approval` transaction (i.e. `isApproval`field 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.

{% tabs %}
{% tab title="Typescript (SDK)" %}

```typescript
const transaction = await rango.checkApproval({
    requestId: "b3a12c6d-86b8-4c21-97e4-809151dd4036", // bestRoute.requestId
    txId: "0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f" // optional
})
```

{% endtab %}

{% tab title="Node.js (Axios)" %}

```typescript
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'
  }
});
```

{% endtab %}

{% tab title="Bash (cURL)" %}

```bash
curl --request GET \
     --url 'https://api.rango.exchange/tx/b3a12c6d-86b8-4c21-97e4-809151dd4036/check-approval?txId=0x7f17aaba51d1f24204cd8b02251001d3704add46d84840a5826b95ef49b8b74f&apiKey=c6381a79-2817-4602-83bf-6a641a409e32' 
```

{% endtab %}
{% endtabs %}

{% embed url="<https://rango-api.readme.io/reference/checkapproval>" %}
Check Approve Transaction Status
{% endembed %}

{% hint style="info" %}
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.
{% endhint %}

{% hint style="warning" %}
**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.
{% endhint %}

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&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`requestId`** <mark style="color:red;">\*</mark>&#x20;
  * 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`
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

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

{% endtab %}
{% endtabs %}

### Check Approval Response&#x20;

{% tabs %}
{% tab title="API Definition" %}

* **`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.
    {% endtab %}

{% tab title="SDK Models (Typescript)" %}

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

export enum TransactionStatus {
  FAILED = 'failed',
  RUNNING = 'running',
  SUCCESS = 'success',
}
```

{% endtab %}

{% tab title="Sample Response" %}

```json
{
  "isApproved": true,
  "txStatus": "suuccess",
  "currentApprovedAmount": 100020003000,
  "requiredApprovedAmount": 100020003000
}
```

{% endtab %}
{% endtabs %}
