---
# System prepended metadata

title: Score Square Explained (needs an update!)

---


# Score Square Explained (needs an update!)

Score Square is an interactive game where players purchase tickets on a 5x5 scorecard grid. Once all 25 tickets are bought, the board is randomized, and a referee submits the final score to determine the winning ticket. 

Score Square tickets can be bought at anytime: before, during and even after a match has concluded.

The referee (the account that deployed the game) has the final say for settling the the payout. If you do not trust the referee, do not buy tickets.

---

## Overview

Score Square allows users to:

- **Purchase Tickets:** Players select the number of tickets they would like.
- **Randomize Board:** Once every ticket is purchased, the board is randomized and tickets represent the final score for the Football match.
- **Submit Final Score:** A designated referee enters the final score of the match. The referee is the person who created to Score Square.
- **Determine Winner:** The winning ticket is determined by the grid cell corresponding to the final score.
- **Claim Prize:** The winner claims a prize calculated from ticket sales minus a deployer's fee.

---

## Architecture

- **Backend:**  
  For now Score Square is offchain in a key-value store to persist game state. This will move onchain soon tm.
  
- **Game States:**  
  - `buying`: Tickets are available for purchase.
  - `placing`: The board is being randomized.
  - `playing`: The match is in progress.
  - `completed`: The match has ended and a winning ticket is determined.
  
- **Frontend:**  
  Implemented with React and Next.js to handle user interactions and display the game state.

---

## Score Grid Explanation

The game is played on a 5x5 grid that represents possible match scores for the two teams.

- **Grid Layout:**
  - **Columns:** Represent the **home team’s score**.
  - **Rows:** Represent the **away team’s score**.

- **Labeling:**
  - Both the columns and rows are labeled as: `0`, `1`, `2`, `3`, and `4+`.
  - **Example:**  
    - The cell at the intersection of the row labeled `2` (away team) and the column labeled `3` (home team) represents a final score of **away: 2, home: 3**.

- **Scores Over 4 Goals:**
  - Since the grid is fixed at 5 columns and 5 rows, any score of 4 or more is labeled as **"4+"**.
  - **Implication:**  
    - If a team scores 4, 5, or more goals, they are recorded as having scored `"4+"`.  
    - For instance, if the home team scores 5 goals and the away team scores 3, the winning ticket is determined by the cell corresponding to row `3` and column `"4+"`.

This labeling keeps the grid simple and fixed in size, while still accommodating high-scoring matches.

---

## Creating a New Game

The `ContestScoreSquareCreate` component allows you to deploy a new game. It includes a form for entering the cost per ticket, and a dropdown for selecting the service fee (from 1% to 10%). The home and away team

<img src="https://hackmd.io/_uploads/rJFnY_SYJg.png" alt="Example Image" width="300" height="300" />

At the moment only the first Score Square deployed for a match is accessible. Eventaully there may be many Score Squares for the same match. 

Additional options for assigning a Referee and increasing the number of tickets sold per game will be implemented.

---

### Settlement 

![image](https://hackmd.io/_uploads/SJfveoQqkl.png)

![image](https://hackmd.io/_uploads/B1G_MiQ9ye.png)

![image](https://hackmd.io/_uploads/ryljlj75Jl.png)



🔹 Expected Format of eventId
The format is:

pgsql
Copy
Edit
{leagueCode}_{division}_{homeTeamAbbr}_{awayTeamAbbr}_{timestamp}
Example:

nginx
Copy
Edit
eng_1_LIV_MCI_20250311180716
🔹 Breakdown of the Example
Part	Example Value	Description
League Code	eng	Represents the country/league (eng for English leagues, usa for MLS, etc.).
Division	1	Represents the division (1 for Premier League, 2 for Championship, etc.).
Home Team Abbr	LIV	Abbreviation of the home team (LIV = Liverpool).
Away Team Abbr	MCI	Abbreviation of the away team (MCI = Manchester City).
Timestamp	20250311180716	The match's scheduled start time in YYYYMMDDHHMMSS format.
![image](https://hackmd.io/_uploads/HywTQgW2Jl.png)


ActiveGamesBrowser
  └── BlockchainScoreSquareDisplayWrapped
    ├── GameMetadataCard
    ├── RefereeCard / RefereeControls
    ├── SquareGrid
    └── CartSection
