Skip to content
Maxrodri0311Public

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

14 Commits

Folders and files

Repository files navigation

SnapPass (snappass) — Gasless Prepaid Vouchers, Scoped Virtual Cards & AI Safe-Spend Guardrails on Solana

Solana Devnet Anchor Rust Dual Solana SDK License: MIT

⚡ Judge Quick-Verification Panel (Zero SOL • Zero Extensions Required)


1. Why SnapPass? (The LATAM FX Tax + Autonomous AI Agent Problem)

A. Emerging-Market SaaS Friction (+30% Card Taxes vs. 5-Step Crypto Onboarding)

In Latin America—especially Argentina—paying $0.75 to $3.00 for an international SaaS module, developer API, or micro-subscription with a credit/debit card triggers +30% FX tax surcharges and frequent issuer blocks. Meanwhile, standard crypto checkouts force mainstream users through a high-drop-off 5-step funnel (Exchange KYC → P2P → Browser Extension Install → Seed Phrase Backup → Buying SOL for gas).

B. Why Autonomous AI Agents Cannot Hold Raw Hot Wallets

As autonomous AI agents increasingly purchase APIs, compute, and real-time data feeds on behalf of users, handing an LLM agent a funded master hot wallet is a critical security liability: a single prompt injection or model hallucination can drain the entire wallet balance in seconds.

SnapPass solves both problems with a single on-chain primitive:

  1. Prepaid SHA-256 USDC Vouchers (VoucherAccount PDA): Acquired off-chain without international card taxes and backed 1:1 by USDC escrowed in the protocol's non-custodial SPL Token Vault PDA.
  2. Zero-Friction Ephemeral Wallets + Role-Pinned Gasless Relayer: The browser auto-generates a local Ed25519 keypair (or optionally connects Phantom). Our FastAPI Relayer pays 100% of Solana gas fees (Slot 0 = payer) while the user co-signs as Slot 1 = owner.
  3. Scoped Disposable Virtual Cards (TempCardAccount PDA): Claiming a voucher mints or tops up a temporary virtual debit card with an immutable per-transaction spending_limit and automatic expires_at TTL. Any human or AI agent charge exceeding spending_limit is deterministically rejected on-chain by Solana (ErrorCode::ExceedsSpendingLimit / 0x1775).

2. Dev3pack 4-Track Alignment & On-Chain Proof Matrix

Hackathon Track Prize How SnapPass Qualifies & Concrete On-Chain Proof
1. Best App Overall on Solana $5,000 Full-stack consumer + developer protocol combining Rust/Anchor PDAs, a Python solders Gasless Relayer & Binary Verifier SDK, and a React/TS @solana/web3.js Command Center where judges mint, claim, unlock, and verify on Solana Explorer in 1 screen with 0 SOL.
2. Dev3pack Argentina Local Track $500 Directly eliminates Argentina's +30% international card FX surcharge and 5-step P2P onboarding via Prepaid USDC Vouchers (SNAP-2026-XXXX-XXXX) redeemable gaslessly into a local browser wallet in <3 seconds.
3. Best DeFi App on Solana $250 Non-custodial SPL Token Vault Escrow PDA ([b"vault", usdc_mint]), programmable virtual debit cards (TempCardAccount) with on-chain spending_limit & TTL, atomic merchant treasury settlement, and instant gasless Close & Refund Card (close_card).
4. Best Agentic App on Solana $250 AI Agent Safe-Spend Firewall (POST /api/v1/agent/auto-unlock): Judges test both (A) Safe Autonomous Purchase ($0.75 <= $1.50 cap → UNLOCKED + Explorer tx) and (B) Hallucinated AI Overspend ($3.00 > $1.50 cap → blocked on-chain by AnchorError 6005: ExceedsSpendingLimit / 0x1775).

3. Architecture, 5-PDA Byte Layout & Live Devnet Registry

