Shift

Spends expiring 0G compute credits on work you queued, with proof of every result on 0G Chain.

Shift

Created At

ETHGlobal Mumbai

Project Description

0G Private Computer credits renew every day at 00:00 UTC, and whatever is not used expires. Each staked iAI receives 1.271 credits per day, worth more than $1, and that value disappears every night it goes unused. Even when people do use AI, they rarely get proof of which model produced a result, who owns it, or what it cost.

Shift fixes both. During the day you queue work: an audio file to summarize, a document to analyze, or an image prompt. Before the cutoff (23:00–23:50 UTC), Shift spends your balance for you. A 0G decision model rates each task as simple, standard or complex, and an optimizer picks the cheapest model that still clears that quality bar within the night's budget. A "Run tonight's shift now" button runs the same pipeline on demand.

You connect with a scoped 0G management key that can only read your balance and create or revoke keys. Each night Shift mints a short-lived key capped to the budget, runs the work through the 0G Router, stores the outputs on 0G Storage, and revokes the key before it returns.

If you opt in, leftover budget goes to public-good work. The first commons job translates Ethereum documentation (ethereum.org, CC BY 4.0) into Hindi and Marathi with two different models, and a result is accepted only when a decision model judges that both carry the source meaning. Rejected rows stay visible.

Every finished result becomes a Merkle leaf (owner, model, cost, request id, storage root), and each night's root is anchored on 0G Chain in the ShiftLedger contract, along with on-chain records of donated compute. Anyone can paste a request id into /verify and check the proof against the contract from their browser.

How it's Made

Shift is a TypeScript monorepo (strict mode, zod on every external input) with three parts: apps/web (Next.js 15, React 19, Tailwind 4) for the pages, route handlers, plan preview and verifier; apps/worker for the 23:00–23:50 UTC nightly window, the key sweeper and on-chain anchoring; and packages/core with the 0G Router client, key vault, optimizer, task executors, Merkle code, storage and chain clients. State lives in PostgreSQL via Prisma, and everything runs on Railway.

0G has no third-party sign-in, so we built least-privilege delegation on its key APIs. The user pastes a management key (mk-) scoped to account:read, keys:create and keys:manage. It is encrypted at rest with AES-256-GCM, bound to the account address, and never sent back to the browser. Each night the worker mints an sk- key capped to the budget and pinned to the trust tier the plan chose, then revokes it in a finally block; a sweeper revokes anything older than two hours.

The optimizer is a greedy multiple-choice knapsack. One /v1/decisions call per text task sets the quality floor, and live catalog prices pick the cheapest model that clears it. Model ids come from the live catalog, nothing is hard-coded. If no private (TeeML) model is available for a private task, the task is deferred instead of silently downgraded. A second decision call is the commons quality gate (accept only when P(yes) >= 0.75).

Outputs and each night's manifest go to 0G Storage with @0gfoundation/0g-ts-sdk (personal outputs encrypted, commons outputs public). The ShiftLedger contract (Solidity + Foundry) stores each night's Merkle root and manifest root and records donations; it is deployed on 0G Galileo testnet. Leaves use OpenZeppelin's StandardMerkleTree encoding, and a forge test checks TypeScript/Solidity hash parity. The verifier recomputes the leaf in the browser and calls verifyLeaf through the public Galileo RPC with viem. Our ENS name, tryshift.eth, publishes the contract address in a text record that /verify cross-checks.

A notable hack: the Router catalog changed during the event (TeeML and decision models disappeared from the listing), so every path degrades honestly. Private tasks wait, classification falls back without a Router call, and the commons gate waits rather than accepting rows. 174 web unit tests pass.

background image mobile

Join the mailing list

Get the latest news and updates