# Order tracking

> The LayerHop order lifecycle (built, submitted, pending, filled, refunded, failed, expired, dropped), how to report a broadcast, poll provider status, list orders by address, or get webhooks.

Source: https://docs.layerhop.com/concepts/order-tracking

To track a LayerHop order, report the broadcast transaction with `POST /v1/orders/{quoteId}/submitted`, then either poll `GET /v1/orders/{provider}/{id}` with the source transaction hash or let LayerHop's tracker call your [webhook](/guides/webhooks) when the order is filled, refunded or failed.

## What is the order lifecycle?

Every `POST /v1/orders` records an order. Its status moves through these values:

| Status | Meaning | Final? |
|---|---|---|
| `built` | The transaction was built; nothing is on chain yet | no |
| `submitted` | The source transaction hash was reported | no |
| `pending` | The provider sees the order in flight | no |
| `filled` | Delivered to the recipient | yes |
| `refunded` | Not filled; funds returned to the sender | yes |
| `failed` | The source transaction reverted, or tracking gave up after 24 hours | yes |
| `expired` | Built, but no transaction was reported within 1 hour (or the reported one was rejected) | yes |
| `dropped` | The reported transaction never reached the network (dropped, cancelled or replaced in the wallet). No funds moved | yes, until a new hash is reported |

```text
built → submitted → pending → filled | refunded | failed
built → expired   (no transaction within 1 h)
submitted → dropped   (the source chain never saw the transaction)
```

## How do I report the broadcast transaction?

After the wallet sends the transaction, call:

```http
POST /v1/orders/{quoteId}/submitted
{ "txHash": "0x…" }
→ { "quoteId": "q_…", "status": "submitted", "verified": true }
```

The call is idempotent. An `expired` order can still be reported if the transaction was broadcast late. `POST /v1/orders/submit` (the [submitViaApi flow](/concepts/submit-via-api)) reports automatically. The SDKs call this `reportSubmitted`.

### How is the reported hash checked?

Anyone who knows a `quoteId` can call this endpoint, so LayerHop checks the hash on the source chain before it counts:

- **EVM:** the transaction (pending is fine) must be sent by the quote's `sender` to the contract the order was built for. A smart-wallet call that contains the built calldata also passes.
- **Solana:** the quote's `sender` must have signed the transaction.

| Result | What happens |
|---|---|
| Found and matches | Recorded with `verified: true`. The hash is final: a different one returns [`CONFLICT`](/errors/CONFLICT). |
| Found but doesn't match | [`INVALID_PARAMS`](/errors/INVALID_PARAMS); nothing changes (a checkout session isn't touched). |
| Not visible yet | Recorded as provisional, `verified: false`. Report the same hash again later to confirm it. |

A provisional hash doesn't block the real one: a different hash that verifies replaces it (the API waits a few seconds for a just-broadcast transaction to appear; if it still isn't visible, you get `CONFLICT` and can retry). The tracker also checks provisional hashes: one that turns out not to be the sender's is released, and the order goes back to `expired` with the reason in `statusDetail`, ready for the real report. Test-mode orders accept any well-formed hash.

## How does LayerHop track orders server-side?

A background worker picks up `submitted` and `pending` orders and asks the provider for their status:

- Checks run every 5 seconds for the first half minute, then back off to 10 s, 15 s, 30 s, 1 minute, then every 5 minutes.
- Every change is visible right away on the [live status stream](/guides/live-status) (`GET /v1/orders/{quoteId}/events`).
- Same-chain swaps (Jupiter, 0x, KyberSwap) are confirmed from the transaction receipt or signature status on chain: success is `filled`, a revert is `failed`.
- A provisional hash (see above) is checked on chain first; if it isn't the sender's transaction, it is released and the order becomes `expired`.
- A `submitted` order whose transaction neither the provider nor the source chain knows is checked for a dropped transaction (see below).
- After 24 hours without a final state, the order becomes `failed` with detail `timeout`.
- Each status change emits a webhook event (`order.submitted`, `order.filled`, `order.refunded`, `order.failed`, `order.dropped`) to the endpoints of the account whose API key created the quote. See [Webhooks](/guides/webhooks).

### What happens when a transaction is dropped?

