Inspiration
Cozy Reef is a NFT project inspired by Squid Game x Happy Tree Friends where players compete in seasonal elimination games in order to join the Cozy Reef Killers, the organization that runs the games.
The team, with several decades of combined game industry experience, is excited about bringing unique and engaging gaming experiences that fully embrace the advantages of blockchain. Our current understanding is that many blockchain games heavily rely on centralized components, and fully on-chain games are commonly defi protocols with UI and art overlays.
We see an opportunity to develop gaming experiences that are truly decentralized, reward players for their achievements, and focus on the joys of gaming above all else. We recognize that Chainlink oracles play a key role in truly decentralizing game state and management, potentially becoming part of the industry standard technology stack for blockchain game development.
What it does
Checkout the white paper to learn more about the project.
The core loop for the Cozy Reef project is as follows:
- Players mint a 1 of 1 unique NFT from the Cozy Reef ERC721 contract on Ethereum, containing 10,000 tokens.
- Players then mint an equivalent one time game pass ERC721 token on Polygon through a proof of reserves contract call to validate token ownership that is powered by Chainlink oracles.
- Players gain access to Cozy Reef games that are deployed on Polygon, and play through a web client and Metamask. The game runner is driven by Chainlink Keepers and certain game outcomes are driven by Chainlink VRF.
- Players who survive the entire game season receive a 1 of 1 Cozy Reef Killer mask NFT. Players can choose to use the mask and the base NFT to mint a Cozy Reef Killer or sell the mask.
Development of Cozy Reef began at the start of the hackathon. At the time of the hackathon submission, the current state of the project is as follows:
- [Live] Website - landing page with information on the project, links to the white paper, blog, and social media accounts.
- [Live] Honorary NFTs - Honorary NFT ERC721 contract deployed to Ethereum mainnet with several tokens minted to thank project advisors.
- [Live] white paper - whitepaper that discusses project direction, challenges, and future work.
- [Alpha] Slingshot Sailors - Slingshot Sailors, the first elimination game of Cozy Reef season one. We ran two public Alpha play tests with 25 players. We will continue to run playtests as we continue to improve the game. ( Alpha 1 contract). (Help Guide)
- [No e2e test] 10k NFT Art Project - art generation from hundreds of attributes, contract, and supporting toolchain.
- [Demo] NFT Proof of Reserves - Contracts and Chainlink infrastructure to validate token ownership on Ethereum to mint an equivalent token on Polygon.
How we built it
Website
The website is built as a React app in Typescript, using Github Actions as our CI/CD pipeline and deployed in AWS. All infrastructure is managed within a Terraform project.
Honorary NFTs
The Honorary NFTs are ERC721 tokens on Ethereum mainnet pointing to metadata and art hosted on Arweave. The development and testing of the contract is done through Hardhat and Ethers.js. The project state is automatically written to a metadata.json file with extensive validations in the toolchain to ensure each NFT is only minted once and contains the correct image/metadata/recipient.
Slingshot Sailors
The contracts for Slingshot Sailors are written in Solidity, with Metamask integration on the web app. Contracts use OpenZeppelin base contracts and Hardhat / Chai for development and testing. The game UI is built in React with custom art assets with state fully managed on-chain and Chainlink Keepers as the game runner. Specific values shown on the game UI are derived through lazy evaluation of state calls through view functions.
NFT Art Pipeline
We built a configurable Javascript tool to generate 10,000 unique and random NFT art over the hundreds of features drawn by our artist. This allows us to quickly iterate on the art as we hone in on the look and feel of Cozy Reef.
NFT Proof of Reserves
We built a prototype of a proof of reserves service to validate NFT token ownership on Ethereum and mint an equivalent one-time game token on Polygon. The core service is a Chainlink oracle with a View-Function external adapter, with dummy NFT and custodian request contracts for testing. The token owner calls verify to the custodian contract on Polygon with the tokenId they own on Ethereum and wish to mint, and a direct request Chainlink job event is emitted. The Chainlink oracle triggers the View-Function external adapter to call ownerOf on the ERC721 contract on Ethereum, and validates the token ownership in order for the custodian contract to mint a one-time game token on Polygon.
Challenges we ran into
Storing game state without exorbitant gas prices
Optimizing CPU and memory performance is commonplace in game development, however these optimizations become critical to the viability of a game when developing a fully on-chain experience. Players cannot be expected to pay dollars, let alone 10s to 100s of dollars for a single action. Similarly, keeper upkeep must be kept to a reasonable cost to ensure the game is cost effective to run. Storing less state is an option, but cutting state often means cutting features, which can lead to an uninteresting game loop.
Fun game experiences
Designing games for blockchain comes with its fair share of constraints.
- Storing State is expensive, any mechanic that requires additional storage, has to be carefully designed to ensure the game remains within our gas cost budgets.
- Players can’t communicate with the game authority (ie. the chain) in real time, nor will players receive information about state changes at the same time. This means that game mechanics can’t rely on fast user action, or any quick-time events.
- No internal state on the authority can be hidden from other players without extra logic (and increased gas costs). A simple game of rock-paper-scissors isn’t so simple when you can’t hide the first person’s choice from the second. Games either have to be designed to handle each player having full knowledge of the state, or pay the complexity and gas cost of adding hidden state.
Integrating Chainlink technology
Chainlink technology is critical in the Cozy Reef platform, with VRFs and Keepers acting as the driving force behind game state and management. We also leverage External Adapters to do cross chain proof of reserves. We ran into several challenges setting up Chainlink infrastructure, mainly with finding very specific documentation as well as trouble shooting bugs with limited logs. Some examples of issues we ran into:
- Setting the ORACLE_PAYMENT values and not understanding the implications of MINIMUM_CONTRACT_PAYMNENT_LINK_JUELS (job does not run)
- Troubleshooting silent VRF failures, later realizing that we exceeded the gas limit
- Troubleshooting Keepers not polling our contract and learning that we need to add ownership rights to the Keeper addresses .
Accomplishments that we're proud of
Alpha Tests
We ran two Alpha tests in the final week of the Hackathon and played “Slingshot Sailors” with 25 players around the world. We received positive and encouraging feedback, as well as many suggestions we plan to implement as we work towards beta. Slingshot Sailors uses Chainlink VRF to determine outcomes of the slings and Chainlink Keepers as the game runner.
NFT Project
We’re really excited about the duality of the Cozy Reef guest and the Cozy Reef Killer, along with their respective art direction. In addition to having all the assets to generate 10,000 unique characters, we deployed the honorary contract to mainnet and began minting custom NFTs to members of the community who are advising and spreading the word on.
What we learned
Coming into this hackathon, most of the engineers on the team had little or no experience with the blockchain technical ecosystem, so everything we’ve done has been new for us. Everything from setting up our dapp to integrate with metamask, creating a quick iteration loop locally with hardhat and waffle for testing our game and contract, and integrating with Chainlink technology all introduced complexities that we’ve dealt with over the course of the hackathon.
Nevertheless, here are some of the key insights that we’ve gained after working in this space for the past month. Feel free to check out our whitepaper for a much more in depth breakdown.
Getting around high gas usage
One of the largest challenges around building games on chain is dealing with high gas usage and high gas prices. To get around high gas prices, the only thing we can do is move to a cheaper side chain such as Polygon. However, reducing gas usage is also important to decrease costs in general.
We try to have each transaction in our game run with a space complexity of O(1). In order to avoid scaling gas fees, we avoid storing player state and opt to store player inputs. Calculating player state dynamically after the fact allows us to avoid state update transactions that scale linearly according to the number of players, which significantly reduces our gas usage.
Designing fun blockchain games
We’ve listed some blockchain game limitations in the section above covering challenges we’ve faced. In general, we try to follow these core tenants:
- Games must allow high player agency.
- Games must require skill to win over pure luck.
- Player to player interactions must be high, since all information is public and fast paced interactions do not exist.
In general, what we’ve learned is that the best on chain games at the moment must be turn based. In addition, games that rely on perfect information work best, which means that the best blockchain based games mimic common board games. The advantages that blockchains provide is a decentralized backend for these games, reducing technical complexity in areas such as scaling and distribution by limiting the capabilities of what the game can achieve.
Fast Iteration Loops
Several tools help us create fast iteration loops and made development of our dapp and game faster:
- Hardhat + waffle provided a solid testing framework for our contracts and enabled a lot of scripting that allowed us to quickly bootstrap our dapp with a local blockchain for development
- Typescript + typechain + language servers made the entire development experience much easier, reducing entire classes of errors that one can make with raw javascript such as calling contract methods with the right data types.
- mocking out Chainlink contracts properly allowed us to test things such as VRFs and Keepers to make sure everything looks right locally.
- NextJS, GitHub actions, and Terraform removed nearly all the boilerplate around developing and deploying a React based app. NextJS provided all the tooling to compile and optimize our application. GitHub actions produced an efficient and free CI/CD pipeline. Terraform made producing new environments very quick and easy, allowing us to focus on application development.
Getting a roadmap out early
We got a roadmap out early and publicly on our website. This not only pushed us forward to deliver but also kept us honest about what work we had left. This seems like a trivial thing to do but was an important part to keeping us moving forward even when faced with difficult challenges throughout the hackathon.
What's next for Cozy Reef
Slingshot Sailors Beta
The next milestone for the project is developing the beta based off of the feedback we received from the Alpha test. The main improvements we plan to make and iterate over with our project supporters:
- Music and SFX - We will add music and sound effects to the game to create a more engaging environment and provide audio cues on state transitions and round outcomes.
- UI polish - we will improve our UI for more intuitive visual indicators. The most requested addition to the UI is a scoreboard, which we will explore showing with ENS names. Other UI improvements we intend to add are animations in the game.
- Stun mechanic - currently if the slingshot a player is on snaps, they are unable to make a move for a full round. We’ve received enough feedback that this is frustrating, and are going to revise the penalty system that still encourages players to engage.
ERC20 Game Token
We plan to release an ERC20 game token (“Cozy Coins”) as part of the Cozy Reef ecosystem. While the ultimate reward is for players to survive a season to an end to join the Cozy Reef Killers, players will earn Cozy Coins based on how well they do in each game. This will reward players for their achievements and engagement while setting the foundations for us to build out a long lasting game ecosystem.
Launch the Cozy Reef Project
When we are confident in “Slingshot Sailors”, the first game of the season, we will launch the Cozy Reef project, consisting of 10,000 ERC721 tokens on Ethereum to mint. Shortly after the minting event we will launch “Slingshot Sailors” on Polygon, along with the proof of reserves for players to validate their ownership for a game token.
Season One
We intend to run at least three elimination games for season one of Cozy Reef. We’ve begun ideating the remaining games beyond Slingshot Sailors that explore new game mechanics that take advantage of blockchain and Chainlink technology. We will take our learnings and reusable components from Slingshot Sailors to bring the next series of games to players sooner.
Cozy Reef Killers
Players who survive the entire season of games will be airdropped a unique Cozy Reef Killer mask (ERC721). They can then choose to sell the mask, or use the mask and a Cozy Reef NFT to mint a Cozy Reef Killer NFT. We already have begun ideation on the art for the masks and will need to do additional work on the Cozy Reef Killers NFT contract to support the minting process.
Built With
- alchemyapi
- amazon-web-services
- arweave
- chai
- chainlink
- docker
- ethereum
- ethersjs
- hardhat
- metamask
- nextjs
- node.js
- polygon
- react
- solidity
- typescript




Log in or sign up for Devpost to join the conversation.