Building PangeniAI: A Decentralized AI dApp on Polygon
AI that actually cares — no tricks, no hidden fees, and none of your data in someone else's hands.
For the better part of a year, the conversations I kept having with builders were always the same: "I love what AI can do, but I don't love what it costs me." Not just in money — in privacy, in control, in trust. Every major AI product runs on someone else's servers, stores your conversations in someone else's database, and can change the rules whenever it pleases.
So I set out to build something different. PangeniAI — a fully decentralized AI application where the wallet, the contracts, and the data all belong to the user. No backend server. No central authority. Just you, your keys, and the blockchain.
This post walks through the architecture, the smart contracts, the hard trade-offs, and the lessons learned along the way.
The Problem: AI Without Ownership
Modern AI platforms are convenient, but convenience often comes with a quiet surrender. You don't own your conversations. You can't move them. You can't prove what happened. And if the platform changes its terms — or disappears entirely — your data goes with it.
The web3 thesis is simple: ownership isn't a feature, it's the baseline. When you hold your private keys, you hold the authority. PangeniAI is an attempt to apply that thesis to AI seriously — not as a marketing tagline, but as an architectural constraint.
The Idea
A dApp with no backend where AI agents are minted as NFTs, conversations live on IPFS, and every interaction is recorded on-chain.
Two modes, one philosophy:
- Free Chat — immediate, honest AI help. No signup, no wallet, no strings. AI should be accessible to anyone, full stop.
- Web3 Pro — the full ownership experience. Mint your AI agents as ERC-721 NFTs, store data on IPFS, and keep custody of everything you create.
Everything is client-side. MetaMask signs, IPFS stores, the chain settles. If you have the keys, you have the app.
Architecture
┌──────────────────────────────────────────────┐
│ Frontend (React) │
│ ┌──────────┐ ┌────────┐ ┌───────────────┐ │
│ │ MetaMask │ │ Pinata │ │ OpenAI / │ │
│ │ Wallet │ │ IPFS │ │ Pollinations │ │
│ └────┬─────┘ └───┬────┘ └──────┬────────┘ │
│ │ │ │ │
│ ┌────▼───────────▼─────────────▼─────────┐ │
│ │ Smart Contracts (Solidity) │ │
│ │ • PangeniAI — ERC-721 NFT agents │ │
│ │ • PangeniStorage — IPFS CID tracking │ │
│ │ • PangeniRegistry — ratings, history │ │
│ └────────────────────────────────────────┘ │
└──────────────────────────────────────────────┘
│ │
Polygon Chain IPFS Network
(Amoy Testnet) (via Pinata Gateway)
There is no server in this diagram, and that is the entire point. The "backend" is a distributed ledger and a distributed filesystem — both of which anyone can verify and no one can quietly delete.
The Smart Contracts
The heart of PangeniAI is three Solidity contracts, deployed with Hardhat and audited by the OpenZeppelin standard library they're built on:
| Contract | Purpose |
|---|---|
| PangeniAI | An ERC-721 collection where every token is an AI agent — name, description, IPFS metadata, creator, visibility toggle. |
| PangeniStorage | A per-user data registry tracking IPFS CIDs — every backup and file reference, recorded and verifiable. |
| PangeniRegistry | The public agent ledger — registration, ratings, and a permanent interaction count for every agent. |
Three contracts, three responsibilities, one idea: identity, storage, and reputation should be public, permanent, and provable.
Why ERC-721 for agents?
An AI agent with its own wallet address, personality, and track record is, in a very real sense, a thing. NFTs give things a global identity that can be owned, transferred, and shown off. Minting an agent turns a configurable prompt into a collectible — it stops being a line in a database and becomes an asset in your wallet.
Why IPFS for content?
Blockchain storage is expensive and public in the wrong way. IPFS gives us content-addressed, censorship-resistant storage with a fingerprint (the CID) that proves the data hasn't been tampered with. The chain stores the proof; IPFS stores the payload. It's the best of both worlds — durability on-chain, cost-efficiency off-chain.
What It Feels Like to Use
Open the app. You're greeted by a welcome screen with two paths.
Free Chat is immediate — ask about code, science, writing, anything. The underlying model routing (currently Pollinations) rotates and falls back gracefully across providers, so even free users get a resilient experience. Rate limits are detected and handled without drama.
Web3 Pro starts the moment you connect MetaMask. The app detects the network, prompts a switch to Polygon Amoy, and then the real fun begins:
- Mint agents. Give your agent a name, a description, a personality. Sign the transaction. Your agent is now a token on-chain.
- Chat with your agents. Stream responses from OpenAI (bring your own key — a deliberate privacy choice).
- Generate images. One click, and FLUX Schnell renders from your prompt.
- Store everything. Conversations and backups go to IPFS, with the CID anchored on-chain. Your data survives any server, any company, any apocalypse short of the internet itself.
- Backup & restore. Encrypted backups pinned to IPFS, tracked on-chain. Lose your phone, keep your agents.
Every meaningful action is a signed transaction. You're not asking a platform for permission — you're instructing the blockchain.
The Tech Stack
| Layer | Choice |
|---|---|
| Frontend | React 18, TypeScript, Vite, Tailwind CSS, Zustand |
| Blockchain | Solidity 0.8.20, Hardhat, ethers.js v6 |
| Standards | ERC-721, OpenZeppelin |
| Storage | Pinata IPFS (pinning + gateway) |
| Network | Polygon Amoy Testnet (chain 80002) |
| AI | OpenAI (BYOK), Pollinations, Replicate / FLUX Schnell |
The whole thing compiles, deploys, and tests through a single npm script surface — contracts:compile, contracts:test, contracts:deploy:amoy — keeping the local and testnet workflows identical.
Lessons Learned
Building this taught me more about constraints than about features.
1. "No backend" is a discipline, not a convenience. Every time you reach for a server, you import trust. The discipline is asking, "can the chain or IPFS do this?" — and surprisingly often, the answer is yes.
2. Keys belong to users — even API keys. Letting users bring their own OpenAI and Pinata keys isn't just cost-saving; it's philosophically consistent. The app holds no secrets, so the app has no power over you.
3. Resilience beats one perfect provider. For free chat, multi-endpoint fallback (with model rotation, history trimming, and rate-limit detection) matters more than any single model choice. Production AI is a reliability problem as much as a quality problem.
4. Testnets are where trust is earned. Shipping on Polygon Amoy means the invariants are verified in a live, adversarial environment before anything matters. The address of every deployed contract is checked, committed, and verifiable.
What's Next
PangeniAI is, at its core, an argument: that the next decade of AI doesn't have to repeat the mistakes of the last one. The roadmap is to push further — stronger agent-to-agent communication, a public agent marketplace on the registry, and eventually mainnet.
But even today, the important thing is that anyone can verify the claim. The contracts are public. The addresses are committed. The data is on IPFS. Skepticism isn't an insult — it's the correct default for web3, and I welcome it.
Conclusion
The most common objection to decentralized apps is that they're complex. And honestly — they are. But the complexity is the cost of freedom, and it's falling every year. The wallets are better, the tooling is better, and the user experience is finally catching up.
PangeniAI is my small contribution to a world where AI is a thing you own, not a thing that owns you.
PangeniAI is open source and live on Polygon Amoy Testnet. Repo: github.com/Pratikeeyyyy/ai.
"Free forever. Yours always."
Top comments (0)