> For the complete documentation index, see [llms.txt](https://docs-unified.crypto-chief.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs-unified.crypto-chief.com/guides/payment-status.md). Agents can also search and read this documentation through its [MCP server](https://docs-unified.crypto-chief.com/~gitbook/mcp).

# Payment Status Polling

## Payment Status Polling

When you know the hash of a payment — a customer pasted it, your own system broadcast it — [`GET /v1/transactions/{network}/{hash}/status`](https://docs-unified.crypto-chief.com/api-reference/transactions.md#transaction-status) tells where it stands. It is a small call, built for repeated reads.

### The states

| `status`    | `stage`     | Meaning                                             | Next                                                                                                                                               |
| ----------- | ----------- | --------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `not_found` | `null`      | The network answered and does not know the hash yet | Keep polling for a while; a just-broadcast transaction can take seconds to appear                                                                  |
| `pending`   | `null`      | In the mempool, not in a block                      | Keep polling                                                                                                                                       |
| `success`   | `found`     | In a block, executed                                | Wait for your stage                                                                                                                                |
| `success`   | `confirmed` | Reached the network's confirmed depth               | Credit on TRON once `confirmations` reach your depth                                                                                               |
| `success`   | `final`     | Final                                               | Credit                                                                                                                                             |
| `failed`    | any         | Included and failed; `final` means irreversibly     | Do not credit; the reason is in [the transaction](https://docs-unified.crypto-chief.com/api-reference/transactions.md#get-a-transaction)'s `error` |
| any         | `reorged`   | Its block left the canonical chain                  | Reverse a credit made on it; keep polling — it may return                                                                                          |
| `dropped`   | `null`      | Observed leaving the mempool                        | Stop; it will not be included unless sent again                                                                                                    |
| `replaced`  | `null`      | Replaced by another transaction; see `replaced_by`  | Follow `replaced_by`                                                                                                                               |

`required` gives the depths the network uses: `{"confirmed": 2, "final": 6}` on Bitcoin, `{"confirmed": 2, "final": null}` on TRON.

### Polling

* Poll at roughly the network's block time, with backoff: a few seconds on TRON, Solana, TON and XRP Ledger; 10–15 seconds on Ethereum; a minute on Bitcoin.
* `503` means the network could not be read: retry after `Retry-After`. It never means the payment is missing — only `200` with `not_found` does.
* Give up on `not_found` after a deadline you choose, and on `dropped`.
* For many payments to your own addresses, do not poll each hash: subscribe to them with EventStream.

{% tabs %}
{% tab title="JavaScript" %}

```javascript
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

async function waitForPayment(network, hash, { intervalMs = 5000, notFoundForMs = 10 * 60_000, depth } = {}) {
  const started = Date.now();
  for (;;) {
    const { http, data, headers } = await api("GET", `/transactions/${network}/${encodeURIComponent(hash)}/status`);
    if (http === 503 || http === 429) {
      await sleep(1000 * Number(headers.get("retry-after") ?? 5));
      continue;
    }
    if (http !== 200) throw new Error(`${http} ${data.error}: ${data.message}`);

    if (data.status === "failed") return { credited: false, reason: "failed" };
    if (data.status === "dropped") return { credited: false, reason: "dropped" };
    if (data.status === "replaced") return waitForPayment(network, data.replaced_by, { intervalMs, notFoundForMs, depth });
    if (data.status === "not_found" && Date.now() - started > notFoundForMs) return { credited: false, reason: "not_found" };

    const conf = BigInt(data.confirmations);
    const done = data.required.final === null
      ? data.stage === "confirmed" && conf >= BigInt(depth ?? 19) // TRON: no final
      : data.stage === "final";
    if (data.status === "success" && done) return { credited: true, block: data.block };

    await sleep(intervalMs);
  }
}

const result = await waitForPayment("TRON_MAINNET", "1f3a8b9c0d1e2f3a4b5c6d7e8f9a0b1c2d3e4f5a6b7c8d9e0f1a2b3c4d5e6f7a", { intervalMs: 3000 });
```

{% endtab %}

{% tab title="Python" %}

```python
import time
from urllib.parse import quote

def wait_for_payment(network, hash, interval=5, not_found_for=600, depth=19):
    started = time.time()
    while True:
        status, data, headers = api("GET", f"/transactions/{network}/{quote(hash, safe='')}/status")
        if status in (429, 503):
            time.sleep(int(headers.get("Retry-After", "5")))
            continue
        if status != 200:
            raise RuntimeError(f"{status} {data.get('error')}: {data.get('message')}")

        s = data["status"]
        if s in ("failed", "dropped"):
            return {"credited": False, "reason": s}
        if s == "replaced":
            return wait_for_payment(network, data["replaced_by"], interval, not_found_for, depth)
        if s == "not_found" and time.time() - started > not_found_for:
            return {"credited": False, "reason": "not_found"}

        if data["required"]["final"] is None:  # TRON: no final
            done = data["stage"] == "confirmed" and int(data["confirmations"]) >= depth
        else:
            done = data["stage"] == "final"
        if s == "success" and done:
            return {"credited": True, "block": data["block"]}
        time.sleep(interval)
```

{% endtab %}
{% endtabs %}

### Check what the transaction paid

A successful transaction is not yet the right payment. Before crediting, read [the transaction](https://docs-unified.crypto-chief.com/api-reference/transactions.md#get-a-transaction) and check its transfers: the recipient is your address, the asset and amount are right, and — on XRP Ledger — the `destination_tag` is the customer's. On XRP Ledger the transfer amount is the amount delivered.

### After broadcasting your own transaction

[`POST /v1/transactions/{network}`](https://docs-unified.crypto-chief.com/api-reference/transactions.md#broadcast-a-transaction) returns the hash with `status: "pending"`. Poll `/status` with that hash. If you raise the fee with a replacement, the old hash ends as `replaced` with `replaced_by`, or as `dropped`.
