Onchain Puzzle Locks
Design puzzles whose solutions must be proven onchain via Sepolia smart contracts to unlock game content.
OUSD payments· pay in OUSD
Section · Onchain
full primer →The primitive.
Interactive puzzles is priced in OUSD; game designers pay with one tap from a Google-login wallet and get a receipt with a public proof link.
Why this primitiveOUSD ensures unique, verifiable puzzle solution submissions maintained transparently.
Kernel
A one-tap OUSD transfer from the user's Privy wallet to the creator, confirmed on chain.
Drives the UI as
A price tag in OUSD, a single Pay button, and a receipt with the explorer link.
Mainnet · real OUSDOUSD has no testnet. Demo with small amounts (≤ 1 OUSD). Pick your chain right above the prompt.
OUSD contract addresses → Contracts page
Appendix · SecretsRequired keys.
PRIVY_APP_ID
Required. Google sign-in + embedded wallet on your chain. Read it in a route loader — Lovable rejects VITE_* secret names.
open ↗ETHEREUM_RPC_URL / SOLANA_RPC_URL
Optional, server-only. A private RPC (Alchemy, Helius) if the public one rate-limits you.
open ↗Add these in your Lovable project under Settings → Secrets before pasting the prompt below.
Appendix · Mega-prompt
The build prompt.
budget · 1 message
Paste into a fresh Lovable project. Make sure the secrets above are set first. read the build strategy →
Build on
Each chain gets its own complete, self-contained prompt.
Build "Onchain Puzzle Locks" in ONE Lovable message. A single-page app that uses OUSD (Open USD) on mainnet.
CONCEPT
Design puzzles whose solutions must be proven onchain via Sepolia smart contracts to unlock game content.
Discipline: Game Design & Interactive Media (interactive puzzles). Primitive: OUSD payments — A one-tap OUSD transfer from the user's Privy wallet to the creator, confirmed on chain.
USER FLOW
The user picks a interactive puzzles item priced in OUSD (default 1.00 OUSD), taps Pay, confirms once in Privy, and sees a receipt with amount, time and the explorer link.
UI: A price tag in OUSD, a single Pay button, and a receipt with the explorer link.
CHAIN — Base MAINNET (real money, no testnet)
- chainId 8453 · RPC https://mainnet.base.org · Explorer https://basescan.org
- OUSD on Base: 0xB2000000000000000000002fEb517dFeC7415344
- Tx link: https://basescan.org/tx/<hash> · Contract page: https://basescan.org/address/0xB2000000000000000000002fEb517dFeC7415344
- Gas: ETH on Base (cheap). Turn on Privy gas sponsorship for Base so users never need ETH.
- viem: `import { base } from 'viem/chains'` — use it as Privy `defaultChain` and in `supportedChains`.
- OUSD is an ERC-20. Transfer with `encodeFunctionData({ abi: erc20Abi, functionName: 'transfer', args: [to, amount] })`, `value: 0n`, sent TO the OUSD address.
- Read `decimals()` from the contract once at boot — never hardcode it.
- Pass `{ sponsor: true }` to Privy `sendTransaction` (needs Base enabled in Privy → Gas Sponsorship).
CODE — paste these files as-is (install: `@privy-io/react-auth viem`)
// src/lib/ousd.ts
import { base as CHAIN } from 'viem/chains';
export { CHAIN };
import { createPublicClient, http, erc20Abi, encodeFunctionData, parseUnits, formatUnits } from 'viem';
export const OUSD = '0xB2000000000000000000002fEb517dFeC7415344' as const;
export const pub = createPublicClient({ chain: CHAIN, transport: http('https://mainnet.base.org') });
let dec: number | undefined;
export async function ousdDecimals() { return dec ??= await pub.readContract({ address: OUSD, abi: erc20Abi, functionName: 'decimals' }); }
export async function ousdBalance(owner: `0x${string}`) {
const raw = await pub.readContract({ address: OUSD, abi: erc20Abi, functionName: 'balanceOf', args: [owner] });
return Number(formatUnits(raw, await ousdDecimals()));
}
export async function transferTx(to: `0x${string}`, amount: string) {
const value = parseUnits(amount, await ousdDecimals());
return { to: OUSD, value: 0n, chainId: CHAIN.id,
data: encodeFunctionData({ abi: erc20Abi, functionName: 'transfer', args: [to, value] }) };
}
export const txUrl = (h: string) => 'https://basescan.org/tx/' + h;
export async function waitFor(hash: `0x${string}`) { return pub.waitForTransactionReceipt({ hash, timeout: 90_000 }); }
// src/components/privy-root.tsx (default export; loaded with React.lazy inside <ClientOnly>)
import { PrivyProvider } from '@privy-io/react-auth';
import { CHAIN } from '@/lib/ousd';
export default function PrivyRoot({ appId, children }: { appId: string; children: React.ReactNode }) {
return <PrivyProvider appId={appId} config={{ loginMethods: ['google'], defaultChain: CHAIN, supportedChains: [CHAIN],
embeddedWallets: { ethereum: { createOnLogin: 'users-without-wallets' } } }}>{children}</PrivyProvider>;
}
// Sending (inside a component under PrivyRoot)
// const { sendTransaction } = useSendTransaction(); // from '@privy-io/react-auth'
// const { hash } = await sendTransaction(await transferTx(to, '1.00'), { sponsor: true });
// await waitFor(hash); show txUrl(hash).
STACK
- TanStack Start (the Lovable default). One page at the index route.
- Privy for sign-in (Google) and embedded wallets on the chain below. Load Privy with
`React.lazy(() => import('./privy-root'))` inside `<ClientOnly>` — a static import crashes SSR.
- Secret `PRIVY_APP_ID` (paste in Project Settings → Secrets). Read it in a route loader via a server
function (`process.env.PRIVY_APP_ID`) and pass it to the provider. NEVER name a secret `VITE_*`.
- Show amounts in OUSD with 2 decimals; convert with the on-chain decimals.
- No smart contract deploy is needed: OUSD is already live. Every action is an OUSD token transfer.
SHARED CODE — paste as-is
// src/lib/privy.functions.ts
import { createServerFn } from '@tanstack/react-start';
export const getPrivyAppId = createServerFn({ method: 'GET' })
.handler(async () => ({ appId: process.env['PRIVY_APP_ID'] ?? null }));
// src/routes/index.tsx (shape)
// loader: () => getPrivyAppId()
// const { appId } = Route.useLoaderData();
// const PrivyRoot = React.lazy(() => import('@/components/privy-root'));
// if (!appId) render the full UI in demo mode with a banner "Add PRIVY_APP_ID to go live" (no sends).
// else: <ClientOnly fallback={<Skeleton/>}><Suspense><PrivyRoot appId={appId}><App/></PrivyRoot></Suspense></ClientOnly>
// Inside <App/>: const { ready, authenticated, login, logout } = usePrivy(); wait for `ready` before reading wallets.
REAL MONEY RULES (mainnet only)
- Above every Pay button show: "Mainnet · real OUSD". Default demo amounts ≤ 1 OUSD.
- Before sending, check the OUSD balance; if too low, show "Get OUSD" linking to https://joinopenstandard.com/integrate.
- Always confirm the wallet is on the right chain before sending; refuse with a clear "switch network" message otherwise.
- After sending, wait for confirmation, then show the explorer link. Never show success before confirmation.
TROUBLESHOOTING
- "window is not defined" / blank SSR page → Privy was imported statically. Only import it via React.lazy inside <ClientOnly>.
- Wrong network / chain mismatch → defaultChain and supportedChains must be the same chain object; refuse to send otherwise.
- Solana "TokenAccountNotFound" → the idempotent create-ATA instruction must precede the transfer; balance = 0 when no ATA.
- "insufficient funds for gas" → enable Privy gas sponsorship for this chain, or tell the user which gas coin to add.
- Balance too low → disable Pay and show "Get OUSD" linking to https://joinopenstandard.com/integrate.
COMPLIANCE (mandatory — OUSD is issued by Bridge, a Stripe company)
- Show a footer notice: "OUSD is not available in the European Economic Area or sanctioned regions. See https://joinopenstandard.com/legal/geo-restrictions-and-prohibited-use-cases".
- Never build or market for prohibited uses: gambling, games of chance, lotteries, sweepstakes, unlawful
prediction markets, adult content, cannabis, tobacco, weapons, pharmaceuticals, luxury goods, jewelry,
watches, precious metals, mixing, multi-level marketing, counterfeit goods or deceptive practices.
- OUSD is acquired through partners (Stripe/Bridge/Privy, Coinbase, Visa, Mastercard) or exchanges
(Coinbase, Kraken, Uniswap). The app itself never mints or redeems.
DEFINITION OF DONE
1. Google sign-in via Privy creates an embedded wallet on the chain above and shows its OUSD balance.
2. The interactive puzzles flow sends a real OUSD transfer, waits for confirmation, and shows a working explorer link.
3. The compliance footer and the real-money notice are visible.
4. The page works with zero secrets (demo mode with a "Add PRIVY_APP_ID to go live" banner).
Credit in the footer: "Built during the Creative AI & Quantum Hackathon organised by StreetKode Fam during Indian Krump Festival 14".Market sizing.
TAM
$700M
global puzzle game revenue including ARGs
SAM
$180M
blockchain-integrated puzzle experiences
SOM
$12M
indie puzzle creators exploring cryptographic challenges
Indicative figures for hackathon pitches — refine with your own research before raising.
RestrictionsOUSD is not available in the European Economic Area or sanctioned regions, and may not be used for gambling, lotteries, prediction markets, adult content, weapons and other prohibited uses. Read the full list ↗
Adjacent entries.
quest tracking
Onchain Quest Ledger
Securely log player quest progress and achievements on Ethereum Sepolia to prove in-game milestones.
item distributionTokenized Loot Drops
Distribute rare, verifiable loot as tokens directly through Sepolia smart contracts to guarantee authenticity.
community trustPlayer Reputation Ledger
Create immutable player reputation scores recorded on Sepolia to foster fair matchmaking and collaboration.
competitive scoringImmutable Scoreboards
Store game scores on Sepolia to prevent cheating and create permanent leaderboards.