Anonymous pay-per-use payments for Tangle Blueprints via cross-chain shielded pools and prepaid credits.
Privacy-preserving payment system that enables users to pay for cloud services — LLM inference, compute, storage — without revealing their identity to the operator or on-chain observers.
How it works:
- Deposit stablecoins into a shielded pool (USDC, USDT, DAI → single anonymity set)
- Withdraw partially via a ZK proof to fund a pseudonymous credit account
- Authorize many job payments with cheap EIP-712 signatures (~50k gas each)
- Unspent funds stay shielded as change UTXOs, each withdrawal unlinkable to the last
The operator serves requests and claims payment, but never learns the user's wallet address, deposit history, or total balance.
The system supports two payment modes. Users choose per request based on their privacy requirements.
| Credit Mode (Prepaid Credits) | RLN Mode (Per-Request Proofs) | |
|---|---|---|
| Privacy | Pseudonymous within session, unlinkable across sessions | Full per-request unlinkability |
| Per-request latency | <100ms (ECDSA signature) | ~640ms (ZK proof, parallelizable to near-zero) |
| Per-request gas | ~50k (on-chain) | 0 (batched settlement) |
| ZK proofs | 1 per session | 1 per request (off-chain verified) |
| Abuse protection | Nonce ordering | Shamir secret sharing (cryptoeconomic slashing) |
| Best for | High-frequency, low-latency inference | Sensitive workloads (medical, legal, journalism) |
Both modes coexist on the same operator. See examples/ for runnable TypeScript code demonstrating each flow.
User deposits (any chain) → VAnchor shielded pool
↓ ZK proof (one-time)
ShieldedGateway
↓ fund
ShieldedCredits
↓ EIP-712 sig (per job)
Operator serves + claims
| Contract | Purpose |
|---|---|
ShieldedGateway |
Bridges VAnchor withdrawals to Tangle service lifecycle |
ShieldedCredits |
Prepaid accounts with EIP-712 spend authorizations, expiry refunds |
LayerZeroAnchorBridge |
Cross-chain Merkle root relay via LayerZero V2 |
- Zero modifications to Tangle's audited core contracts
- Variable-amount UTXO model (not fixed denominations) with JoinSplit transactions
- Cross-chain deposits via 8-chain bridge (Ethereum, Arbitrum, Base, Optimism, Polygon, BSC, Avalanche, Hyperliquid)
- Expiry-based refunds — if operator doesn't claim before deadline, user reclaims funds
- Multi-stablecoin wrapping — USDC + USDT + DAI → single pool token, maximizing anonymity set
# Clone with submodules
git clone --recursive https://github.com/tangle-network/shielded-payment-gateway.git
cd shielded-payment-gateway
# Install dependencies
forge soldeer update
./scripts/setup-shielded-deps.sh
# Build
forge build
# Test (104 tests)
forge testcd sdk/shielded-sdk
npm install
npx vitest run # 40 tests including real ZK proof generationnpx tsx sdk/shielded-sdk/src/cli.ts keygen # Generate credit account keys
npx tsx sdk/shielded-sdk/src/cli.ts balance --credits 0x... --commitment 0x...
npx tsx sdk/shielded-sdk/src/cli.ts authorize-spend --credits 0x... --amount 1 ...# 1. Run trusted setup ceremony
./scripts/trusted-setup/ceremony.sh
# 2. Deploy everything to a chain
export RPC_URL=https://sepolia.base.org PRIVATE_KEY=0x... TANGLE=0x...
./scripts/deploy-full-stack.sh
# 3. Verify deployment
GATEWAY=0x... CREDITS=0x... POOL=0x... WRAPPER=0x... ./scripts/verify-deployment.shSee deploy/config/ for Base Sepolia and Base Mainnet configurations.
Technical spec: shielded-payments.pdf
Covers: UTXO change mechanics, operator knowledge boundaries, privacy analysis, AI use cases (inference, image generation, agent execution, fine-tuning), cross-chain architecture, and cost comparison.
MIT
