# Purchase Flow

![Market item detail + purchase view](/files/eAnt2tmcnjr1DH3zo7UG)

## Step-by-Step

1. Open **MARKET** app.
2. Browse categories (skin / arena / badge / powerup / pack / pfp).
3. Tap an item → see preview + price.
4. Tap **BUY**.
5. Wallet popup → approve the SOL transfer to treasury.
6. Server verifies on-chain:
   * TX exists
   * Sender matches your connected wallet
   * Amount matches the server-side price table
   * Destination matches treasury wallet
7. Item added to your `market_purchases` → appears in Locker immediately.

## Anti-Replay Protection

Every market purchase TX signature is **UNIQUE-indexed** in the database (migration 016). A signature can only be used once. Attempting to replay a previous purchase TX → 409 error, no item granted.

## Failed Purchases

If the on-chain verification fails (TX not found yet, wrong amount, wrong destination, sig already used):

* The item is NOT granted
* Your SOL is still on-chain wherever the TX sent it — usually you didn't actually approve a transfer if the verify failed
* If you did transfer SOL but the verify failed (e.g., RPC race condition), the SOL went to treasury and you can report it in the support topic on Telegram with the TX hash for manual investigation

## Why On-Chain Verify

We don't trust the client. The flow is:

1. Client claims a purchase happened
2. Server fetches the TX from RPC and validates it
3. Only on validated TX does the item grant happen

This prevents a malicious client from sending fake "I bought X" requests.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.snake-os.com/market-and-locker/purchases.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
