Skip to main content
Ace Data Cloud X402 currently uses two types of schemes: exact and upto. They address different billing issues.

exact

exact means that the price can be determined before the request reaches the target API. The amount signed by the client is the final deduction amount. Suitable for:
  • Fixed price image generation;
  • Fixed price video task creation;
  • Fixed price search or tool APIs;
  • Order payments.
EVM exact uses USDC EIP-3009 TransferWithAuthorization:
The facilitator verifies the signature and amount in the /verify stage and submits this authorization on-chain in the /settle stage.

upto

upto means the client authorizes a maximum limit, and Ace Data Cloud settles based on actual usage after the request is completed, with the actual deduction not exceeding the limit. Suitable for:
  • Chat completion: The final price depends on prompt tokens and completion tokens;
  • Streaming responses: The true output length is only known after it ends;
  • Future post-measurement APIs.
upto uses Permit2 PermitWitnessTransferFrom. The amount signed by the client is not a fixed transfer but a limit authorization with a witness:
permitted.amount is the limit and not necessarily the final deduction. The gateway will convert the actual usage into amount and pass it to the facilitator in the /record stage. The facilitator is only allowed to settle amount <= permitted.amount. Base upto program execution result:
Explanation:
  • The authorization limit returned in 402 is 95215 atomic USDC, and the client signs based on this limit.
  • After the model’s actual response, only 3 atomic USDC is settled, and the on-chain transaction can be checked on BaseScan.
  • This result illustrates the key difference of upto: the signed amount is a limit, and the on-chain settlement can be less than the limit.
  • If the actual usage exceeds the limit, the facilitator should reject the settlement, and the client needs to reauthorize with a higher limit.
upto is currently only available on Base. SKALE only offers exact, so if you need post-measurement, please use Base.

Why Permit2 Approve is Needed

upto is ultimately pulled from the payment wallet through Permit2 by the x402 proxy. Before the first use, the payment wallet needs to give Permit2 an ERC-20 allowance. Python CLI:
Programmatic way:
After authorization is complete, each request still requires signing a new upto envelope, as nonce, deadline, witness, and limit amount are all different.

Zero Amount Settlement

upto supports cases where the actual amount is 0. For example, if the target API does not successfully generate billable usage, the gateway can pass in amount = "0". The facilitator will return success but will not issue an on-chain transaction. This can avoid the issue of “request not successful but still incurring on-chain fees.”

Selection Recommendations

If you are unsure which to choose, use the SDK’s default behavior; the SDK will select the payment requirement matching the network returned by the server.

Base upto Checklist

When integrating or troubleshooting, please ensure the following parameters come from the same 402 response and remain consistent during client signing: Common errors and handling methods: