D-Agar

Introducing D-Agar, a browser game inspired by the popular agar.io. Grow, compete, and conquer in a trustless environment powered by Arbitrum, Dynamic, NounsDAO and lots of smart contracts wizardry

ETHGlobal BrusselsShipped July 12, 2024Prize winner#gaming#nft#infra#arbitrum
Repo
D-Agar banner

About

# D-Agar

A decentralized version of the popular multiplayer browser game [agar.io](https://agar.io), where players try to get as big as possible and eat each other.

## Rationale

Browser games are becoming increasingly popular, with the leader Agar.io boasting over 6 million active users. This project aims to showcase how to leverage browser gaming to introduce more people to web3.

In order to do so, the user experience must be: - Fast and easy, without complicated popups or endlessly-loading frontends. - Cheap, as nobody likes to spend excessive gas just to play. - Secure, thanks to smart contract logic preventing cheating.

## How it works

### Backend

  • A user calls the *DagarFactory* contract to deploy a new rollup. The rollup is picked up by the backend, and a node is set up for it.
  • The user deploys the game smart contract from Arbitrum Sepolia to the new L3 using the relay bridge.
  • Other users join the game and bridge a little ETH to the L3.
  • Each relevant game interaction (map generation, food eating, and player kills) is registered and validated on-chain, leveraging the L3 for its speed and low gas fees.
  • When only one player remains, they can kill the L3 and relay a message to the L2 to claim the pot.

Map generation is based on a seed unique to each game, which is then fed into a random number generator to create 200 food dots. Whenever a player eats a food dot, its position is validated on-chain to ensure they cannot cheat. The same model applies to player-to-player interactions, verifying that both players are alive and that the larger player kills the smaller one (incrementing its size).

### Frontend

A combination of React and canvas to create smooth transitions.

How it's made

## How it was made

- **React**

- **Chakra UI** - **Arbitrum**: Through the factory contract, we spawn a new Orbit L3 chain, deploy the game contract there, and bridge the ETH necessary for users to play. Once the game is completed, the winner is relayed back to Arbitrum One and the bets are awarded to them. - **NounsDAO**: Provides custom skins for the players based on the NFTs they hold in their wallets. - **Dynamic Wallet**: A seamless signup/signin experience with headless interactions (not implemented) to provide a web2-like user experience. - **PeerJS**: Enables peer-to-peer communication, allowing players to connect and exchange real-time game data without relying on a centralized server. - **Smart Contracts**: The "backend" of the game, responsible for generating the playing field, validating kills, and collecting the bets to be awarded to the winner.

Prizes

  • Arbitrum · Best Orbit Chain Project · 1st place

From the public ETHGlobal showcase page. Votes, swipes and the judge score are hackfeed's own.

AI judge

Not judged yet. A free model reads this page, compares it with similar projects and this event's winners, then scores it and says what would make it win.

Still being built?

Not checked yet.

Swipe stats

0upvotes
0skips
0saves

Discussion 0

No comments yet. Ask the team something, or say what you'd use it for.

Posting as a guest. Plain text, 1,000 characters max.

Already built nearby

Closest projects by meaning and shared words. Similar isn't the same as copied: read them.

Nouns Royale

Discover Agar.io with a crypto twist! Join the NounsDAO community as you control a cell, grow by consuming smaller cells, and avoid larger ones. Use strategy and agility to dominate the petri dish and earn crypto rewards. Simple yet addictive gameplay!

YumeRTS Game

A decentralized verifiable medieval multiplayer real-time strategy game inspired by famous military youtube channel "Kings and General"