> For the complete documentation index, see [llms.txt](https://betfin.gitbook.io/betfin-public/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://betfin.gitbook.io/betfin-public/smartcontracts-description/roulette.md).

# Roulette

The `Roulette` smart contract is a part of a decentralized gaming platform, specifically designed to handle the logic and operations related to playing a game of roulette. It leverages the Ethereum blockchain for transparency, fairness, and security. The contract employs Chainlink's Verifiable Random Function (VRF) to ensure the randomness of roulette spins, integrates with a dynamic staking system, and adheres to the game interface standard defined within the platform.

### Key Features

* Implements [Chainlink VRF](https://vrf.chain.link/) for provably fair randomness.
* Integrates with a [Dynamic staking](broken://pages/YI0AkYvS8rrR8KFrH7Dk) mechanism for handling bets and payouts.
* Enforces betting limits and validates bet data.
* Non-reentrant to prevent re-entrancy attacks.
* Emits events for key actions: bet placement, spin result, etc.

#### Variables <a href="#variables" id="variables"></a>

* `REQUIRED_FUNDS_COEFFICIENT`: Multiplier for validating sufficient balance.
* `subscriptionId`, `vrfCoordinator`, `keyHash`: Chainlink VRF configuration.
* `limits`: Struct mapping defining minimum and maximum bet sizes.
* `staking`, `core`: Addresses for the [staking](broken://pages/YI0AkYvS8rrR8KFrH7Dk) and [core](broken://pages/1Qngro7f28fSq5sUYJak) contracts.

### Functions

**Public and External**

* `getPossibleWin`: Calculates the maximum possible win for given bet data.
* `placeBet`: Initiates a roulette spin request for a player. Validates bet data, requests randomness, and records the bet.
* `getAddress`, `getVersion`, `getFeeType`, `getStaking`: Interface implementations providing contract details.
* `setLimit`: Updates minimum and maximum bet sizes for a specific bet type.

#### Events

* `Rolled`: Emitted when a roulette spin is requested.
* `Landed`: Emitted with the result of a roulette spin.
* `LimitChanged`: Emitted when bet limits are updated.
