> For the complete documentation index, see [llms.txt](https://pokebets.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pokebets.gitbook.io/docs/pokebetting-contract/overview.md).

# Overview

This contract facilitates the betting on Pokémon matches streamed on pokebets.io. Users can place their bets in the form of an ERC20 token ($PBETS Token)

### 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.
