TOKENSHARE / official-plan quota market

x402 / agentic payment rails · trust-minimized API supply

TOKEN
SHARE

Idle official-plan quota, sold by the call. KIMI / MOONSHOT FIRST

In plain words: paying for a Kimi plan you never fully burn through? Sell the leftover quota by the call — buyers pay per request, you keep the plan.

Sellers rent out the spare quota of their official LLM subscription plans — a relay holds their own platform key and forwards only to the provider's official endpoint. Buyers lock a few cents of USDC on-chain and pay per request. An immutable escrow holds the funds, settlement is priced on relay-reported usage in three tiers, and every call comes back with an EIP-712 receipt anyone can verify. Seller keys stay off-chain; the escrow holds only USDC. Custody modes, receipt limits & refund rules → policy.

LISTINGS ON-CHAIN
—
ACTIVE
—
RELAYS ONLINE
—
NETWORK
—

live values — read from the Registry contract; relays probed via /health

buyer — one call, end to end
$ tokenshare deposit --amount 0.50
  tx 0x9f2e…a1c4 confirmed · balance 500000
$ tokenshare lock --seller 0x7A3f…9c2E --max 0.05
  paymentId 42 · locked 50000 · ttl 600s
$ tokenshare call "summarize block 0x1f3a…" --model kimi-for-coding
  relay: isValid(42) → true · forwarding to api.moonshot.cn
  POST /v1/chat/completions → 200 OK · 1.24s
  usage  cached_in 12000 · in 26400 · out 2140
  settle actual 45552 · diff 4448 → buyer balance
  receipt EIP-712 ✓ verified · upstream api.moonshot.cn · kimi-for-coding

illustrative trace · amounts are USDC native units (6 decimals)

01MARKET

Preview of the configured sellers (config.js) — Registry.getListing() live: endpoint, models, per-model three-tier pricing, active flag. Pick a model chip to see its tier prices. Relay dots probe each listing's /health live from your browser.

LISTINGS
—
ACTIVE
—
RELAYS ONLINE
—
CHAIN
—
FULL MARKET→ every seller read directly from the Registry on-chain — pagination, model filters, operator/model search, price sort

PROOF — DON'T TRUST THE PAGE, CLICK THE CHAIN

Historical Escrow v3.1 proof: a full deposit → lock → per-call capture → settle round, executed on Monad testnet against Escrow v3.1 0x157C…71aD5 ↗ — every link below opens the real transaction. The current Escrow v3.2 0xe4D5…514c ↗ adds an opt-in settle delegate — now authorized by both live shared-mode sellers (the TEE relay's signer); see policy.

X-Receipt — EIP-712, signed over lock #1
domain    TokenShare Relay v1 · chainId 10143
paymentId 1  · usage cached 0 · in 24 · out 88
actual    312 units ($0.000312) · model kimi-for-coding
upstream  api.kimi.com · seller 0x38c2…8Dd6
sig       0xd955…1c2c ✓ verified — recovers to the seller address

02MECHANISM

One call, five transitions. Funds move only through the escrow; the relay never touches money and the contract never touches keys.

1

DEPOSIT

deposit()

Buyer funds an escrow balance in USDC. One deposit backs many calls.

2

LOCK

lock(seller, maxAmount, ttl)

Reserves up to maxAmount for one seller and returns a fresh paymentId — default ttl 600s.

3

CALL

isValid(paymentId)

Relay checks the lock on-chain before forwarding. An invalid proof gets a 402 — zero cost, never upstreamed.

4

SETTLE

settle(paymentId, actual)

Usage priced in three tiers; the seller settles actual ≤ max and the difference returns to the buyer.

5

REFUND

refund(paymentId)

No settle before the deadline → anyone releases the lock. The un-captured remainder returns to the buyer.

same flow, raw — cast + relay log
$ cast send $USDC "approve(address,uint256)" $ESCROW 500000
$ cast send $ESCROW "deposit(uint256)" 500000 --rpc $MONAD_RPC
$ cast send $ESCROW "lock(address,uint256,uint256)" $SELLER 50000 600
# relay: Escrow.isValid(paymentId, seller=self, minAmount=est) — false → 402, no forward
# relay: forward to api.moonshot.cn with seller's own official-plan key · usage from response
# pricing: 12000×cached + 26400×in + 2140×out = 45552 units = 0.045552 USDC
$ cast send $ESCROW "settle(uint256,uint256)" $PID 45552 # seller only
# buyer diff 4448 → balances[buyer] · X-Receipt: EIP-712 {paymentId, usage, actual, seller, upstreamHost, model}

03ESCROW STATE MACHINE

Four states, five transitions, no admin path. Hover a state to trace its edges.

deposit() lock(seller, maxAmount, ttl) → paymentId · ttl = 600s settle(paymentId, actual) seller only · actual ≤ maxAmount refund(paymentId) now ≥ deadline · anyone withdraw() · balance out anytime idle DEPOSITED balances[buyer] += amount LOCKED paymentId live · 600s SETTLED actual → seller REFUNDED max → buyer solid = value flow · dashed = exit · all amounts USDC 6-decimals · no admin / no upgrade path
  1. deposit()→ Deposited
  2. lock(seller, maxAmount, ttl=600)→ Locked · emits paymentId
  3. settle(paymentId, actual)→ Settled · seller only · diff → buyer balance
  4. refund(paymentId)→ Refunded · after deadline, anyone can trigger
  5. withdraw()→ idle · unencumbered balance out

04DESIGN CONSTRAINTS

The things the protocol refuses to do are the features.

KEYS OFF-CHAIN

Contracts never see a key, a prompt, or a completion. Single mode: keys live in the seller's own relay. Shared mode (live): sealed inside a platform TEE relay (see policy). The escrow holds USDC — nothing else.

VERIFY, THEN FORWARD

Every request is gated by an on-chain isValid(paymentId) check. Unpaid calls get a 402 and cost the seller nothing. Payment proof comes first, inference second.

OFFICIAL ENDPOINTS ONLY

The relay boots only against the provider's official host allowlist (api.moonshot.cn/.ai, api.openai.com) and rejects models whose prefix doesn't match the host — no lookalike endpoints, no poisoned models. Every receipt records upstreamHost + model.

ONE BYTECODE, NO KEYS

No proxies, no admin keys, no upgrade path. Chain-agnostic by config, delivered on MONAD TESTNET · 10143 with immutable contracts — what you read is what you get.

TEE CUSTODY, PLAIN LIMITS

Shared mode runs one multi-seller relay inside a Phala TDX enclave: seller keys enroll encrypted and stay sealed inside; buyers receive scoped credentials, never the raw key. The Console VERIFY step checks the live relay against a pinned deployment identity — a verifiable boundary, not a blank cheque. Isolation shrinks operator access without erasing it; pin checks are not full hardware quote verification; a signed receipt attests the bill, not what the model answered.