BugDex

Web3 biodiversity monitoring: photograph insects, community voting, mint NFTs, support conservation.

BugDex

Created At

ETHOnline 2025

Project Description

BugDex is a mobile-first DeSci (Decentralized Science) platform that transforms biodiversity monitoring into an engaging, economically sustainable activity. Over 40% of insect species are declining globally, yet conservation data collection remains expensive, slow, and limited to well-funded regions.

BugDex solves this by gamifying biodiversity research: users photograph insects with their phones, stake tokens to submit for community voting, and mint verified observations as NFTs with rarity tiers (Common to Legendary). Every photo becomes both a collectible and valuable scientific data - geo-tagged, timestamped, and permanently stored on IPFS.

The platform demonstrates three powerful sponsor integrations:

PYUSD Consumer Payments: Users pay $1 in PYUSD (stablecoin) or ETH to unlock the faucet, which dispenses 100 BUG tokens every 24 hours. Stablecoin payments provide predictable pricing regardless of crypto volatility. Users can also donate PYUSD directly to conservation organizations, with quarterly fund distribution determined by community token voting - transparent on-chain impact for real-world conservation.

Blockscout Custom Explorer: Deployed a custom-branded explorer at bugdex-explorer.cloud.blockscout.com that keeps users in the BugDex ecosystem. Transaction confirmation dialogs after key actions (unlock, stake, mint) provide blockchain transparency without leaving the app or triggering mobile popup blockers.

Pyth Price Oracle: Uses Pyth's ETH/USD price feed to dynamically calculate the exact ETH needed for a $1 faucet unlock. The system fetches real-time prices from Hermes before each transaction, ensuring the unlock cost stays at $1 regardless of ETH price volatility - critical for consumer-facing applications.

How it works:

  1. Unlock Faucet - Pay $1 (PYUSD or ETH) to unlock 24h token claims
  2. Photograph - Capture insects with mobile camera (stored on IPFS via Lighthouse)
  3. Stake & Submit - Lock 10 BUG tokens to submit for community voting
  4. Community Votes - Other users vote FOR or AGAINST (free, off-chain signatures)
  5. Mint NFT - Approved bugs (2+ net votes) become NFTs with rarity tiers
  6. Earn Rewards - Voters earn 5 BUG per upvote, discoverers keep the NFT
  7. Support Conservation - Donate PYUSD to wildlife organizations with transparent tracking

BugDex showcases how Web3 can solve real-world problems by making scientific data collection economically viable, accessible to anyone with a smartphone, and directly connected to conservation funding.

Live App: https://bugdex.life Custom Explorer: https://bugdex-explorer.cloud.blockscout.com Network: Sepolia Testnet

How it's Made

BugDex is built on a hybrid architecture that balances blockchain transparency with practical UX:

SMART CONTRACTS (Solidity 0.8.27):

  • BugTokenV3: ERC-20 with dual-payment faucet (PYUSD + ETH via Pyth oracle). Integrated Pyth's pull oracle pattern - fetches ETH/USD price from Hermes before each unlock to calculate exact ETH needed for $1 cost. Added PYUSD transfer logic to accept stablecoin payments with allowance checks.
  • BugSubmissionStaking: Manages 10 BUG stakes for submissions and distributes 5 BUG rewards per upvote. Uses off-chain voting signatures to save gas while maintaining verifiable on-chain reward distribution.
  • BugNFT: ERC-721 with dynamic rarity tiers (Common, Rare, Epic, Legendary) based on vote counts. Metadata stored on IPFS with tokenURI pointing to decentralized storage.

FRONTEND (Next.js 15 + TypeScript):

  • Mobile-first PWA with App Router for fast navigation
  • Privy for wallet abstraction (external wallets only - mobile-optimized)
  • TailwindCSS with dark mode theming
  • Camera API integration for in-browser photo capture
  • Ethers.js v6 for contract interactions with proper error handling
  • Clipboard API with fallback handling for mobile transaction links

SPONSOR INTEGRATIONS:

  1. PYUSD (Consumer Champion prize):

    • Dual-payment faucet accepts PYUSD OR ETH
    • Conservation donation system with community-governed fund distribution
    • Mobile-first stablecoin payments for predictable pricing
    • Contract: 0xCaC524BcA292aaade2DF8A05cC58F0a65B1B3bB9 (Sepolia)
  2. Blockscout (Autoscout prize):

    • Custom explorer deployed: bugdex-explorer.cloud.blockscout.com
    • Requested $1000 credits via Discord per requirements
    • Transaction popups use confirm() dialogs instead of window.open() to bypass mobile popup blockers
    • Clipboard copy fallback ensures users can access transaction links on any device
  3. Pyth Network (Pull Oracle prize):

    • ETH/USD price feed: 0xff61491a931112ddf1bd8147cd1b641375f79f5825126d665480874634fd0ace
    • Fetches latest price from Hermes API before each unlock transaction
    • Pull-based updates ensure accurate pricing without expensive on-chain storage
    • Dynamic calculation: cost = $1 / (ETH price) = exact ETH amount

BACKEND (Next.js API Routes + Postgres):

  • Voting system with off-chain signature verification (ethers.recoverAddress)
  • IPFS uploads via Lighthouse API with metadata generation
  • Postgres database for submissions, votes, and faucet unlock tracking
  • REST endpoints: /api/submit-bug, /api/vote, /api/uploads, /api/mint-status

DEPLOYMENT:

  • Hardhat for contract deployment with verification scripts
  • Vercel for frontend hosting with automatic CI/CD
  • Environment variables for contract addresses, API keys (Pinata, Privy)
  • Git-based version control with frequent commits throughout hackathon

HACKY/NOTABLE SOLUTIONS:

  • Hybrid on-chain/off-chain voting: Votes are signed off-chain and verified in backend, but rewards distributed on-chain. Saves massive gas costs while maintaining cryptographic verifiability.
  • Confirm dialog workaround: Mobile browsers block window.open() after async operations, so we use confirm() with clipboard copy to show transaction links without triggering popup blockers.
  • Pyth pull oracle: Implemented manual price feed updates by fetching from Hermes API right before transactions, avoiding expensive keeper networks while ensuring accurate pricing.
  • Rarity calculation: NFT rarity tier automatically upgrades based on vote count (2+ = Common, 5+ = Rare, 10+ = Epic, 20+ = Legendary) with colored frames for visual feedback.
  • Contract verification override: FaucetButton checks both isUnlocked() and contract events to handle users who unlocked before event emission was added.

The trickiest integration was Pyth oracle - had to understand pull vs push models, decode price feed IDs, handle Hermes API responses, and update contract state with fresh prices before each transaction. The result is a consumer-friendly $1 price point that stays accurate regardless of ETH volatility.

Tech Stack Summary: Next.js 15, TypeScript, Solidity, Ethers.js, Privy, PYUSD, Pyth Oracle, Blockscout, Lighthouse IPFS, Postgres, TailwindCSS, Vercel.

background image mobile

Join the mailing list

Get the latest news and updates