Last updated
Was this helpful?
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.
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.
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
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?
Was this helpful?
function credits(address user) external view returns (uint256);
function consumeCredit(address user) external;
