$ |

Prepaid escrow accounts for variable-cost web3 payments over HTTP

problem.md

# The Problem with Fixed Pricing

The exact scheme breaks down when costs are variable

1. AI Inference
Cost depends on token count — unknown before request
2. Data Transfer
Cost depends on response size — unknown before request
3. Streaming & Metering
Cost accrues over time — no fixed price possible
warning: Resource servers either overcharge (bad for users) or undercharge (bad for operators).
flex --explain

# Prepaid Escrow Accounts

Fund once. Pay for what you use.

step 1 :: Discovery

Client requests a resource, receives payment requirements including the facilitator's public key.

step 2 :: Account Creation

Client creates an escrow account governed by a dual-authorization contract. Both client and facilitator must co-sign transfers.

step 3 :: Funding

Client deposits tokens into the escrow account. A single account can hold multiple token types.

step 4 :: Session Key

Client registers a session key for signing payment authorizations. Works with any account type, including smart wallets.

step 5 :: Usage & Holds

Middleware places holds before work begins. Client authorizes via session key. Actual cost is settled after completion.

step 6 :: Settlement

Facilitator batches authorizations on-chain. Pending settlements have a configurable refund window before finalization.

diff exact flex
ASPECT- exact+ flex
Payment timingPer-request, upfrontPost-request, from prepaid balance
Amount knowledgeMust know before requestDetermined after request
On-chain transactionsOne per requestBatched settlements
Client complexityBuild and sign transactionsFund account once, authenticate requests
Use casesFixed-price APIsMetered usage, streaming, variable pricing
flex --security

[ok] Dual authorization — both client and facilitator must co-sign

[ok] Session keys — no private key exposure per request

[ok] Replay protection — monotonically increasing nonces

[ok] Refund window — time to cancel erroneous charges

[ok] Deadman switch — client recovers funds if facilitator goes offline

All checks passed. ✓

$ flex --participants

Client

Makes requests and pays for resources

Middleware

Gates access, generates payment requirements, receives payment

Facilitator

Validates payments, settles on-chain, co-signs escrow transfers

$ Ready to get started?