Skip to content

A fully implemented Web3 NFT game where players merge virtual starter entities to create unique hybrid creature NFTs using blockchain technology, AI-generated images, and verifiable randomness.

License

Notifications You must be signed in to change notification settings

runsdev/hybridhaven

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

47 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

HybridHaven

Discover. Merge. Evolve.

A fully implemented Web3 NFT game where players merge virtual starter entities to create unique hybrid creature NFTs using blockchain technology, AI-generated images, and verifiable randomness.

๐ŸŒŸ Live Demo

๐ŸŽฎ Play Now: https://hybridhaven.runs.my.id
๐ŸŒŠ OpenSea Collection: HybridHaven on OpenSea
๐Ÿ“‚ Source Code: GitHub Repository

๐Ÿš€ What is HybridHaven?

HybridHaven is a complete Web3 gaming platform that combines:

  • Instant Virtual Starters: 35 virtual entities available immediately upon wallet connection
  • Real NFT Creation: Merge any two entities to mint unique hybrid NFTs on Ethereum
  • AI-Powered Generation: Google Gemini creates unique images and descriptions for each hybrid
  • Verifiable Randomness: Chainlink VRF ensures fair and unpredictable rarity outcomes
  • Decentralized Storage: IPFS stores all NFT metadata and images permanently

โœจ Key Features

  • ๐Ÿ”— Wallet Connection: Connect with MetaMask and other Web3 wallets
  • ๐ŸŽ Virtual Starter Collection: Access 35 virtual starter entities instantly
  • โšก Entity Merging: Combine any two entities (starters or hybrids) to create unique NFTs
  • ๐ŸŽฒ Verifiable Randomness: Chainlink VRF for provably fair rarity generation (1-5 stars)
  • ๐Ÿค– AI-Generated Content: Google Gemini creates unique hybrid creature images and names
  • ๐Ÿ“ฆ IPFS Storage: Decentralized storage for images and metadata via Pinata
  • ๐Ÿ”„ Auto-Finalization: Automatic processing of merge requests when VRF completes
  • ๐ŸฆŠ MetaMask Integration: Auto-add newly created NFTs to your wallet
  • ๐Ÿ† OpenSea Compatible: Full ERC-721 compliance with marketplace support

๐Ÿ—๏ธ Architecture

Project Structure

web3-project/
โ”œโ”€โ”€ fullstack/           # Next.js frontend + backend API
โ”œโ”€โ”€ smart-contract/      # Solidity contracts + deployment scripts
โ”œโ”€โ”€ proposal/           # Original project proposal (Slidev)
โ””โ”€โ”€ report/            # Final implementation report (Slidev)

System Components

  1. Frontend Application (Next.js 15 + TypeScript)

    • Real-time game interface with entity management
    • Web3 wallet integration and transaction handling
    • Auto-updating UI with merge progress tracking
  2. Backend Services (Next.js API Routes)

    • AI image generation via Google Gemini
    • IPFS metadata upload via Pinata
    • Blockchain event monitoring and auto-finalization
  3. Smart Contracts (Solidity)

    • GameContract.sol: Core game logic and merge mechanics
    • NFTContract.sol: ERC-721 NFT management
    • ChainlinkVRFConsumer.sol: Verifiable randomness oracle
  4. External Integrations

    • Chainlink VRF v2.5: Secure randomness for rarity calculation
    • Google Gemini AI: Dynamic image and description generation
    • IPFS + Pinata: Decentralized metadata storage

๐ŸŽฎ How to Play

  1. Connect Wallet: Connect MetaMask to Sepolia testnet
  2. Instant Access: Get immediate access to 35 virtual starter entities
  3. Select Entities: Choose any two entities (starters or hybrids) to merge
  4. Pay & Request: Pay 0.0001 ETH + gas to submit merge request
  5. Wait for Magic: Chainlink VRF generates randomness, AI creates your hybrid
  6. Receive NFT: New hybrid NFT is minted to your wallet automatically

๐Ÿ’Ž Rarity System

Rarity is calculated on-chain using Chainlink VRF randomness:

  • โญ 1-Star (Common): 20% chance
  • โญโญ 2-Star (Uncommon): 30% chance
  • โญโญโญ 3-Star (Rare): 40% chance
  • โญโญโญโญ 4-Star (Epic): 9.9% chance
  • โญโญโญโญโญ 5-Star (Legendary): 0.1% chance

๐Ÿงฌ Starter Entities Collection

Players get instant access to 35 virtual starter entities:

Elements: Fire, Water, Earth, Air, Light, Shadow, Metal, Crystal, Lightning, Ice
Nature: Plant, Beast, Aquatic, Avian, Insect
Cosmic: Stellar, Lunar, Solar, Void, Nebula
Environments: Forest, Desert, Ocean, Mountain, Swamp
Animals: Wolf, Tiger, Eagle, Bear, Fox
Plants: Oak, Rose, Cactus, Lotus, Fern

