Blackjack
Contract Details
The Blackjack contract is a seat-based game management contract that operates as a single table for up to 3 players. It functions as bookkeeping logic, managing game state, round progression, and token operations while delegating actual game logic to the off-chain server.
The contract's structure is designed to be table-scoped, making it suitable for a multi-table architecture using NEAR sub-accounts, where each sub-account (e.g., table1.blackjack-v3.warsofcards.near) would manage its own isolated game state while sharing token operations through a parent contract.
The contract maintains a tracking of CARDS token usage by players (total_winnings and total_burned). Leaderboard is sorted by total winnings, where only players with at least one win appear.
Objective
Beat the dealer by getting as close to 21 as possible without exceeding it.
Card Values
- Ace: 11 or 1
- Face cards (J, Q, K): 10
- Number cards: face value
Dealer Rules
- Hits on 16 or less
- Stands on 17 or more
- Uses a 6-deck shoe (312 cards)
Actions
- Hit — Draw another card
- Stand — End your turn
- Double Down — Double your bet, receive one card
- Split — Split two equal-value cards into separate hands
Payouts
| Result | Payout |
|---|---|
| Blackjack | 3:2 |
| Win | 1:1 |
| Push | Bet returned |
| Bust | Lose bet |
Payout Examples — Split & Double
Example 1: Mixed Results
- Initial bet: 30
- Split → 2 hands (30 + 30 = 60)
Hand 1:
- Bust → 0 payout
Hand 2:
- Double → bet becomes 60
- Push → 60 returned
Final:
- Total bet: 60
- Total payout: 60
- Net result: Break even
Example 2: Double Blackjacks
- Initial bet: 100
- Split → 2 hands
Both hands:
- Double → 200 each
- Blackjack → 200 × 2.5 = 500
Final:
- Total bet: 400
- Total payout: 1000
- Net result: +600 profit