flowchart LR
    subgraph L3["Layer 3: React + TS Frontend (@solana/web3.js)"]
        EW["Ephemeral Ed25519 Wallet<br/>(or Optional Phantom)<br/>Signs Slot 1 (owner)"]
        VC["3D Scoped Virtual Card UI<br/>+ Live Judge Quest Bar"]
    end

    subgraph L2["Layer 2: FastAPI Relayer & Verifier SDK (Python solders)"]
        FW["Instruction Firewall<br/>Role-Pinning (Slot 0 = payer)<br/>+ Discriminator Whitelist"]
        AG["AI Agent Safe-Spend Evaluator<br/>POST /api/v1/agent/auto-unlock"]
        VR["Direct 206-Byte PDA Deserializer<br/>GET /api/v1/entitlements/..."]
    end

    subgraph L1["Layer 1: Solana Devnet Smart Contract (Anchor / Rust)"]
        PC["ProtocolConfig PDA (74 B)<br/>Pins Official USDC Mint"]
        VP["VoucherAccount PDA (90 B)<br/>SHA-256 Secret Commitment"]
        TC["TempCardAccount PDA (66 B)<br/>balance + spending_limit + TTL"]
        VT["SPL Vault Escrow PDA<br/>1:1 Mock-USDC Backing"]
        EP["EntitlementPass PDA (206 B)<br/>On-Chain SaaS License Receipt"]
    end

    EW -->|"Base64 Partial Tx"| FW
    FW -->|"Co-Signs Slot 0 (0 SOL Gas)"| TC
    VP -->|"claim_voucher_to_card"| TC
    TC -->|"unlock_plan (Checks Limit 0x1775)"| EP
    VT -->|"Atomic Settlement / Refund"| TC
    AG -->|"Scoped Agent Keypair"| FW
    EP -->|"Raw Account Bytes"| VR
Loading

Exact Byte-Level On-Chain PDA Specification

All 5 Anchor accounts prepend an 8-byte discriminator (sha256("account:<Name>")[..8]):

PDA Account Deterministic Seeds Exact SPACE Key Fields & Role
ProtocolConfig [b"config"] 74 B admin (32), usdc_mint (32), vault_bump (1), bump (1) — Global anti-fake-mint singleton.
MerchantPlan [b"plan", merchant, plan_id] 182 B merchant (32), treasury (32), plan_id (36), tier (20), feature_tag (36), price_usdc (8), duration_secs (8), active (1), bump (1).
VoucherAccount [b"voucher", voucher_hash] 90 B issuer (32), amount (8), voucher_hash ([u8;32]), is_claimed (1), expires_at (8), bump (1).
TempCardAccount [b"card", owner] 66 B owner (32), balance (8), spending_limit (8), expires_at (8), is_active (1), bump (1).
EntitlementPass [b"entitlement", payer, merchant, plan_id] 206 B payer_wallet (32), merchant (32), plan_id (36), tier (20), feature_tag (36), expires_at (8), active (1), receipt_hash ([u8;32]), bump (1).

Deployed Solana Devnet Addresses

Protocol Component Solana Devnet Public Key Explorer Verification
SnapPass Anchor Program ID 9Zg8VjTxxAUHJycmZsJt27krSgPySbEuPn5habnnu8wv Inspect on Solana Explorer
Mock-USDC SPL Token Mint 97RkWMrviy4exQQ2dezy1VGrFaQLep1iwGgKoMkUixLs Inspect Mint
ProtocolConfig PDA ([b"config"]) 6QzjKtREDz1rtvQDApAS4m3SvhjmXiiPm6QiSznU6ZAG Inspect Config PDA
SPL Vault Escrow PDA ([b"vault", mint]) C4AJpzoBHvHcYAaCtuKsBxPjFHpmDrThwywgrCJkZyGg Inspect Vault PDA
Gasless Fee-Payer Relayer (Slot 0) 2qoPLfHtnu6wmqhLPLBVCwHkNadWHtHg8wd9mqs96QT9 Inspect Relayer
Demo Merchant Authority AVxrvxEs4MmyoYKLhxP1PFG3NdYpvwX4cQ4tFFCHAwd4 Inspect Merchant
Merchant Treasury USDC ATA 2X6WTnAQFm8xYpgDXZSqdsGfCh6GPA7ZUWNpSerSyqYu Inspect Treasury
Demo Issuer Refund USDC ATA 3pgVZ2jZNfodWH1sVow2wcjGfLduRH5xXKU7QTdwXXMY Inspect Refund Pool
Plan 1 (analytics-24h • $0.75) GYXgMMCGDKasdieSW6fZR7obZCvEwbATNSrXSe2yLeJJ Inspect Plan PDA
Plan 2 (ai-copilot-7d • $1.50) HkJizio3kswi4k2zmgJqvUHfkyCSdPVppYys5YD2WrmT Inspect Plan PDA
Plan 3 (pro-bundle-30d • $3.00) HPAmpZrW9DuLmPbH3DKGFGsNV71ucuMFiHqT1E6XQPFt Inspect Plan PDA