๐Ÿ› ๏ธ Tech Stack

Frontend & Backend

  • Framework: Next.js 15 with TypeScript
  • Styling: Tailwind CSS with custom animations
  • Web3: ethers.js for blockchain interactions
  • State Management: React hooks with real-time updates

Blockchain & Infrastructure

  • Network: Ethereum Sepolia Testnet
  • Smart Contracts: Solidity with OpenZeppelin standards
  • Randomness: Chainlink VRF v2.5
  • AI: Google Gemini Flash 2.0
  • Storage: IPFS with Pinata pinning service

Development Tools

  • Smart Contracts: Hardhat with TypeScript
  • Testing: Comprehensive test suite with Mocha/Chai
  • Deployment: Automated scripts with verification
  • Documentation: Slidev for interactive presentations

๐Ÿš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • MetaMask or Web3 wallet
  • Sepolia testnet ETH (get from faucets)

Run Locally

  1. Clone repository:

    git clone https://github.com/runsdev/hybridhaven
    cd hybridhaven
  2. Setup frontend:

    cd fullstack
    npm install
    cp .env.example .env.local
    # Configure environment variables
    npm run dev
  3. Deploy contracts (optional):

    cd smart-contract
    npm install
    npx hardhat compile
    npx hardhat run scripts/deploy.ts --network sepolia

Environment Configuration

# Frontend
NEXT_PUBLIC_GAME_CONTRACT_ADDRESS=0x3b20dB5784862D3a615e089923b6aD1d6e65A28f
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS=0x906834aeC6B6F486F306D66DEDd5925B30cfEB3c
NEXT_PUBLIC_VRF_CONTRACT_ADDRESS=0x48796e7CFdf0ad487875891ad651c7d9562dBa43
NEXT_PUBLIC_RPC_URL=https://sepolia.infura.io/v3/YOUR_KEY

# Backend Services
GOOGLE_AI_API_KEY=your_google_ai_api_key
PINATA_API_KEY=your_pinata_api_key
PINATA_SECRET_API_KEY=your_pinata_secret_key
BACKEND_PRIVATE_KEY=your_backend_wallet_private_key

๐Ÿ“ Contract Addresses (Sepolia)

Contract Address Verified
GameContract 0x3b20dB5784862D3a615e089923b6aD1d6e65A28f โœ…
NFTContract 0x906834aeC6B6F486F306D66DEDd5925B30cfEB3c โœ…
VRFConsumer 0x48796e7CFdf0ad487875891ad651c7d9562dBa43 โœ…

๐Ÿงช Testing

The project includes comprehensive testing:

cd smart-contract
npm test                    # Run all tests
REPORT_GAS=true npm test   # Test with gas reporting

Test coverage includes:

  • Contract deployment and configuration
  • Entity minting and management
  • Merge request flow with VRF integration
  • Access controls and security measures
  • Error handling and edge cases

๐Ÿ”’ Security Features

  • Access Control: Role-based permissions with OpenZeppelin
  • Payment Validation: Smart contract enforces payment requirements
  • Ownership Verification: Contract validates entity ownership before merging
  • Cooldown Protection: 5-minute cooldown prevents spam/abuse
  • VRF Security: Chainlink VRF ensures unpredictable randomness
  • Input Validation: Comprehensive validation for all user inputs

๐Ÿ’ฐ Economics

  • Merge Cost: 0.0001 ETH per merge (fixed)
  • Gas Fees: Variable based on network congestion
  • Payment Destination: Contract owner address
  • No Refunds: Failed merges due to cooldown/ownership issues

๐Ÿ“š Documentation

๐ŸŽฏ Performance Metrics

  • VRF Timing: 30 seconds to 2 minutes for randomness
  • AI Generation: 10-30 seconds for image creation
  • IPFS Upload: 5-15 seconds for metadata storage
  • Total Merge Time: Typically 1-3 minutes end-to-end
  • Success Rate: 100% completion rate for valid merges

๐Ÿ› Troubleshooting

Common issues and solutions:

  • "Contract not initialized": Verify contract addresses and network
  • "Merge cooldown active": Wait 5 minutes between merges
  • "Insufficient funds": Ensure wallet has 0.0001 ETH + gas
  • "Entity not found": Verify entity ownership and selection

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Chainlink for VRF oracle services and reliable randomness
  • Google for Gemini AI integration and creative image generation
  • Pinata for IPFS pinning services and reliable storage
  • OpenZeppelin for secure smart contract libraries
  • Ethereum for decentralized blockchain infrastructure

Ready to start your hybrid creature collection? ๐Ÿš€

Connect your wallet and begin merging! Each combination creates a unique NFT with AI-generated artwork.

About

A fully implemented Web3 NFT game where players merge virtual starter entities to create unique hybrid creature NFTs using blockchain technology, AI-generated images, and verifiable randomness.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published