zen master illustration

As a builder of web3 app , you can build a paymaster to sponsor gas on behalf on your users to help drive broader adoption You can choose to sponsor a certain number of UserOperations per user or provide gas for a limited-time -just enough time to let newcomers explore your app and get onboarded smoothly.
The goal is to simplify the onboarding process for less experienced or new web3 ethusiasts by abstracting away the complexity of gas fees.
It is really up to you to define your sponsorship schemes.

Workflow for a basic paymaster :

1- User Operation Creation.
A user creates a UserOperation, which includes details of the transaction they want to execute on their smart account. The UserOperation includes the paymaster’s address and any paymaster-specific data.

2 - Bundler Submission. The UserOperation is submitted to a bundler, which batches multiple operations and sends them to the EntryPoint contract.

3 - EntryPoint Processing. The EntryPoint contract receives the batch of UserOperations and processes each one.

4 - Paymaster Validation.
For each UserOperation, the EntryPoint calls the validatePaymasterUserOp function on your paymaster contract. Your paymaster decides whether to sponsor the transaction based on your custom logic. If approved, your paymaster returns a context and validationData.

5 - Smart Account Validation:
The EntryPoint then calls validateUserOp on the smart account to verify the operation’s validity.

6 - Execution:
If all validations pass, the EntryPoint executes the UserOperation on the smart account.

7 - Post-Operation:
After execution, the EntryPoint calls the postOp function on your paymaster. Your paymaster can perform any necessary post-execution logic, such as updating balances or recording transaction details.

Additional Features: Implement any additional features specific to your paymaster, such as :

  • Deposit management
  • Whitelisting user or contracts
  • Integration with your app’s business logic custom
  • Token handling if you are using tokens for gas payments.

Deployment:

1- Deploy paymaster.
2- Fund it with ETH for gas payments.
3- Configure your smart account or app to use this paymaster’s address in UserOperations.

BasePaymaster.sol provides a solid foundation for creating a paymaster. However, it’s important to understand that while it offers a versatile structure, it’s not meant to be used directly without modifications. BasePaymaster is an abstract contract, meaning it provides a framework but requires you to implement some key functions.