# Placing Bets

### Function Breakdown

* The function first checks if the state of the contract is `Open`. If not, it reverts the transaction.
* It then checks if the prediction is either 0 or 1, and if the bet amount is greater than 0. If either of these checks fail, the function reverts the transaction.
* The function then calculates the amount to be bet, which is the submitted amount minus the contract's fee.
* The `transferFrom` function of the PBetsToken contract is called, which transfers the bet amount from the user to the contract.
* The details of the bet are then stored in the contract's state variables.
* Finally, a `BetPlaced` event is emitted, with the user's address, their prediction, the bet amount, and the current version of the contract.


---

# 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://pokebets.gitbook.io/docs/pokebetting-contract/placing-bets.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.
