# Overview

### Contract Basics

* **PBetsToken**: This is the token users will use to place bets. It is an ERC20 token.
* **States**: This contract has three possible states - Open, Closed, and Resolved. The contract state determines whether users can place bets, and whether they can claim their winnings.
* **Bet Details**: Users' bets are stored in several mappings, which record details about each placed bet, the total bet amount for each outcome, and the total bet amount of each user.

### Contract Mechanics

#### Betting

The betting process is handled primarily by the `battleWager` function, which allows a user to place a bet on a prediction (either 0 or 1, representing Trainer 1 or Trainer 2 respectively). Bets can only be placed when the contract is in the `Open` state. A fee is taken from each bet, which is stored in the contract balance.

#### Claiming Winnings

The `winnerClaim` function allows a user to claim their winnings once the bet has been resolved. This function can only be called when the contract is in the `Resolved` state, and it pays out proportional to the amount that the user bet on the winning outcome.

#### Withdraw Contract Fees

The `withdrawContractFees` function can be called by the owner of the contract to withdraw the accumulated fees from 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/overview.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.