A wallet can report a hash that never lands: the gas was too low, the user cancelled it, or sped it up under a new hash. Once the grace period since the report has passed (20 minutes on EVM chains, 5 minutes on Solana, where the blockhash has expired by then, 10 minutes on Tron), the tracker asks the source chain whether it knows the hash at all, pending transactions included. After 3 checks in a row that don't find it, the order becomes `dropped` and `statusDetail` says why. RPC errors never count as a miss.

On EVM chains, a transaction the tracker saw once (in the mempool) is dropped once the sender's nonce has moved past it (after the same grace period and checks), because another transaction with that nonce was mined. If the nonce hasn't moved, it waits three times the grace period in case the wallet re-broadcasts it.

A `dropped` order is final: no funds moved and there is nothing to refund, so it never counts as a fill or as a provider failure. Its hash counts as provisional again, so if the wallet sent a replacement, report the new hash with `POST /v1/orders/{quoteId}/submitted`; once it verifies on chain, the order goes back to `submitted`. Otherwise get a new quote and try again.

## How do I poll a provider's status directly?

```text
GET /v1/orders/{provider}/{id}
→ { provider, id, state, srcTxHash?, dstTxHash? }
```

`provider` is the `provider` field of the quote you executed. This endpoint asks the provider and returns its `state`. Answers are cached per order for about 12 seconds (10 minutes once final), so polling faster returns the same answer:

| State | Meaning |
|---|---|
| `pending` | In flight: source confirmed, destination not yet delivered |
| `filled` | Delivered |
| `refunded` | Refunded to the sender |
| `failed` | Failed; check the source transaction |
| `unknown` | The provider cannot tell yet, or does not track this kind of order |
| `dropped` | The provider doesn't know the transaction and LayerHop's order for it is `dropped`: it never reached the network. Stop polling and re-quote |

`id` must look like a transaction hash or order id (`0x` + 64 hex, or a Solana signature); anything else is [`INVALID_PARAMS`](/errors/INVALID_PARAMS). A well-formed id the provider doesn't know answers `state: "unknown"`, not an error: providers can't tell a transaction they haven't indexed yet from one that never existed. [`ORDER_NOT_FOUND`](/errors/ORDER_NOT_FOUND) is returned only when the provider says the order doesn't exist (deBridge, for an order id).

### Which id do I pass?

| Provider | `id` |
|---|---|
| `relay` | Source transaction hash, or Relay's request id |
| `debridge` | Source transaction hash (EVM hash or Solana signature), or a DLN order id |
| `lifi` | Source transaction hash |
| `mayan` | Source transaction hash |
| `jupiter`, `zerox`, `kyberswap` | Anything; always `unknown`, confirm on chain instead |

Same-chain swaps settle inside the transaction itself. Confirm it with `waitForTransactionReceipt` on EVM or `getSignatureStatuses` on Solana; if it succeeded, the swap is done.

## How do I list a wallet's orders?

```text
GET /v1/orders?address=<sender or recipient>&status=&cursor=&limit=
→ { orders: [...], nextCursor }
```

It returns public order fields (status, provider, chains, tokens, amounts, fee bps, hashes, timestamps), newest first, 1 to 200 per page (default 50). EVM addresses match case-insensitively. Orders with no reported transaction yet (`built`, or `expired` without one) appear only for an API key of the account that built them; the dashboard lists them all. See [List orders by address](/api-reference#list-orders-by-address).

## How do I poll with the SDK?

```ts
for await (const s of lh.watch("relay", srcTxHash, { intervalMs: 3000, timeoutMs: 30 * 60_000 })) {
  render(s.state, s.dstTxHash);
}
```

`watch()` yields only when the state changes and stops at `filled`, `refunded`, `failed` or `dropped`, or after `timeoutMs` (30 minutes by default).

## What should I watch out for?

- Right after broadcasting, providers may answer `unknown` or `pending` until they index the source transaction. Keep polling; `unknown` is not a failure.
- Link the user to the explorer: every chain in [`GET /v1/chains`](/api-reference#list-chains) has an `explorerTx` prefix.
- When the provider can't answer (it is rate limiting, erroring or slow), you get the last answer LayerHop had for that order, or for a LayerHop order the status LayerHop last recorded. With nothing to fall back on, the call fails with [`PROVIDER_ERROR`](/errors/PROVIDER_ERROR) or [`PROVIDER_TIMEOUT`](/errors/PROVIDER_TIMEOUT); keep polling. A provider's rate limit never comes back as `429`: [`RATE_LIMITED`](/errors/RATE_LIMITED) only means you went over your own limit, so back off.
