@react-casino-games-demo/dice
v1.3.0
Published
Dice game component — publishable build.
Readme
@react-casino-games-demo/dice
The Dice game component.
Install
pnpm add @react-casino-games-demo/dicePeer deps: [email protected], [email protected].
Usage
import { Dice } from '@react-casino-games-demo/dice'
<Dice
balance={balance}
onBet={async (bet) => placeBet(bet)}
onResult={(result) => recordResult(result)}
/>Props
Dice accepts DiceProps (an alias of GameProps), exported by this package:
import type { DiceProps, GameProps, BetRequest, BetResult } from '@react-casino-games-demo/dice'| Prop | Type | Description |
| ---------- | ----------------------------------------- | --------------------------------------------------------------------------- |
| balance | number | Current player balance, used to display funds and gate betting. |
| onBet | (bet: BetRequest) => Promise<BetResult> | Called when the player places a bet. Resolve with the settled BetResult. |
| onResult | (result: BetResult) => void | Called after each settled bet, e.g. to append to bet history. |
Contract types
type Currency = 'USD' | 'EUR' | 'BTC' | 'ETH'
type BetOutcome = 'win' | 'loss'
type BetRequest = {
amount: number
currency: Currency
gameId: string
payload: Record<string, unknown>
}
type BetResult = {
betId: string
multiplier: number
payout: number
outcome: BetOutcome
payload: Record<string, unknown>
}
type GameProps = {
balance: number
onBet: (bet: BetRequest) => Promise<BetResult>
onResult: (result: BetResult) => void
}Dice sends bets with gameId: 'dice' and a payload containing the chosen rollUnder target.
