đź—ľ Join us at NERO Chain's Tokyo WebX Side Event! Register now here!

Payment Types

The Paymaster supports three payment types that provide flexibility in how gas fees are handled. Each type offers different benefits and trade-offs.

Type 0: Free Gas (Sponsored)

The developer fully sponsors gas fees for the user. This is ideal for:

  • User onboarding
  • Promotional campaigns
  • Simplifying UX
  • GameFi applications

To use this type, set type: 0 in your context object when calling pm_sponsor_userop.

Type 1: Prepay with ERC20

Users pay for gas with ERC20 tokens before transaction execution:

  1. The full estimated amount is collected upfront during the verification phase
  2. Excess is refunded after execution
  3. Requires token approval before transaction

To use this type:

  • Set type: 1 in your context object
  • Include the token address in your context object
  • Ensure the user has approved the Paymaster contract to spend their tokens

Type 2: Postpay with ERC20

Users pay for gas with ERC20 tokens after transaction execution:

  1. Only the exact gas cost is collected after the transaction completes
  2. Requires token approval before execution
  3. Better UX as users only pay what’s needed
  4. Has a risk of payment failure after execution if the UserOperation depletes tokens

To use this type:

  • Set type: 2 in your context object
  • Include the token address in your context object
  • Ensure the user has approved the Paymaster contract to spend their tokens

Choosing the Right Payment Type

When deciding which payment type to use, consider these factors:

  • Type 0 (Free): Great for new user acquisition, but increases costs for the developer
  • Type 1 (Prepay): More reliable but requires users to have slightly more tokens than needed
  • Type 2 (Postpay): Best user experience but comes with failure risk

Most applications use a combination of payment types - offering free gas for first-time users or specific actions while using token payments for regular operations.