An open API service indexing awesome lists of open source software.

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.

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.


[![Live Demo](https://img.shields.io/badge/๐Ÿš€_Live-gochi.edycu.dev-06b6d4?style=for-the-badge)](https://gochi.edycu.dev)
[![Pitch Deck](https://img.shields.io/badge/๐Ÿ“Š_Pitch-Deck-f59e0b?style=for-the-badge)](https://gochi.edycu.dev/pitch/index.html)
[![Contract](https://img.shields.io/badge/๐Ÿ“œ_Contract-0G_Galileo-22c55e?style=for-the-badge)](https://chainscan-galileo.0g.ai/address/0x9BDA4cBfda7a7960251A4EE07A7ec0C00239a8cf)
[![Built for HackQuest](https://img.shields.io/badge/HackQuest-0G_APAC_2026-8b5cf6?style=for-the-badge)](https://www.hackquest.io/hackathons/0G-APAC-Hackathon)


![Next.js](https://img.shields.io/badge/Next.js_16-black?style=flat&logo=next.js)
![React](https://img.shields.io/badge/React_19-20232A?style=flat&logo=react&logoColor=61DAFB)
![TypeScript](https://img.shields.io/badge/TypeScript-3178C6?style=flat&logo=typescript&logoColor=white)
![Tailwind](https://img.shields.io/badge/Tailwind_v4-38B2AC?style=flat&logo=tailwindcss&logoColor=white)
![Solidity](https://img.shields.io/badge/Solidity-363636?style=flat&logo=solidity&logoColor=white)
![Supabase](https://img.shields.io/badge/Supabase-3ECF8E?style=flat&logo=supabase&logoColor=white)
[![CI](https://github.com/edycutjong/gochi/actions/workflows/ci.yml/badge.svg)](https://github.com/edycutjong/gochi/actions/workflows/ci.yml)



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](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)**