https://github.com/edycutjong/gochi
๐พ On-chain AI virtual pet on 0G Network. Built for HackQuest 0G APAC 2026.
https://github.com/edycutjong/gochi
0g-network ai dapps hackathon inft nextjs react smart-contracts solidity virtual-pet wagmi web3
Last synced: 20 days ago
JSON representation
๐พ On-chain AI virtual pet on 0G Network. Built for HackQuest 0G APAC 2026.
- Host: GitHub
- URL: https://github.com/edycutjong/gochi
- Owner: edycutjong
- License: mit
- Created: 2026-05-16T06:35:21.000Z (about 2 months ago)
- Default Branch: main
- Last Pushed: 2026-05-16T09:28:50.000Z (about 2 months ago)
- Last Synced: 2026-05-16T10:42:57.877Z (about 2 months ago)
- Topics: 0g-network, ai, dapps, hackathon, inft, nextjs, react, smart-contracts, solidity, virtual-pet, wagmi, web3
- Language: TypeScript
- Homepage: https://gochi.edycu.dev
- Size: 4.7 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Agents: AGENTS.md
Awesome Lists containing this project
README
## ๐งโโ๏ธ 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](https://gochi.edycu.dev) |
| ๐ **Pitch Deck** | [gochi.edycu.dev/pitch](https://gochi.edycu.dev/pitch/index.html) |
| ๐ฌ **Demo Video** | [YouTube](https://youtu.be/IEQkZUbJdmo) |
| ๐ **Contract** | [`0x9BDA4...8cf`](https://chainscan-galileo.0g.ai/address/0x9BDA4cBfda7a7960251A4EE07A7ec0C00239a8cf) on 0G Galileo |
| ๐๏ธ **Architecture** | [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) |
**To test in 60 seconds:**
1. Go to [gochi.edycu.dev](https://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.
[](https://gochi.edycu.dev)
[](https://gochi.edycu.dev/pitch/index.html)
[](https://chainscan-galileo.0g.ai/address/0x9BDA4cBfda7a7960251A4EE07A7ec0C00239a8cf)
[](https://www.hackquest.io/hackathons/0G-APAC-Hackathon)






[](https://github.com/edycutjong/gochi/actions/workflows/ci.yml)

---
## ๐ธ Screenshots
### Landing & Birth
Landing โ glitch hero, 0G stats, sponsor strip
BORN ON 0G CHAIN โ hatching after mint tx confirmed on-chain
### Gameplay โ Feed ยท Play ยท Sleep
Feed โ hunger stat written to 0G Storage KV
Play โ mood increases, memory archived to 0G Log
Sleep โ energy restored, Merkle root stored
### AI Chat & Core Memories
0G Compute responds in character โ stat-aware personality
Gochi references past interactions from memory context
Personality shifts with stats โ grumpy when hungry, playful when happy
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](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
- Node.js โฅ 20, npm
- MetaMask with [0G Galileo Testnet](https://docs.0g.ai/build-with-0g/network-info) configured (Chain ID: 16602)
- Testnet tokens from the [0G Faucet](https://faucet.0g.ai)
### Installation
```bash
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](https://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](https://pc.0g.ai) |
```bash
npm run dev # http://localhost:3000
```
### Deploy Smart Contract
```bash
npx hardhat run scripts/deploy.ts --network zero-g-galileo
# Update NEXT_PUBLIC_CONTRACT_ADDRESS in .env.local + Vercel
```
---
## ๐งช Testing & CI
```bash
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](https://chainscan-galileo.0g.ai/address/0x9BDA4cBfda7a7960251A4EE07A7ec0C00239a8cf) |
| Mint Transaction | [chainscan-galileo.0g.ai/tx/0x5213...6c77](https://chainscan-galileo.0g.ai/tx/0x5213a03e6fa209136b3da2750087af08b5f9456115f493af8e035491bccf6c77) |
| NFT Metadata | [gochi.edycu.dev/api/metadata/1](https://gochi.edycu.dev/api/metadata/1) |
| NFT Image | [gochi.edycu.dev/api/metadata/1/image](https://gochi.edycu.dev/api/metadata/1/image) |
---
## ๐ License
[MIT](LICENSE) ยฉ 2026 Edy Cu
---
**Built for [HackQuest 0G APAC Hackathon 2026](https://www.hackquest.io/hackathons/0G-APAC-Hackathon)**
Powered by **[0G Network](https://0g.ai)** ยท Hosted on **[Vercel](https://vercel.com)** ยท Fallback by **[Supabase](https://supabase.com)**