NFT ownership of ai image generated, prove that image is yours
ChainRight is a decentralized provenance system for AI-generated images built entirely on 0G. It gives every AI artwork an immutable, cryptographically verifiable birth certificate on the blockchain — solving the problem that AI images have no way to prove who created them, when, or with what prompt and model. The project has two interfaces: a premium Next.js 15 web application where users generate AI images via 0G Compute (Flux Turbo, TEE-verified), store them on 0G Storage (Merkle proofs + sequence numbers), and mint them as NFTs on 0G Chain (ChainRightERC721 with full provenance struct). Anyone can then verify an image's authenticity through a real-time 5-step on-chain analysis culminating in a "Wow Moment" — a visual demonstration where modifying a single pixel completely changes the SHA-256 Merkle Root, proving cryptographic impossibility to forge. The second interface is an autonomous Telegram verification agent powered by DeepSeek Function Calling. Users send images with natural language ("verify this", "is this real?") and the agent autonomously decides which tool to invoke, downloads the image, computes the Merkle Root, queries 0G Chain for provenance (including querying on-chain events for tokenId and transaction hash), generates a Certificate of Authenticity PDF, and responds with all provenance data plus ChainScan/StorageScan/NFT explorer links. The agent maintains persistent memory synced to 0G Storage KV/Log across restarts. The entire UI follows a premium Black & Amber design system, using Newsreader serif typography and surgical amber accents on near-black surfaces.
The project is built with TypeScript across all layers. The web frontend uses Next.js 15 (App Router) with React 19, Tailwind CSS v4, and RainbowKit/Wagmi for wallet connectivity with a custom amber dark theme. All wallet-gated routes are protected by a "Mechanical Vault Dial" gate UI. Smart contracts are written in Solidity 0.8.24 with evmVersion "cancun" (required for 0G Chain) and deployed via Hardhat. The ChainRightERC721 contract stores a full ProvenanceRecord struct including merkleRoot, zkResKey, prompt, model, sequenceNumber (txSeq for StorageScan linking), timestamp, and creator. The contract emits ProvenanceMinted events that the agent queries to retrieve tokenId and transactionHash for building explorer links. Three 0G SDKs are integrated: @0gfoundation/0g-ts-sdk (Storage — ZgFile for Merkle trees, Indexer for upload/download, and we reuse uploadBuffer/downloadFile for the agent's persistent KV/Log memory), @0glabs/0g-serving-broker (Compute — provider discovery, TEE inference with Flux Turbo, and the critical processResponse() call for fee settlement), and ethers v6 (Chain — contract interaction with explicit v6-only patterns: JsonRpcProvider, parseEther, waitForDeployment). The autonomous agent is the most architecturally interesting piece. It uses grammY (Telegram framework) and runs as a standalone tsx process alongside Next.js. The core innovation is the Function Calling loop: DeepSeek receives the user's message plus four tool definitions (verify_image, show_help, show_stats, chat_reply) and autonomously decides which to invoke. We feed the tool execution result back to DeepSeek to generate a natural language response that always includes every provenance field plus all explorer links. A notable hack: the agent queries contract events (ProvenanceMinted) filtered by Merkle Root to extract tokenId and transactionHash — data not available in the contract's read functions — enabling ChainScan NFT and transaction links that make the provenance tangible. For persistent memory, we implemented a local-first JSON state with throttled sync to 0G Storage every 5 operations plus a SIGINT handler for final sync on shutdown. Merkle Roots are stored in .0g-kv-root for cross-restart recovery via downloadFile. This avoids the complexity of the full KV stream API (Batcher + Flow contracts) while still demonstrating decentralized persistent memory. Certificate PDFs are generated with jsPDF in both browser (web app) and Node.js (agent — using output("arraybuffer") → Buffer). The Wow Moment renders a character-by-character hash diff with amber/rose highlighting and an animated cryptographic similarity counter dropping to 0%.

