Skip to content

ETHDam Hackathon Project - Web3 RPG game built on Oasis Sapphire and ROFL

Notifications You must be signed in to change notification settings

epintos/oasis-moncraft-game

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

79 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Oasis MonCraft

Logo

Introduction

Oasis MonCraft is a project built for the 2025 ETHDam 48-hours Hackathon. It’s a retro-inspired, top-down RPG where players explore a grid-based world, encounter wild Monsters, and attempt to catch them — blending on-chain privacy with real-time gameplay.

Contributors: Developed by @epintos and @federava.

With this project we won the following Oasis track bounties:

  • 🥉 ROFL Track Champions
  • 🥉 Sapphire Track Heroes
  • ⭐ Developer Feedback

Sapphire Tesnet contracts:

Implementation

Smart Contracts

The game leverages Oasis Sapphire and ROFL to introduce on-chain privacy and secure randomness into the gameplay, ensuring fairness and decentralization.

Monster Encounters and Catching Mechanics

The game client connects to a ROFL instance via WebSockets. As the player moves around the grid, ROFL invokes a view function on the MonCraft smart contract to determine if a Monster appears. This logic uses secure randomness on Sapphire to make each encounter unpredictable and tamper-proof.

If a Monster appears, the player may choose to attempt a capture. To ensure smooth gameplay, player movement is recorded off-chain in ROFL until the capture is initiated. When a capture is attempted, ROFL sends a transaction to the smart contract, which again uses secure randomness to decide the outcome. If successful, the Monster is added to the player's current session, and the player's state is synchronized on-chain.

Each Monster is represented as an NFT with unique attributes such as HP, attack damage, appearance rates, and capture probabilities.

To prevent abuse (e.g., rerolling movements to force favorable outcomes), player movements are kept off-chain until a decision point, minimizing the attack surface while preserving game feel.

In the following diagram, you can see how the moves are persisted only in ROFL until the player attempts to catch a Monster. At that point, the moves are synced on-chain and the NFT is minted.

Moves flow

Game Sessions

To lower the barrier to entry, the game supports gasless gameplay: no wallet is required to start. When a session begins, a unique access code is generated, allowing players to return and resume progress later. ROFL signs transactions on behalf of the player during gameplay.

Advanced users can optionally link their wallet and withdraw their Monster NFTs to trade, transfer, or import them into other game sessions.

Fights

A game admin can create a fight between two sessions. Each player can join the fight by selecting a Monster from their inventory. Once both players have joined, the fight takes place off-chain in ROFL. ROFL calls a view function that returns random damage caused by each Monster. It then simulates multiple rounds automatically until one Monster's HP reaches zero. When that happens, the winner is synced on-chain, and the losing Monster's NFT is burned.

Moves flow

Repo structure

We have a monorepo structure with the following components:

  • Frontend: Includes the game UI
  • Smart Contracts: Includes the Smart Contracts using Hardhat
  • ROFL: Includes the Oasis ROFL implementation

Usefull commands

Install dependencies

We are using pnpm in each mono repo:

  pnpm install

Envs

  cp .env.example .env

and complete the missing values.

Compile

  pnpm hardhat compile

Deploy

The following compile and deploy to the different networks:

  pnpm deploy-local
  pnpm deploy-tesnet

Generate ABIs

  pnpm generate-abi

About

ETHDam Hackathon Project - Web3 RPG game built on Oasis Sapphire and ROFL

Topics

Resources

Stars

Watchers

Forks

Contributors 2

  •  
  •