A privacy-preserving zero-knowledge smart contract built using o1js that verifies whether a user’s age is above a required threshold (e.g., 18) without revealing the actual age.
This zkApp is deployed and tested on Mina Devnet.
- Zero-Knowledge age verification
- Private input:
age - Public rule:
age ≥ minAge - Stores last verified age on-chain (as a Field)
-
The zkApp exposes a method
verifyAge(age, minAge) -
A zero-knowledge proof ensures:
age ≥ minAge -
If valid, zkApp stores the verified age on-chain
The verifier checks the proof, without seeing the actual age.
-
Anyone can read the stored value from the blockchain
This showcases how Mina zkApps can be used for privacy-preserving identity checks.
| Key | Purpose |
|---|---|
| Fee Payer | Pays transaction fees (MINA) |
| zkApp Key | Owns and authorizes the zkApp |
project-root/ │
├── src/
│ ├── AgeVerifierDevnet.ts # zkApp smart contract
├── scripts/
│ ├── deployDevnet.ts
│ ├── callVerifyAgeDevnet.ts
│ └── readStateDevnet.ts
│
├── package.json
├── tsconfig.json
└── README.md
- Network: Mina Devnet
- GraphQL Endpoint:
https://api.minascan.io/node/devnet/v1/graphqlhttps://minascan.io/devnet/account/<ZKAPP_ADDRESS>
Requires Node.js 18.14.0 or higher.
npm installnpm run buildnode build/scripts/deployDevnet.jsAfter deployment, note:
zkApp address
Transaction hash (from explorer)
node build/scripts/callVerifyAgeDevnet.jsThis
-
Generates a zk proof
-
Calls verifyAge(age, minAge)
-
Updates on-chain state
node build/scripts/readStateDevnet.jsThis reads:
zkApp balance
lastVerified age
Mina Protocol (Devnet)
o1js
TypeScript
Node.js
zkApp lifecycle (compile → deploy → call → read)
Fee payer vs zkApp key separation
Devnet transactions
On-chain state management
Zero-knowledge constraints
Apache 2.0 License