For the complete documentation index, see llms.txt. This page is also available as Markdown.

Credit System

Credits are managed by the ZDriveXCreditsV2 smart contract on Base, deployed as a UUPS upgradeable proxy. You purchase credits by sending USDC to the contract. Each successful inference call consumes one credit, deducted asynchronously after the response is streamed.

Credits do not expire. They are stored on-chain and readable by anyone via the contract's public credits(address) function.

Credit flow

RPC resilience

The worker reads balances via a viem fallback transport across multiple Base RPC providers to avoid single-provider outages. If all providers fail during a credit check, the request returns 503 — the worker fails closed rather than serving inference to a user whose balance cannot be verified.

consumeCredit behaviour

Credit deduction happens after a successful inference response, not before. This means:

  • Failed or errored inference calls do not cost credits

  • If consumeCredit() fails transiently, the worker retries automatically before giving up

Contract interface

Only the operator address (the CF Worker's signing key) can call consumeCredit. The credits view function is public and can be queried by anyone to verify a user's balance.

Last updated

Was this helpful?