> For the complete documentation index, see [llms.txt](https://docs.polypump.app/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.polypump.app/documentation/api-reference/place-a-bet.md).

# Place a Bet

`POST /markets/{id}/bets` – Place a bet on a market outcome.

* **Request:** Provide the market ID in the URL. The JSON body should include the outcome you want to bet on and the amount (and optionally the currency if needed). The request must be signed by the user’s wallet (or the user must have authenticated via an API key tied to their wallet) to ensure the bet is authorized and the funds are available.

```json
POST /markets/market_b7c3d1e0/bets
Content-Type: application/json

{
  "outcome": "No",
  "amount": 10,
  "currency": "SOL"
}
```

This example means the user is betting 10 SOL on the "No" outcome for market\_b7c3d1e0.

* **Response:** On success, the API returns a confirmation with the updated state for that market (or at least the parts affected):

```json
{
  "marketId": "market_b7c3d1e0",
  "outcome": "No",
  "amountStaked": 10.0,
  "newTotalStake": {
    "Yes": 150.0,
    "No": 60.0
  },
  "newOdds": {
    "Yes": 0.7143,
    "No": 0.2857
  },
  "transactionId": "5gHk...zFt", 
  "message": "Bet placed successfully."
}
```

Now the "No" side has a total of 60 SOL (previously 50 + this 10), and the "Yes" side remains 150, so the odds have shifted slightly (Yes down to \~0.714, No up to \~0.286). The response also includes a `transactionId` for the on-chain transaction that recorded the bet, which can be looked up on Solana’s explorer for verification.

If the request fails (e.g., insufficient funds, invalid outcome name, market already closed), an error is returned:

```json
{
  "error": "Bet placement failed: market is already resolved or closed."
}
```

or a relevant message.

**Note:** In a real scenario, placing a bet would involve transferring the amount from the user’s wallet to the smart contract. The API call might return immediately with a pending status while the transaction is confirmed on-chain. A websocket or polling mechanism could be used to confirm when the bet is finalized. The above simplified flow assumes the bet goes through successfully.

#### **Retrieve Results**

As mentioned, once a market is resolved, the outcome and payouts are visible via `GET /markets/{id}`. There may not be a separate “result” endpoint; clients can just fetch the market data to see who won. However, for convenience, an endpoint could exist to specifically fetch resolved outcome and user-specific payout info:

For example, `GET /markets/{id}/result` might return:

```json
{
  "marketId": "market_b7c3d1e0",
  "winningOutcome": "Yes",
  "resolvedAt": "2025-09-11T00:10:00Z",
  "yourWinnings": 0, 
  "claimable": false
}
```

Where `yourWinnings` is what the requesting user won (if the API is authenticated and knows the user’s wallet) and `claimable` indicates if the user still needs to claim (in Polypump, winnings could be automatically sent, so likely claimable is false and funds were auto-transferred). If the user lost, `yourWinnings` would be 0 (as in this example).

**API Usage Notes:** All monetary values are typically given in SOL or in smallest units (LAMPORTS for SOL, or smallest $POLYPUMP unit if applicable). In the examples above, we used floating numbers for readability, but actual API might use strings or integer values (e.g., `"15000000000"` lamports for 15 SOL) to avoid floating-point issues.

The Polypump API is versioned (hence v1 in the base path), and future changes (v2, etc.) might introduce more complex query capabilities, multi-currency support improvements, and endpoints for historical data or leaderboard stats. Always check the latest API documentation for up-to-date information on parameters and responses.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.polypump.app/documentation/api-reference/place-a-bet.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
