# File a claim

> From a breached receipt to a payout: what the SDK checks, when to claim, what the Claims contract returns, and every error you can meet.

*LOPW documentation · Guides.* Canonical page: https://lopw.com/docs/guides/file-claim.html · This Markdown twin: https://lopw.com/docs/guides/file-claim.md · Index of all pages: https://lopw.com/llms.txt · Everything in one file: https://lopw.com/llms-full.txt

A claim is one transaction with one outcome. The SDK builds it from the record it kept at payment time.

1. Fetch through the SDK. After payment it evaluates every predicate and lists any breaches on `warranty.breaches`. If `warranty.problems` is non-empty the response is untrusted and **cannot** be claimed.
2. Call `agent.claim(warranty)` before `warranty.claimableUntil`. It uses the first breach unless you pass a predicate ID; for P1 it attaches the duplicate receipt automatically.
3. Read the result: `{ outcome: { paid: amount } | { rejected: "not_proven" | "not_verifiable" }, transaction }`.

**TypeScript**

```ts
const { warranty } = await agent.fetch(url);
if (warranty && !warranty.problems.length && warranty.breaches.length) {
  const result = await agent.claim(warranty, warranty.breaches[0]);
  if ("paid" in result.outcome) console.log("paid", result.outcome.paid, "tx", result.transaction);
  else console.log("rejected:", result.outcome.rejected);
}
// Later: const open = await agent.store.list();   // records whose claim windows are still open
```

**Contract call**

*Claims contract*

```text
claim(predicate_id: u32, offer: SignedOffer, receipt: SignedReceipt, extra: ClaimExtra) -> Result<ClaimOutcome, ClaimError>
// extra = SecondReceipt(SignedReceipt) for P1, None otherwise
// ClaimOutcome = Paid(i128) | Rejected(1 NotProven | 2 NotVerifiable)
```

| Fact | Detail |
| --- | --- |
| Who may submit | Anyone holding the evidence. The payout always goes to `receipt.buyer`. |
| Claim window | Starts at `served_at`; lasts the terms’ `claim_window` (at most 24 hours; at most one hour when P6 is offered). |
| Payout | `min(offer.max_claim, stake remaining)`, also capped by the launch limit `max_payout` when one is set, and subject to the slash rate limit. |
| Recorded outcomes | `Paid(amount)` emits `ClaimPaid`. `Rejected(NotProven \| NotVerifiable)` emits `ClaimRejected` and does not block a later valid claim for the same payment. |
| Errors (nothing recorded) | `UnknownService`, `BadSignature`, `OfferMismatch`, `WindowClosed`, `AlreadyClaimed`, `PredicateNotOffered`, `NoStake`, `ValidatorNotSet`, `KeyRetired`, `UnsupportedVersion`, `SlashRateLimited`. Full table in the [claims reference](https://lopw.com/docs/protocol/claims.html#errors). |
| Rate limited? | `SlashRateLimited` means this service already paid out 50% of its epoch-start stake in the current epoch. Retry in the next epoch if the window is still open. |
| Fees | The submitter pays the normal transaction fee, including the oracle read for P6. A rejected claim costs the fee and nothing else. |

Keep evidence: the `FileReceiptStore` keeps every record until its claim window closes and survives restarts. You can also call `binding.submitClaim(signer, predicateId, offer, receipt, secondReceipt?)` directly with evidence obtained elsewhere.
