Super Bowl Squares on Solana
Tags: solana, rust, react, nextjs
Published: 2024-02-10 22:15:16

[Super Bowl Squares on Solana
](https://squares.gg)

For as long as I can remember, every time the Super Bowl came around, me and the boys would play this game called Super Bowl Squares.

It's a wager game. You buy real estate on a 10x10 grid that represents every possible score. If you own the square that represents the score when each quarter ends, you get a payout. 

Hell, ChatGPT can explain it better than me:

> There's a 10x10 grid, 100 squares up for grabs. Each square is gonna end up with a pair of digits – one for each team playing. These numbers reflect the last digit of each team's score at the end of a quarter. Nail the matching score at quarter's end, and boom – you score some cash.

> Example: If the score's 21-17 when the quarter ends, and you've got the square with 1 for Team A and 7 for Team B, you're the winner for that quarter.

So even if your team isn't playing in the Super Bowl, you're super invested in the score of each quarter of the game.

I promise, if you play this game, you won't just be watching for the commercials. 

## Why put this on the blockchain?

Over time, we built the below Google sheet.

![This year's spreadsheet](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zttbqhrcpv1he2mk83d2.png)

If you notice on the right, we've got a centralized treasurer (read: escrow) who we cash app our $5 per square to.

Since Google sheets has the ability for collaboration, we can go in and add our names to the squares we want to purchase. 

Sure, this works fine. This is a big improvement on our system from a few years prior, where the spreadsheet was entirely controlled by the treasurer. But it's still a very manual process.

This is a [fairly popular game](https://www.superbowlsquares.org/how-to-play), and I imagine a lot of people do not have a cracked-out Google sheet like we do. A very popular sports site [published a printable sheet](https://www.sportingnews.com/us/nfl/news/printable-super-bowl-squares-grid-2024/eeb51d69301dcb1617d36a53) where you and your crew would have to write everything down on paper!

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rr4m1sj6cw31mjgufjk2.png)

By putting this on-chain, we remove the treasurer, all actions are automated, and there's near zero overhead of creating new games.

Imagine if our treasurer had a few different groups of friends that they wanted to play with. Even with our Google sheet, that is a lot of overhead.

By bringing this on-chain, you create a game at a click of a button, and share the link with your friends. That's it.

## How it works

### Board setup

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/trxzpplldnrd0j43eign.png)

You start with an empty 10x10 grid with unlabeled x and y-axis headers.

Each square has a set cost. IRL, we usually do $5 a square, which amounts to a $500 pot with 5 $100 payouts.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12cd3nprdvi3eqc6afl7.png)

Each player selects the squares they want to purchase, which are denoted by a sticky note colored background and the total cost is shown on the purchase button.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lylnvsc550uag28xu6o2.png)


After the squares are purchased, they'll turn a new color and contain the first two letters of the buyer's wallet address. The players legend to the left of the board is also updated.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/96v3is351osi7p3y1kmt.png)


Once all 100 squares are purchased, the `Purchase Squares` button turns into a `Finalize Board` button. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qnbtrn3sz4qhx45dfl3i.png)

This tells the contract to generate the x and y-axis headers.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/misrr8bum8x7v0yew7z1.png)

Once the actual Super Bowl has started, let's say the first quarter has ended, and the score is `49ers 21 - 10 Chiefs`. The square that aligns with the headers 1 on the y-axis and 0 on the x-axis will be the winner.

`8Df1..vd6y` is the winner, and will have a `Claim` button in the Payouts section. The amount is for 1/5th of the total pot minus a 6.9% fee. 

This repeats for each quarter of the game.

If the game doesn't go into overtime, the player who won the fourth quarter gets a doubled up payout.

## Conclusion

That's pretty much it! It's a super fun game to play with friends and a great way to financially incentivize yourself to be invested in the big game (lol).

Always more fun watching sports when something is on the line, right?

P.S. I'll be back with a technical post about how I implemented this in a future post.

I also plan on keeping this alive for March Madness, NBA Playoffs, and more. Stay tuned!












###