A blockchain-based MMORPG proof of concept built on the Ethereum Sepolia testnet, demonstrating on-chain game mechanics including character NFTs, item system, gold economy, combat, and guild governance.
- Fang Zihao (122090106)
- Liang Ruilan (122090308)
- Xu Penggan (122090625)
EtherRealms implements a minimal MMORPG game using Solidity smart contracts on the Ethereum Sepolia Testnet. The project focuses on verifying core mechanisms: on-chain shared world state, NFT characters/items, player interaction, persistent progress, and guild governance.
- Character System (ERC-721) – Mint unique character NFTs with on-chain attributes (level, XP, HP, STR, DEF)
- Item System (ERC-721) – Weapons, armor, and potions with 5 rarity tiers and ownership history tracking
- Gold Economy (ERC-20) – In-game currency earned through gameplay, spent on items and guild treasury
- Adventure & Combat – Exploration and turn-based PvE combat with 3 monster types
- Guild Governance – Create guilds, shared treasury, governance proposals with on-chain voting
- Shared World – Global event log, leaderboard, and player list for "massively online" experience
| Component | Technology |
|---|---|
| Smart Contracts | Solidity 0.8.24, OpenZeppelin v5.0 |
| Dev Framework | Hardhat |
| Testing | Hardhat Test (Mocha + Chai) |
| Frontend | React 18, Vite 5, ethers.js v6 |
| Wallet | MetaMask |
| Testnet | Ethereum Sepolia |
- Node.js >= 18
- MetaMask browser extension
- Sepolia testnet ETH (from a faucet)
# Install smart contract dependencies
npm install
# Install frontend dependencies
cd frontend && npm install && cd ..npm run compilenpm run testAll 24 tests should pass:
EtherRealms
CharacterNFT (5 tests)
GoldToken (1 test)
GameManager - Adventure (6 tests)
GameManager - Combat (3 tests)
GameManager - Rest (1 test)
GameManager - Equipment (1 test)
GameManager - Guild System (5 tests)
GameManager - Leaderboard (1 test)
ItemNFT - Ownership History (1 test)
24 passing
# Terminal 1: Start local Hardhat node
npm run node
# Terminal 2: Deploy contracts
npm run deploy:local# Set environment variables
export SEPOLIA_RPC_URL="https://rpc.sepolia.org"
export PRIVATE_KEY="your-private-key-here"
# Deploy
npm run deploy:sepoliacd frontend
npm run devOpen http://localhost:3000 in your browser.
- Open the web page
- Connect MetaMask (switch to Sepolia network)
- Click "Mint Character" (costs 0.01 ETH)
- Enter the game interface
- Click "Explore" to gain XP and gold
- Click on monsters to fight them
- Buy/equip items from the shop
- Create or join a guild
- Create governance proposals and vote
- View the leaderboard and world events
The full loop can be experienced in ~5 minutes.
┌─────────────┐
│ GameManager │──── Central game logic hub
├─────────────┤
│ explore() │
│ fightMonster│
│ equipItem() │
│ rest() │
│ buyItem() │
│ createGuild │
│ leaderboard │
└──────┬──────┘
│ manages
├──→ CharacterNFT.sol (ERC-721 + attributes + action history)
├──→ ItemNFT.sol (ERC-721 + ownership history)
├──→ GoldToken.sol (ERC-20 in-game currency)
└──→ GuildManager.sol (Guild governance + treasury)
etherrealms/
├── contracts/ # Solidity smart contracts
│ ├── CharacterNFT.sol
│ ├── ItemNFT.sol
│ ├── GoldToken.sol
│ ├── GuildManager.sol
│ ├── GameManager.sol
│ └── Marketplace.sol
├── test/ # Hardhat test suite (24 tests)
│ └── EtherRealms.test.js
├── scripts/ # Deployment scripts
│ └── deploy.js
├── frontend/ # React DApp
│ ├── src/
│ │ ├── App.jsx
│ │ ├── components/
│ │ │ ├── CharacterPanel.jsx
│ │ │ ├── GameActions.jsx
│ │ │ ├── WorldEvents.jsx
│ │ │ ├── Leaderboard.jsx
│ │ │ ├── Inventory.jsx
│ │ │ ├── GuildPanel.jsx
│ │ │ ├── Marketplace.jsx
│ │ │ └── Notification.jsx
│ │ └── contracts/ # ABIs and addresses
│ └── index.html
├── hardhat.config.js
├── package.json
└── README.md
The PoC reviewer noted that the original proposal looked like an "on-chain RPG" rather than a project designed around MMORPG structures. We addressed this by implementing:
| MMORPG Structure | Implementation |
|---|---|
| Persistent shared world | Global worldEvents array, getAllPlayers(), leaderboard() |
| Long-term player identity | One character per address,ActionRecord history, permanent progression |
| Traceable asset histories | ItemNFT.ownershipHistory, CharacterNFT.actionHistory |
| Guild governance | GuildManager with treasury, proposals, on-chain voting |
| Player-driven economy | ERC-20 gold earned through gameplay, spent on items/healing/treasury |
- Randomness: Uses pseudo-random (blockhash) – upgradeable to Chainlink VRF
- Gas Costs: Free on Sepolia; production would need Layer 2 deployment
- Scalability: Leaderboard uses O(n²) sort; production needs off-chain indexing
- No PvP: Current version is PvE only
MIT
- On the real ETH chain, establish a Uniswap pool to exchange ETH with ETHGOLD.