This guide covers end-to-end Paymaster v2 integration for gas sponsorship (users pay nothing) and token-fee mode (users pay in ERC-20). Related pages in this section:

How billing works

  • For both mode: "sponsor" and mode: "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.
  • constantFee is 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:
  • isERC20
  • isSponsored
  • treasuryWalletAddress (required when isERC20=true)
  • constantFee (required when isERC20=true, 0..10)
  • validUntilMinutes
  • restrictionType: NONE | ALLOWLIST | BLOCKLIST
  • restrictedWallets (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: paymasterClient
  • paymasterContext (controls how v2 pays fees)

Step 3: Sponsor mode (native gas sponsorship)

Use mode: "sponsor" when you want the paymaster to sponsor gas using the native gas flow.

Step 4: ERC20 (token) mode

Use mode: "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 an approve(...) call into calls before your real action call. Minimal pattern:

Notes you must know

  1. PAYMASTER_ADDRESS must be the Paymaster contract address used by your backend for the chain you are using.
  2. If token-mode configuration is missing in dashboard (isERC20, treasuryWalletAddress, constantFee), v2 will reject the request.