Skip to content

edycutjong/gochi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

83 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ§‘β€βš–οΈ For Judges (Quick Start)

Welcome! If you are evaluating Gochi for the HackQuest 0G APAC Hackathon 2026, here is everything you need immediately:

πŸš€ Live App gochi.edycu.dev
πŸ“Š Pitch Deck gochi.edycu.dev/pitch
🎬 Demo Video YouTube
πŸ“œ Contract 0x9BDA4...8cf on 0G Galileo
πŸ—οΈ Architecture docs/ARCHITECTURE.md

To test in 60 seconds:

  1. Go to gochi.edycu.dev and click HATCH YOUR GOCHI
  2. Connect MetaMask β€” the app auto-switches to 0G Galileo Testnet (Chain ID: 16602)
  3. Mint your Gochi INFT, then feed, play, and chat with it
  4. Every action writes to 0G Storage KV (<50ms) and archives to 0G Storage Log (Merkle proof)

Gochi

The On-Chain AI Virtual Pet β€” Powered by 0G Network

It cannot be deleted. It cannot be shut down.


Live Demo Pitch Deck Contract Built for HackQuest


Next.js React TypeScript Tailwind Solidity Supabase CI


Gochi β€” On-Chain AI Pet

πŸ“Έ Screenshots

Landing & Birth

Landing page

Landing β€” glitch hero, 0G stats, sponsor strip

Born on 0G Chain

BORN ON 0G CHAIN β€” hatching after mint tx confirmed on-chain

Gameplay β€” Feed Β· Play Β· Sleep

Feed

Feed β€” hunger stat written to 0G Storage KV

Play

Play β€” mood increases, memory archived to 0G Log

Sleep

Sleep β€” energy restored, Merkle root stored

AI Chat & Core Memories

Chat 1

0G Compute responds in character β€” stat-aware personality

Chat 2

Gochi references past interactions from memory context

Chat 3

Personality shifts with stats β€” grumpy when hungry, playful when happy

Core Memories

Core Memories β€” Merkle roots + StorageScan links, permanently archived


πŸ’‘ The Problem

When Tamagotchi servers shut down in 2023, millions of virtual pets were erased overnight. Every Web2 pet is one server outage away from extinction.

What if a virtual pet's existence was cryptographically guaranteed?


🐾 What Gochi Does

Gochi is a Tamagotchi-inspired AI pet that lives entirely on the 0G modular stack:

Layer Technology Why It Matters
Identity ERC-721 INFT on 0G Chain The pet owns a unique on-chain identity β€” provably yours
Reflexes 0G Storage KV Hunger, mood, energy update in <50ms β€” the pet feels alive
Memory 0G Storage Log + Merkle proofs Every moment is permanently archived and verifiable
Soul 0G Compute Router (TEE) AI personality β€” cryptographically proven to be authentic

Take 0G out and you'd need Redis + IPFS + Arweave + OpenAI + Ethereum: four SDKs, four billing accounts, zero unified verification. With 0G it's one SDK, one token, four capabilities.


πŸ—οΈ Architecture

See full architecture with Mermaid diagrams, code samples, and API reference: docs/ARCHITECTURE.md

High-Level Flow

Browser β†’ Wallet (wagmi/viem)     β†’ 0G Chain        ERC-721 mint
        β†’ Next.js API /kv/write   β†’ 0G Storage KV   pet state (<50ms)
        β†’ Next.js API /log/archive β†’ 0G Storage Log  Merkle memory
        β†’ Next.js API /chat        β†’ 0G Compute      TEE-verified AI
        β†’ Next.js API /metadata    β†’ Dynamic ERC-721 metadata + SVG

All 0G operations fall back to Supabase when the testnet node is unavailable, so the demo is always live.

Key Files

