> For the complete documentation index, see [llms.txt](https://docs.megapot.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.megapot.io/build-on-megapot/build/claiming.md).

# Claim Winnings & Fees

Two kinds of payout matter to an integration: the **winnings** your users earn, and the **referral fees** you earn. Both are pull-based. Nothing is sent automatically, so a claim function has to be called. Here is how each one works.

## Users claiming winnings

After a drawing settles, any winnings sit as a claimable balance against the winning ticket NFTs until claimed. In your app, surface the claim and call it on the user's behalf (they sign the transaction):

1. Find the user's winning tickets for a settled drawing. You can detect winners with on-chain reads, or list a wallet's wins across many drawings with the [Data API](/build-on-megapot/pull-data.md) (`GET /v1/wallets/{address}/wins`).
2. Call `Jackpot.claimWinnings(uint256[] _ticketIds)` with those ticket IDs. Winnings pay out in USDC to the ticket owner.

{% hint style="info" %}
The full win-detection and claim recipe (tier lookup, batching large claims) is at [llms.megapot.io](https://llms.megapot.io). Use the [Data API](/build-on-megapot/pull-data.md) when you need a wallet's unclaimed wins across drawings.
{% endhint %}

## Claim and re-buy in one step (auto-compound)

To let a user roll their winnings straight into new tickets in a single transaction, use auto-compound instead of a plain claim.

* **Contract:** `TicketAutoCompoundVault.depositAndCompound(...)`
* **What it does:** claims the winnings and buys new tickets in one call.
* **You still earn:** it takes the same trailing `_referrers`, `_referralSplit`, and `_source` arguments as a purchase, so your referral fees apply to the re-buy.

See the [Protocol Reference](/build-on-megapot/build/protocol-reference.md) for the full signature.

## Claiming your referral fees

Your referral earnings (ticket fees plus win-share from users you referred) accrue as a claimable USDC balance inside the `Jackpot` contract.

**Read your claimable balance** (USDC, 6 decimals):

```typescript
const claimable = await jackpot.referralFees(yourAddress);
const claimableUsdc = Number(claimable) / 1e6;
```

**Withdraw the full balance** (there is no minimum):

```typescript
await jackpot.claimReferralFees();
```

This transfers everything you have accrued to your wallet in one call. For how those fees are set, split, and rated, see [Referrals & Attribution](/build-on-megapot/build/referrals-and-attribution.md).

***

**Next:** [Referrals & Attribution](/build-on-megapot/build/referrals-and-attribution.md) · [Protocol Reference](/build-on-megapot/build/protocol-reference.md) · [Add the jackpot to your site](/build-on-megapot/add-to-your-site.md)
