RogueChain: Infinite on-chain roguelike. Dungeons procedurally generated by Pyth Entropy.
RogueChain is a revolutionary Web3 RPG game that combines NFT technology with real-time oracle data to create dynamic, market-adaptive gameplay. Players mint unique Hero NFTs and battle in dungeons where difficulty and rewards change based on live ETH/BTC price feeds from Pyth Network.
š Key Features: ⢠Real-time market integration (ETH/USD, BTC/USD price feeds) ⢠Dynamic market states (BEAR/NORMAL/BULL/EXTREME) affecting gameplay ⢠ERC721 Hero NFTs with randomized stats and level progression ⢠Production-ready frontend with MetaMask integration ⢠Live on Optimism Sepolia with gas-optimized transactions
š Live Demo: https://rogue-chain.vercel.app/ š§ Contract: 0x01b4b5227A1234A32b23bdBCF63C354f1253C963
Built with Solidity 0.8.28, Pyth Network SDK, Ethers.js, and modern Web3 best practices. Demonstrates advanced oracle integration, security-first smart contract design, and seamless user experience.
RogueChain is built as a full-stack Web3 application, leveraging a robust Solidity smart contract on Optimism Sepolia and an interactive frontend.
Smart Contract (Backend Logic):
The core game logic resides in the RogueChain.sol smart contract, developed with Solidity 0.8.28. It utilizes Hardhat for development, testing, and deployment. Key components include:
ERC721, ERC721Enumerable, Ownable, and ReentrancyGuard are used to manage Hero NFTs, ensure ownership, and prevent re-entrancy attacks.IPythEntropyCallback) to handle Pyth's pull-based oracle model.Frontend (User Interface): The user-friendly interface is built with standard web technologies:
RogueChain smart contract, and handling transactions.fetch-based solution to retrieve real-time price update data from the Pyth Hermes API. This data is then passed to the smart contract for on-chain price verification.How They're Pieced Together:
The frontend communicates with the smart contract via Ethers.js, using the contract's ABI (frontend/abi.json) and address. When a user initiates an action (e.g., "Mint Hero" or "Enter Dungeon"), the frontend constructs a transaction, fetches necessary off-chain data (like Pyth price updates from Hermes), and prompts the user to sign it via MetaMask. The smart contract then processes the transaction, updates its state, and emits events. The frontend listens for these events to update the UI in real-time, providing immediate feedback on hero stats, dungeon results, and market changes.
Notable & "Hacky" Aspects:
getMarketState() and calculateVictoryChance()), the frontend currently uses simplified client-side logic for displaying market status and victory chances. This was a pragmatic decision to maintain a "working system" for the hackathon, while the contract's full Pyth integration is robustly handled for critical functions like updatePriceFeeds.try-catch blocks are implemented both in Solidity and JavaScript to gracefully handle potential issues with Pyth oracle updates, network interactions, and transaction failures, providing clear feedback to the user.
