> ## Documentation Index
> Fetch the complete documentation index at: https://docs.megapot.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Buy tickets for another wallet (protocol)

You can buy Megapot tickets for another wallet by calling the protocol directly. Set `_recipient` to the recipient's wallet while **you** remain the buyer and payer. The recipient gets ticket NFTs in their own wallet and can win and claim like any other player.

> [!WARNING]
>
> **The megapot.io/gift page has been removed.** Campaign claim links and app giveaways are no longer available. New signups in the Megapot app are closed. The app shuts down on December 1, 2026; the protocol continues to run. [Read Announcement](https://megapot.io/blog/thank-you-for-playing).

> [!NOTE]
>
> **Tickets are never free, you fund every gift.** There is no zero-price primitive (setting a ticket price to 0 reverts). When you buy a ticket for another wallet, **you** pay for it in USDC. The recipient pays nothing.

***

## In code: buy via the recipient param

Every purchase call takes a `_recipient` argument. To send tickets to another wallet, set `_recipient` to **that wallet** while **you** remain the buyer and payer. You approve and spend the USDC, the tickets are minted to them.

Optionally, set `_referrers` to **your own wallet** so you also earn referral fees on the tickets you fund (10% of the ticket fee, plus 10% win-share if those tickets win). See [Referrals & attribution](https://docs.megapot.io/developers/build/referrals-and-attribution.md) for the referrer arrays in detail.

Here is the minimal flow with `Jackpot.buyTickets`: approve USDC to the Jackpot contract, then buy tickets for the recipient:

```typescript theme={null}
import { stringToHex } from "viem";

const JACKPOT = "0x3bAe643002069dBCbcd62B1A4eb4C4A397d042a2";

// Recipient wallet (synthetic example)
const userWallet = "0x1111111111111111111111111111111111111111";
// Your wallet: earns referral fees on the purchase (optional)
const yourWallet = "0x2222222222222222222222222222222222222222";

// 1. Read the live ticket price and ball ranges
const drawingId = await jackpot.currentDrawingId();
const state = await jackpot.getDrawingState(drawingId);
const ticketPrice = state.ticketPrice; // USDC, 6 decimals

// 2. Define the tickets.
//    5 unique normals in [1, state.ballMax]; bonusball in [1, state.bonusballMax].
//    Do NOT hardcode the ranges: read ballMax / bonusballMax from getDrawingState().
const tickets = [{ normals: [7, 14, 21, 28, 30], bonusball: 12 }];

// 3. Approve USDC to the Jackpot contract (the contract that receives payment)
const totalCost = ticketPrice * BigInt(tickets.length);
await usdc.approve(JACKPOT, totalCost);

// 4. Buy: recipient is the other wallet; referrer (optional) is you
const tx = await jackpot.buyTickets(
    tickets,
    userWallet,                       // _recipient: the other wallet
    [yourWallet],                     // _referrers: you (or [] to skip)
    [1000000000000000000n],           // _referralSplit: 100% (1e18), or []
    stringToHex("my-purchase", { size: 32 }) // _source: your analytics label
);
await tx.wait();
// Tickets are minted directly to userWallet
```

The trailing `_source` is a free-form `bytes32` label for **your own** analytics. It does not affect payments. If you skip the referrer, pass empty arrays (`[]`, `[]`) for `_referrers` and `_referralSplit`.

### Buying more than 10, or recurring purchases

Other purchase methods take a `_recipient` too, so you can buy at scale or on a schedule:

* `BatchPurchaseFacilitator.createBatchOrder`: buy more than 10 tickets in one drawing.
* `JackpotAutoSubscription.createSubscription`: drip tickets across multiple drawings.
* `JackpotRandomTicketBuyer.buyTickets`: buy quick-pick tickets with numbers chosen on-chain.

For the full method menu and which one to pick, see [add-to-your-site.md](https://docs.megapot.io/developers/add-to-your-site.md). For exact addresses and signatures, see [build/protocol-reference.md](https://docs.megapot.io/developers/build/protocol-reference.md).

***

## What recipients experience (and KYC)

Recipients receive standard ticket NFTs and can claim any winnings into their wallet without KYC if they never use Megapot's app. The identity rules apply through megapot.io. Once a recipient links the wallet to a Megapot account, all of its prize claims count toward their lifetime prize withdrawal total, and cashing out of a Megapot wallet is checked the same way. See [Identity Verification (KYC)](https://docs.megapot.io/learn/kyc.md).

***

## Track what you sent

Because the buyer is you and the recipient is the other wallet, query the tickets from the recipient's side using the Data API wallet endpoints:

```
GET /v1/wallets/{recipient}/tickets
```

This returns the tickets now held by that wallet, including the ones you bought for them. Pair it with `GET /v1/wallets/{recipient}/wins` to see if they paid off. See [pull-data.md](https://docs.megapot.io/developers/pull-data.md) for auth, pagination, and the rest of the wallet endpoints.

> [!NOTE]
>
> The `_source` label you set on a purchase is **not** queryable through the Data API. Keep your own record if you need to attribute purchases.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.