4. Defense-in-Depth Security Model (5 Hardened Patches)

  1. Anti Fake-Mint Singleton (ProtocolConfig PDA): Initialized once via initialize_protocol(). Pins the official usdc_mint and canonical vault_bump so no attacker can pass a counterfeit SPL token mint into create_voucher, unlock_plan, or close_card.
  2. Strict SPL Vault PDA Pinning: Every token-moving instruction enforces seeds = [b"vault", config.usdc_mint.as_ref()], bump = config.vault_bump and token::authority = config, preventing vault substitution attacks.
  3. Relayer Discriminator Whitelist + Role-Pinning (Slot 0/1) + Anti-ALT:
    • The public /api/v1/relay firewall only accepts transactions targeting SNAPPASS_PROGRAM_ID (and optional ComputeBudget) with the 3 user discriminators (claim_voucher_to_card, unlock_plan, close_card).
    • Role-Pinning: Verifies num_required_signatures == 2, pins RELAYER_PUBKEY (Account Index 0) strictly to ix.accounts[0] (payer), and forbids Index 0 from appearing in ix.accounts[1..N] (owner, issuer, merchant, or refund_token_account), eliminating fee-payer authority spoofing.
    • Anti-ALT / Per-IP Rate Limiting: Rejects obfuscated Address Lookup Table privilege escalation and enforces sliding-window IP rate limits (20 req/min on /relay, 5 req/min on /demo/mint-voucher).
  4. Ephemeral-Safe Refund Compatibility (close_card): Because zero-friction browser ephemeral keypairs do not possess pre-funded Associated Token Accounts (ATAs), close_card verifies refund_token_account.mint == config.usdc_mint while requiring an explicit cryptographic signature from owner: Signer<'info> (Slot 1), allowing unspent demo funds to return cleanly to the demo liquidity pool ATA (3pgVZ2...) or any user-designated USDC ATA.
  5. Runtime SHA-256 Preimage Verification (claim_voucher_to_card): Derives VoucherAccount via [b"voucher", voucher_hash.as_ref()] and verifies solana_program::hash::hash(secret_code.as_bytes()).to_bytes() == voucher.voucher_hash inside the instruction handler, preventing macro expansion pitfalls while guaranteeing cryptographic preimage security.

5. Quick Start & 3-Line Web2 Verifier SDK

SnapPass implements a Dual Solana SDK Stack:

  • Backend (backend/): Python 3.12 + FastAPI + solders / solana-py for zero-IDL binary PDA deserialization, transaction firewall inspection, and fee-payer co-signing.
  • Frontend (frontend/): React 18 + TypeScript + Vite + @solana/web3.js for client-side Ed25519 keypair persistence, Borsh instruction encoding, and partial transaction signing (requireAllSignatures: false).

A. Run the Frontend Command Center Locally

cd frontend
cp .env.example .env
npm install
npm run dev

Open http://localhost:5173. Toggle between Live Relayer Mode (Solana Devnet) and Mock Sandbox Mode from the top-right status pill at any time.

B. Run the FastAPI Gasless Relayer & Verifier Backend

cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000

C. 3-Line Web2 SaaS License Verification (curl / REST SDK)

Any Web2 backend can verify whether a user wallet holds an active, non-expired EntitlementPass PDA on Solana Devnet with a single HTTP GET call—no Web3 wallet popups required:

curl -s "http://localhost:8000/api/v1/entitlements/<PAYER_WALLET>/AVxrvxEs4MmyoYKLhxP1PFG3NdYpvwX4cQ4tFFCHAwd4/analytics-24h" \
  | jq '{valid: .valid, tier: .tier, feature_tag: .feature_tag, pda: .pda, explorer: .explorer_url}'

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages