Inspiration
AI agents increasingly need to purchase datasets, renew infrastructure, pay for security services, and interact with DeFi while their owners are offline.
Giving an agent unrestricted wallet access is dangerous. A compromised workflow, prompt-injection attack, or faulty decision could become an unlimited financial liability. Publishing every spending rule on-chain is not ideal either because budgets, categories, and limits may reveal sensitive operational information.
Latch is built around one principle: every payment must pass a private gate.
Instead of giving an agent control of an entire wallet, the owner delegates a narrow, revocable spending capability. A payment must satisfy its private rules before it can be authorized.
What it does
Latch demonstrates privacy-preserving delegated payments using a Compact smart contract deployed on Midnight Preprod.
The submission has two clearly separated parts:
- A live Compact contract deployment completed through a connected Lace wallet
- An interactive policy simulator that mirrors the contract’s authorization rules
Local simulation · Contract-equivalent logic
Simulator actions are not live on-chain transactions. They provide an instant, transparent way to explore the same capability rules implemented by the deployed contract.
Each capability can define:
- Total spending budget
- Per-payment limit
- Allowed spending category
- Maximum number of uses
- Revocation status
- Replay protection
The simulator demonstrates the full policy lifecycle:
Capability creation →
createCapability
The owner creates a constrained spending policy.Valid request →
authorizeSpendapproval
CodeShield requests payment for a security report and satisfies the policy.Invalid request →
authorizeSpendrejection
AlphaSignal requests payment for a trading dataset that exceeds the policy. The Owner sees a useful private explanation, while the Public Observer receives only a generic rejection.Replay attempt →
authorizeSpendrejection
Reusing an approved request is blocked through nullifier-based replay protection.Revocation →
revokeCapability
The owner revokes the capability. The simulator disables additional requests, reflecting the contract’s revoked-state enforcement.
Latch also provides two separate views:
- Owner View: shows private policy and management information
- Public Observer View: shows only commitments, status, and restricted receipts
The Public Observer is generated from a dedicated allowlisted data model. Private limits, spending rules, and rejection reasons are never passed into that interface.
Live Preprod deployment
The MOAT Compact contract is deployed on Midnight Preprod.
- Network: Midnight Preprod
- Status: Contract deployed
- Wallet: Lace
- Contract address:
3f45a282f188b82e5e8b029825a9057e2f3a295cd48b015eff73949eff8d8a25 - Transaction ID:
002d6d4d1f5f3965db970e14071947b895ca5a4aed76f5a0e5c8ba29384e333d64
This proves that the Compact contract is live. It does not imply that simulator actions are Preprod transactions.
How we built it
The frontend uses TypeScript, React, and Vite, structured around a typed MoatClient abstraction that separates the interface from blockchain-specific code.
The Compact contract implements three private circuits:
createCapabilityauthorizeSpendrevokeCapability
Together, they model:
- Agent authorization
- Per-payment limits
- Total-budget enforcement
- Category restrictions
- Maximum-use limits
- Revocation
- Nullifier-based replay protection
Commitments are domain-separated using namespaces including:
MOAT_OWNER_V1MOAT_POLICY_V1MOAT_CAPABILITY_ID_V1
Wallet connectivity uses the Midnight DApp Connector and Lace. The application safely handles duplicate providers, delayed authorization, stale sessions, network changes, and recoverable wallet errors.
Privacy is enforced throughout the data flow. Wallet addresses, balances, seeds, private state, witnesses, raw transactions, and provider payloads are never exposed through interface diagnostics.
Challenges we ran into
Our biggest challenge was demonstrating real privacy without overstating the implementation.
Privacy required more than hiding interface elements. We built separate Owner and Observer data models, sanitized copied and exported information, and added automated tests to detect private-data leakage.
Integrating Lace also required handling real browser-wallet behavior, including duplicate provider aliases, delayed authorization, network changes, correct method binding, and Connector API 4.0.1 transaction responses.
Finally, we kept the integration boundary honest. The contract deployment and Lace connection are real, while the public capability walkthrough is clearly labeled as a local, contract-equivalent simulator.
Accomplishments that we're proud of
Latch includes:
- A Compact contract deployed on Midnight Preprod
- Three compiled private circuits
- Real Lace wallet connectivity
- Private policy commitments
- Replay protection and revocation
- Separate Owner and Public Observer data models
- Privacy-safe diagnostics and clipboard handling
- A complete interactive policy simulator
- Automated privacy, wallet, contract, and interface tests
Latch never fabricates transaction hashes, treats wallet connectivity as proof of a capability transaction, or silently replaces a failed blockchain operation with simulated success.
Every result clearly distinguishes between the live Preprod deployment and the local policy simulator.
What we learned
Privacy-preserving payments require two kinds of correctness:
- Transaction correctness: only valid requests should be authorized
- Disclosure correctness: interfaces, receipts, logs, and errors must reveal no more than intended
We also learned that useful AI autonomy does not require unrestricted financial authority. Narrow, revocable capabilities offer a safer foundation than giving agents direct access to permanently funded wallets.
What's next
Our immediate next step is connecting the public application’s complete createCapability, authorizeSpend, and revokeCapability workflow to the deployed Preprod contract.
Future plans include:
- Multiple capabilities per Owner
- Expiration and renewal policies
- Recurring payment capabilities
- Persistent encrypted private state
- Better audit exports
- A separately deployed Public Observer
- SDK support for autonomous-agent frameworks
Latch can ultimately become a private authorization layer for autonomous finance letting AI agents pay for services without giving them unrestricted control of an owner’s wallet.
Built With
- compact
- github
- github-actions
- lace
- midnight
- node.js
- preprod
- react
- typescript
- vite
- vitest
- web-crypto-api

Log in or sign up for Devpost to join the conversation.