How billing works
- For both
mode: "sponsor"andmode: "token", usage deducts from the developer’s USD gas credit. - In
mode: "token", token deductions are transferred to the configured paymaster treasury wallet as compensation. constantFeeis an extra token fee charged from the end user per transaction/userOp.
Dashboard-managed paymaster config (new flow)
Paymaster v2 now reads token-mode policy from your paymaster config (validated by validation-service), not from per-request context fields. Configure these in dashboard create/update paymaster:isERC20isSponsoredtreasuryWalletAddress(required whenisERC20=true)constantFee(required whenisERC20=true,0..10)validUntilMinutesrestrictionType:NONE | ALLOWLIST | BLOCKLISTrestrictedWallets(used for allowlist/blocklist checks)
Step 1: Create a Paymaster client (v2)
Use the API key you copied from the dashboard.Step 2: Call sendUserOperation (paymaster + paymasterContext)
sendUserOperation is where you pass:
paymaster: paymasterClientpaymasterContext(controls how v2 pays fees)
Step 3: Sponsor mode (native gas sponsorship)
Usemode: "sponsor" when you want the paymaster to sponsor gas using the native gas flow.
Step 4: ERC20 (token) mode
Usemode: "token" when you want fees paid in an ERC20 token.
Required paymasterContext fields
For mode: "token", you must provide:
tokenAddress: ERC20 contract address used for fee payment
treasury and constantFee are sourced from paymaster config in the dashboard (via validation-service). Do not send these in request context.
paymasterContext field definitions (focused)
mode
Defines how gas is paid:
"sponsor": native gas sponsorship by paymaster"token": ERC20 token is deducted as fee payment
tokenAddress (required in mode: "token")
The ERC-20 token address to use for payment.
treasury (dashboard-configured)
The receiver wallet for deducted ERC20 fees (compensation wallet).
constantFee (dashboard-configured)
Additional token amount charged per transaction / userOp.
Example paymasterContext (token mode)
ERC20 approval: what you must do
In ERC20 token mode, the paymaster deducts fees during the same UserOperation (post-op). That deduction requires the sender to have ERC20 allowance for the paymaster contract. So you must add anapprove(...) call into calls before your real action call.
Minimal pattern:
Notes you must know
PAYMASTER_ADDRESSmust be the Paymaster contract address used by your backend for the chain you are using.- If token-mode configuration is missing in dashboard (
isERC20,treasuryWalletAddress,constantFee), v2 will reject the request.