src/lib/zero-g.ts            β€” 0G SDK wrapper (kvRead, kvWrite, logUpload)
src/lib/supabase.ts          β€” Supabase fallback client
src/app/api/kv/              β€” Pet state read/write
src/app/api/log/             β€” Memory archive + retrieval
src/app/api/chat/            β€” AI personality (0G Compute / OpenAI)
src/app/api/metadata/        β€” ERC-721 tokenURI + dynamic SVG image
src/components/MintFlow.tsx  β€” Mint / Resume INFT flow
src/components/PetViewport.tsx β€” Animated ghost pet UI
contracts/Gochi.sol          β€” ERC-721 INFT contract

πŸ† Sponsor Tracks

0G Network Foundation β€” All Four Components

# 0G Component Gochi Usage Integration Method
1 0G Chain INFT identity (ERC-721) Solidity contract, Hardhat deploy, wagmi writeContractAsync
2 0G Storage KV Real-time pet state Batcher.streamDataBuilder.set() + KvClient.getValue()
3 0G Storage Log Permanent memory archive Indexer.upload(MemData) β€” Merkle root returned + stored
4 0G Compute AI personality Compute Router /v1/chat/completions β€” ZG-Res-Key TEE verification

Why Only 0G Can Power Gochi

1. Dual-Layer Storage β€” No other protocol gives you KV + Log in one SDK. KV keeps the pet alive (real-time state); Log keeps it immortal (permanent memories). Without 0G you'd need two separate systems, two SDKs, two billing accounts.

2. Verified AI β€” 0G Compute's TEE signing (ZG-Res-Key header) provides cryptographic proof that the pet's responses came from a genuine compute environment β€” impossible with centralized providers.

3. Ecosystem Cohesion β€” One private key signs INFT mints, KV writes, Log uploads, and Compute payments. All visible in one explorer ecosystem (ChainScan + StorageScan).


πŸš€ Getting Started

Prerequisites

Installation

git clone https://github.com/edycutjong/gochi.git
cd gochi
npm install
cp .env.example .env.local

Environment Variables

Variable Required Description
NEXT_PUBLIC_CONTRACT_ADDRESS βœ… Deployed Gochi.sol address
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID βœ… cloud.walletconnect.com
NEXT_PUBLIC_SUPABASE_URL βœ… Supabase project URL
NEXT_PUBLIC_SUPABASE_ANON_KEY βœ… Supabase anon key
SUPABASE_SERVICE_ROLE_KEY βœ… Supabase service role (server-only)
PRIVATE_KEY βœ… Burner wallet for 0G Storage writes
INDEXER_RPC βœ… https://indexer-storage-turbo-testnet.0g.ai
KV_NODE_URL βœ… 0G KV node endpoint
FLOW_CONTRACT_ADDRESS βœ… 0G FixedPriceFlow contract
NEXT_PUBLIC_RPC_URL βœ… https://evmrpc-testnet.0g.ai
OPENAI_API_KEY πŸ”Ά Fallback AI (when ROUTER_API_KEY not set)
ROUTER_API_KEY πŸ”Ά 0G Compute Router key from pc.0g.ai
npm run dev      # http://localhost:3000

Deploy Smart Contract

npx hardhat run scripts/deploy.ts --network zero-g-galileo
# Update NEXT_PUBLIC_CONTRACT_ADDRESS in .env.local + Vercel

πŸ§ͺ Testing & CI

npm run lint          # ESLint
npm run typecheck     # tsc --noEmit
npm run test          # Jest unit tests
npm run test:coverage # Coverage report
npm run ci            # Full pipeline

πŸ”— On-Chain Verification

Proof Link
INFT Contract chainscan-galileo.0g.ai/address/0x9BDA4...8cf
Mint Transaction chainscan-galileo.0g.ai/tx/0x5213...6c77
NFT Metadata gochi.edycu.dev/api/metadata/1
NFT Image gochi.edycu.dev/api/metadata/1/image

πŸ“„ License

MIT Β© 2026 Edy Cu


Built for HackQuest 0G APAC Hackathon 2026

Powered by 0G Network Β· Hosted on Vercel Β· Fallback by Supabase