System Architecture

CanTrustAI — Trusted AI Inference

Pay-per-query AI inference with on-ledger token economics, escrow settlements, and full audit trails — powered by Daml smart contracts on Canton.

FRONTEND
👤

User Dashboard

View token balances, purchase history, and spending activity in real time.
React Auth0 SSO
💰

Buy Tokens

Purchase compute tokens with Canton Coin (CC) through atomic delivery-vs-payment.
CC → Compute Atomic DVP
🤖

AI Query Interface

Send prompts to AI models. Cost is metered per query and settled on-ledger.
Multi-model Usage Stats
REST API  /  JWT + API Keys
BACKEND
🔒

Auth & API Keys

Auth0 JWT validation and API key authentication with rate limiting.
Auth0 Rate Limiter API Keys
⚙️

Core Services

Purchase, drawdown, UTXO management, deposit, and inference orchestration with per-user concurrency locks.
Purchase Drawdown UTXO Inference Registry
🧠

AI Router

Forwards prompts to LLM providers. Calculates actual token cost for settlement.
OpenRouter Pricing
gRPC Ledger API  /  JSON Ledger API
LEDGER
🎮

ComputeTokenHolding

UTXO-based token holdings. Supports merge for consolidation. Implements Splice Holding interface.
UTXO Model Splice Standard
📦

Purchase (DVP)

Propose → Accept → Allocate CC → Settle atomically. Mints compute tokens on payment.
Proposal Allocation Atomic Settle
📑

Drawdown & Escrow

Delegation authorizes spending. Hold → Settle for variable AI costs with automatic refunds.
Delegation Hold / Settle Audit Trail
Canton Synchronization Protocol
INFRA
🌐

Canton Network

Decentralized synchronization domain. Participant nodes validate and commit transactions.
Participant Node Sync Domain
💰

Splice / Canton Coin

Native payment rail. CC (Amulet) used for token purchases with FeaturedAppRight rewards.
Amulet (CC) Rewards
🗃️

Postgres & Logs

API key storage, query logging, and usage analytics. Off-ledger operational data.
Drizzle ORM Query Logs

How an AI Query Works

End-to-end flow from user prompt to settled payment
1

Authenticate

User sends prompt with JWT or API key

2

Escrow Hold

Max cost reserved on-ledger from token balance

3

AI Inference

Prompt routed to LLM; actual tokens metered

4

Settle & Refund

Actual cost debited; surplus returned to user

5

Audit Record

Immutable DrawdownRecord created on ledger