What is Paymaster?
The main entity of the ERC-4337
A paymaster is an entity that pays the gas fee for the transaction(TX) when using account abstract(AA). It is triggered and used by the entrypoint, user, or the manager of the contract. As part of an AA system, it enables the operation of a smart contract wallet (SCW) even if the wallet has no remaining Ether (ETH).
The paymaster allows users to benefit from gas fee discounts, pay fees with alternative tokens such as ERC-20 Token, or utilize other gas fee handling mechanisms that the paymaster supports. If you're new to ERC-4337 or AA wallets, we recommend reading an introduction to better understand the concepts.
Pay the gas fee? How?
The paymaster covers the gas fees for TXs operating a user’s SCW by sending ETH directly to the transaction executor, referred to as the 'bundler,' as reimbursement. The paymaster transfers the required ETH for the user operation (referred to as userOp
) through the EntryPoint
contract, which manages the gas fee repayments.
To enable this, the paymaster must deposit ETH into the EntryPoint
contract, as it is the sole entity authorized to reimburse gas fees on behalf of users. Two functions manage the adjustment of the Paymaster’s balance. One function deducts the user’s deposit in advance, while the other settles the gas fee after the userOp
is executed on-chain, either by further deducting from the user’s deposit or refunding gas fees to the user.
While the sender of the userOp
is responsible for paying their deposited ETH to the bundler for transaction execution, using the paymaster allows the gas fees to be abstracted away from the user.
How paymaster exactly works?
The paymaster operates through interaction with the EntryPoint
contract, a singleton contract initially deployed by the Ethereum Foundation. The EntryPoint
serves as the main hub for transmitting userOp
data—a struct containing the user's signed transaction, which the bundler submits as a TX. The bundler acts as an intermediary, executing the user's transaction on their behalf.
During the validation and execution of the call to the user's SCW, the EntryPoint
interacts with the paymaster to reimburse the bundler for the gas used. It calculates the exact gas fee consumed during the transaction to ensure proper compensation.
Last updated