var ChallengeWindowSeconds
1var ChallengeWindowSeconds int64 = 180 // 3-minute challenge window for settlement proposals
Timeout duration (seconds) for challenge proposals and turn timeouts
1var ChallengeWindowSeconds int64 = 180 // 3-minute challenge window for settlement proposals
Timeout duration (seconds) for challenge proposals and turn timeouts
AcceptDraw accepts a draw offer from the opponent
ClaimTimeout allows the challenger to win the game after the opponent goes AFK/rage quits and turnDeadline has passed without a response move from the opponent.
ConfirmSettlement allows opponent to immediately approve final result without waiting for challenge window
CreateGame creates a new direct game challenge
DeclineDraw declines a draw offer from the opponent
DisputeSettlement allows opponent to dispute a fraudulent settlement proposal
FinalizeSettlement officially finalizes the game after the challenge period has passed
GetActiveGameForPlayer searches for the latest active game ("PLAYING") for a given address. Returns -1 if no active game found.
GetBoard returns the 8x8 board for a given game ID
GetChallengeDeadline returns the deadline unix timestamp for challenging settlement
GetGameStatus returns the game status for a given game ID
GetGamesCount returns the total number of games
GetLatestGameForPlayer returns the latest game ID involving the player, or -1 if none.
GetPendingStatus returns the pending status of settlement
GetQueueCount returns the number of players waiting in the matchmaking queue
GetTurnDeadline returns the deadline unix timestamp for turn timeout
IsInQueue checks if an address is currently waiting in the matchmaking queue
IsWhiteTurn returns whether it is White's turn for a given game ID
JoinQueue registers a player into the on-chain matchmaking queue. If the queue is empty, the player is added to the queue. If another player is already waiting, both players are immediately matched into a new game.
LeaveQueue cancels and removes a player from the on-chain matchmaking queue
MakeMove moves a piece (defaults to Queen on promotion)
1func MakeMovePromote(cur realm, gameID int, fromRow, fromCol, toRow, toCol int, promoPiece string) errorMakeMovePromote moves a piece with a specified promotion piece (Q, R, B, N)
OfferDraw offers a draw to the opponent
ProposeSettlement submits a victory claim for off-chain chess results. Prevents fraudulent opponent moves: proposal opens a challenge period. Opponent can confirm immediately (ConfirmSettlement), or dispute if cheated (DisputeSettlement). If opponent does not respond, winner can finalize after ChallengeWindowSeconds expires. ProposeSettlement submits a victory claim for off-chain chess results. Prevents fraudulent opponent moves: proposal opens a challenge period. Opponent can confirm immediately (ConfirmSettlement), or dispute if cheated (DisputeSettlement). If opponent does not respond, winner can finalize after ChallengeWindowSeconds expires.
Resign resigns the game for the calling player
SettleGame proposes settlement and finalizes immediately if challenge window is 0
StartTurnTimer is initiated when opponent goes AFK or closes browser (Rage Quit) during an off-chain game. Player submits current move history (currentMovesUCI). Smart contract validates the board and ensures it is the OPPONENT'S TURN.
NewGame initializes a new game with the standard chess starting layout
1type Game struct {
2 id int
3 white address // Wallet address of White player
4 black address // Wallet address of Black player
5 board chess.Board // 8x8 chess board from package chess
6 isWhiteTurn bool // True = White's turn, False = Black's turn
7 status string // "PLAYING", "WHITE_WON", "BLACK_WON", "DRAW"
8 castling chess.CastlingRights // Castling rights for White & Black
9 enPassantCol int // Pawn column vulnerable to en passant (-1 if none)
10 drawOfferedBy address // Address of player offering a draw ("" if none)
11 resignedBy address // Address of player who resigned ("" if none)
12 settledBy address // Address of player who recorded final settlement on blockchain ("" if not yet)
13
14 // Anti-Cheat Protection: Proposal & Challenge Period
15 proposedBy address // Player submitting victory claim
16 pendingStatus string // Proposed settlement status ("WHITE_WON", "BLACK_WON", "DRAW")
17 challengeDeadline int64 // Unix timestamp deadline for challenging settlement proposal
18
19 // Anti-RageQuit Protection: Timeout & Abandonment
20 turnDeadline int64 // Unix timestamp deadline for opponent's turn response
21 turnChallengedBy address // Player demanding turn response due to AFK opponent
22}Game represents an on-chain chess game session