About the Project
What Inspired Us
We kept seeing the same pattern: people pay for API credits and then let them expire. You subscribe for a month, use a fraction, and the rest disappears. Credits aren’t resellable, transferable, or tradeable. They just get wasted.
We wanted to turn those credits into assets: something you own, can sell, and that settles on-chain. The XRP Ledger’s low fees and issued currency model made it a natural fit. That’s where openchain started: what if AI inference credits were tokenized, tradeable, and settled on-chain?
What We Learned
We learned how to build a bridge between Web2 AI APIs and Web3 payments. On the blockchain side: trust lines, issued currencies, XRPL’s DEX for price discovery, and Crossmark for wallet signing. On the AI side: OpenAI’s API structure, token metering, and cost calculations. The hard part was matching them in a way that felt seamless for users.
We also saw how much people care about transparency. When credits are on-chain, every burn and every purchase is visible. That accountability became central to the design.
How We Built It
Stack: Next.js 16 (App Router), XRPL (Testnet), Supabase, Crossmark, OpenAI.
Flow:
Users connect via Crossmark and deposit XRP for INFX credits at a 1:100 rate.
INFX credits are XRPL-issued tokens held in trust lines.
Users create API keys and call an OpenAI-compatible endpoint; each token used burns INFX.
Sellers list access on the marketplace for RLUSD; buyers pay on-chain and receive keys instantly.
Usage from marketplace keys is debited from the seller’s balance, not the buyer’s.
Metering: Model-specific pricing (e.g., GPT-4o at ( $5/\text{1M} ) input tokens) is converted to INFX using a fixed credits-per-dollar rate, so every API call maps to a deterministic on-chain debit.
Challenges We Faced
Trust line flow: The backend checks for trust lines before issuing credits. Early on, we didn’t handle “trust line not established” well; users saw generic errors. We fixed it by guiding them through a one-time Crossmark TrustSet transaction and surfacing clear error messages.
Transaction parsing: XRPL’s tx response uses DeliverMax for some payment types and Amount for others. The deposit verification logic failed on certain transactions. We added fallback parsing:
amount = txJson.DeliverMax ?? txJson.Amount and more robust logging.
Vercel deployment: The build failed because the OpenAI client was initialized at import time and threw when OPENAI_API_KEY was missing. We moved to lazy initialization so the client is only created on the first request, allowing the build to succeed before env vars are applied.
Crossmark UX: Users occasionally couldn’t scroll the Crossmark approval modal or saw timeouts. We increased timeouts and simplified the auth flow to a single signInAndWait call instead of a multi-step nonce challenge.
The Result
openchain turns AI inference into on-chain assets. Deposits, sales, and usage settle on the XRP Ledger. Unused credits can be sold instead of wasted. Every call is metered and verifiable. We hope this makes a case for a permissionless, transparent market for AI access.
Log in or sign up for Devpost to join the conversation.