Inspiration

The Cozyverse is a gaming ecosystem of fully on-chain community blockchain games. Chainlink oracles play a vital role in building meaningful gaming experiences that don't rely on any centralized game servers and we are excited to build with that belief. Since the Chainlink 2021 Fall Hackathon, we:

  • Launched Cozy Penguins, a free mint 10k NFT project that minted out in less than 2 minutes and generated over 1k ETH in secondary sales on Open Sea within 72 hours
  • Shipped our first game Slingshot Sailors to Polygon mainnet, where players choose slings to try to outrun the killer. There is no game server holding state - Slings fire based on VRF values and rounds are driven by Keepers

What it does

During the Chainlink Spring Hackathon, the team built two pieces of the ecosystem we're excited to share:

Cross Chain NFT Verifier

We productionalized and shipped the cross chain NFT verifier that allows us to verify our favorite NFTs that live on different chains and invite them to play in the Cozyverse. The verification is async - so players keep their NFTs safe in their wallets but we have the proof we need to grant them access.

Cozy Fishing

We built the prototype of our upcoming game, Cozy Fishing! Players travel the world grid, drop a line and go fish!

How we built it

Cross Chain NFT Verifier

The cross chain NFT verifier verifies that the player owns a certain NFT that rests on a blockchain outside of Polygon where Cozyverse is currently deployed. This is done by sending a direct request job to a Chainlink Oracle, which retrieves the owner of the requested NFT by calling the ownerOf function of the NFT contract via a view-function external adapter.

The Cross Chain NFT Verifier has 2 contracts to interact with the oracle and persist state:

  • Verifier - the verifier contract holds the configuration for the Chainlink Oracle job IDs / requests
  • Registry - the registry holds the "game pass" IDs that players use to play in the Cozyverse and the mapping from the game pass ID to the original NFT token

Cozy Fishing

The foundations of Cozy Fishing is comprised of the following:

  • Enter the game
  • Pick a coordinate on the world map
  • Travel to the coordinate
  • Fish -... wait for fish!
  • Reel in the fish as they swim up

All state and events (fishing, inventory, traveling) are managed through a composition of smart contracts. This allows us incrementally build new functionality into the fishing game (trading docks, new biomes with more fish, upgrades to boat and rod, leveling) while keeping the key contracts that manage game state.

The core game loop for fishing is managed by Chainlink Oracles. Fishing happens in rounds, where every round fish spawn and migrate to new coordinates on the world grid. Rounds are managed by Chainlink Keepers, which will tick the round state after a certain amount of time. With each new round, a VRF call is made which is processed and used to remap fish location across the grid. With each new round, players can check to see if a fish is on their hook, and if so, reel it in!

Challenges we ran into

Cross Chain NFT Verifier

  • With our wave one integration partners we had to work with several different ERC721 contracts. Some contracts had the ERC721Enumerable interface implemented, others did not or had custom lookups to fetch all NFTs owned by a specific address, some required us to use subgraph.
  • We needed to design a reusable integration SDK across the login flow and ecosystem. A user's NFT shows up in multiple places (login page, game hub, in game etc...) in the Cozyverse platform, and we needed a way for new NFTs to be smoothly integrated without having to hardcode everything.

Cozy Fishing

  • We had to design a composable contract architecture that's flexible for game development. This allows us to ship iteratively and build more functionality to the game (augments, leveling, docks) while preserving certain elements that make Cozy Fishing a truly web3 game (permanent state, asset ownership, etc...)
  • Keeping gas and transaction fees low for players - in order to keep costs down, we created ways for the client to compute state to drastically reduce the number of contract interactions. An example is movement across the world grid. The client reads the destination of a traveling player and computes the estimated location during travel.
  • Building client based game engine on top of contracts - we built a client based game rendering engine using PixiJS that mimics a development experience similar to working in something like UNITY (with scenes, game object position, etc...). Figuring out the best way to do state management against smart contracts was quite the learning experience!

Accomplishments that we're proud of

Cross Chain NFT Verifier

  • Deploying the cross chain verifier to Polygon mainnet to verify Cozy Penguins
  • Integrated Chubbicorns to the Cozyverse ecosystem as the first metaverse partner
  • Secured partnerships for wave one integration (Axolittles, Cool Cats, Sappy Seals, Squishiverse, Chubbiverse Frens, Starcatchers)
  • Start of a resuable integration SDK

Cozy Fishing

  • Laid out initial contract architecture
  • World grid and movement completely managed on chain
  • Initial prototype of the game where a player can travel and fish

Toolchain

We built a robust toolchain to make development extremely easy

  • Bootstrap - single button press to spin up the entire local environment
  • Mock keepers to tick our local contracts
  • Mock VRF contracts for local development
  • Hardhat tasks to manage VRFv2 subscription

Monitoring

Built monitoring and alerts with Slack integrations to monitor contract and service states for outages and low balances.

Monitoring is also integrated with Chainlink Pricefeeds on MATIC/USD and LINK/USD to ensure the cost of operating the verifier is offset by the verification fee

What we learned

Refer to our challenges!

What's next for Cozyverse

  • Integrating all your favorite NFT projects to the Cozyverse
  • Ship the fishing game to production
  • Build more capabilities to the fishing game (leveling, docks, boat and rod upgrades, more fish and biomes)
  • Cozy Islands - players will be able to build their own islands with composable plots of land and create Animal Crossing / Runescape PoH like experiences
  • Open new regions in the Cozyverse. We're currently building out the Cozy Reef activities, there's a whole world to create!

Note - Ownership of a Cozy Penguin required to enter cozyverse.xyz. If you are a judge, please contact us to send one your way! Reach out to for a live demo to the fishing game

Built With

Share this project:

Updates