# What is Pokebets

### How does it work?

PokéBets relies on smart contract technology to manage the betting system, ensuring transparency and immutability. Each Pokémon battle has two trainers, trainer 1 and trainer 2. Users can place their bets on either of these trainers.

Each Pokémon battle is versioned, meaning all bets associated with a specific battle are related to a particular version of the contract. This allows users to differentiate between different Pokémon battles and to keep track of their winnings and bets.

#### Betting

To place a bet, users call the `battleWager` function in our smart contract, indicating their prediction (either 0 or 1, representing trainer 1 and trainer 2 respectively) and the amount they wish to bet. The contract ensures the user has enough PBetsTokens to cover their bet and then transfers these tokens from the user's wallet to the contract. A small fee is subtracted from the user's bet, with the remainder being added to the total pot for that specific outcome.

The contract safeguards against re-entrancy attacks, ensuring the user cannot call the function again until the first bet placement has fully completed.

Once a bet has been successfully placed, a `BetPlaced` event is emitted to update external systems and interfaces.

#### Claiming Winnings

When the Pokémon battle concludes, the contract owner (usually the platform operator) calls the `resolveBet` function, passing the winning outcome (either 0 or 1). This updates the contract state, and a `BetResolved` event is emitted.

Once the bet has been resolved, users who successfully predicted the outcome can claim their winnings by calling the `winnerClaim` function. The winnings are calculated proportionately based on the user's stake compared to the total amount staked on the winning outcome. A `Claimed` event is emitted when a user successfully claims their winnings.

#### Viewing Information

The contract provides several view functions to help users track their bets and the overall betting outcomes. Functions such as `getTotalBetsForOutcome`, `getUserTotalBets`, `getUserPredictionForOutcome`, `getUserPredictionForOutcomes`, and `getAmountToClaim` provide valuable insights to users about their betting activities and potential winnings.

### Why Blockchain?

By leveraging blockchain technology, PokeBets can provide an open, transparent, and fair betting system. Every bet placed is recorded on the blockchain, ensuring transparency and auditability. The contract rules are defined and immutable, preventing any chance of manipulation. Additionally, the use of PBetsTokens allows for a seamless betting experience, eliminating the need for traditional banking systems.

{% hint style="info" %}
**GitBook tip:** A succinct video overview is a great way to introduce folks to your product. Embed a Loom, Vimeo or YouTube video and you're good to go! We love this video from the fine folks at Loom as a perfect example of a succinct feature overview
{% endhint %}


---

# 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/overview/what-is-pokebets.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.
