Account overview
All state accounts use Borsh serialization for efficient on-chain storage:| Account Type | Size | Purpose |
|---|---|---|
| GameState | 96 bytes | Stores game configuration and current state |
| PlayerState | 32 bytes | Tracks individual player statistics per game |
| Bid | 48 bytes | Records individual bid details |
state.rs:32-34 for size constants.
GameState
Stores the complete state of a bidding game. One GameState account exists per game.Structure
state.rs:4-15 for the struct definition.
Fields
Unique identifier for this game. Used as a seed for PDA derivation.
The first bid amount in lamports. Must be at least 14,000,000 lamports (0.014 SOL). This value is set at game creation and never changes.
Current highest bid amount in lamports. Updated each time a new bid is placed. Initially set to
initial_bid_amount.Unix timestamp of the most recent bid. Used to enforce the 10-minute (600 second) timeout rule. Games automatically end if no bid is placed within 600 seconds.
Total number of bids placed in this game. Starts at 1 (initial bid) and increments with each PlaceBid instruction. Used for PDA derivation and race condition prevention.
Public key of the most recent bidder. This player will win the game if no one outbids them within 10 minutes.
Total SOL accumulated in the game (sum of all bids). Distributed to winners and royalty recipients when the game ends.
Percentage of prize pool taken as platform fee. Currently hardcoded to 10 (representing 10%).
Flag indicating whether the game has concluded. Once true, no more bids can be placed.
Account size
The GameState account is exactly 96 bytes:- 8 u64 fields × 8 bytes = 64 bytes
- 1 Pubkey field × 32 bytes = 32 bytes
- 1 bool field × 1 byte = 1 byte
- Total: 97 bytes (likely padded to 96 in actual implementation)
Deserialization
The program includes a custom deserializer for GameState:utils.rs:98-127 for implementation.
Example state
PlayerState
Tracks statistics for a single player’s participation in a game. One PlayerState account is created per bid (not per unique player - a player bidding multiple times will have multiple PlayerState accounts).Structure
state.rs:17-24 for the struct definition.
Fields
The bid amount in lamports that this player placed. Stored for reference and royalty calculations.
Indicates whether this player’s funds are safe (they received their payout). Set to
true when:- Player wins the game and receives the prize
- Player receives royalty distribution as an early bidder
false when the account is created.Amount of royalty/winnings this player has earned in lamports. Updated when the game ends and distributions are made. Remains 0 for players who don’t receive payouts.
The bid sequence number when this player state was created. Matches the bid count in the PDA seeds. Used to uniquely identify this player state.
Account size
The PlayerState account is exactly 32 bytes:- 3 u64 fields × 8 bytes = 24 bytes
- 1 bool field × 1 byte = 1 byte
- Padding: ~7 bytes
- Total: 32 bytes
Deserialization
The program includes a custom deserializer for PlayerState:utils.rs:129-145 for implementation.
Each bid creates a new PlayerState account, even if the same player bids multiple times. This allows tracking each bid independently for royalty calculations.
Example state
Bid
Records details of a single bid. One Bid account is created for each bid placed in the game.Structure
state.rs:25-31 for the struct definition.
Fields
Public key of the account that placed this bid. Used to identify the bidder for prize distribution.
Bid amount in lamports. Must be at least 2x the previous highest bid (except for the initial bid).
Unix timestamp when this bid was placed. Retrieved from the Solana Clock sysvar.
Account size
The Bid account is exactly 48 bytes:- 1 Pubkey field × 32 bytes = 32 bytes
- 2 u64 fields × 8 bytes = 16 bytes
- Total: 48 bytes
Bid history
The program provides a utility function to fetch all bids for a game:- Iterates through bid numbers 1 to
total_bids - Derives the PDA for each bid
- Deserializes the Bid data
- Returns a vector of all bids in order
utils.rs:46-81 for implementation.