Paymaster Explained in Detail
A paymaster decides whether it will pay gas for a UserOperation. It can sponsor users directly, require an off-chain signature, charge ERC20 tokens, or enforce application-specific rules.
The paymaster must deposit funds into the EntryPoint contract and validate operations before it is charged.
Smart contract example
function validatePaymasterUserOp(
UserOperation calldata userOp,
bytes32 userOpHash,
uint256 maxCost
) external returns (bytes memory context, uint256 validationData);
This function decides whether the paymaster accepts the gas liability.
Paymaster in Auditing
Paymasters are easy to drain if validation is too broad. They are also exposed to replay, bad token pricing, failed execution, and gas griefing.
Auditors check that the paymaster sponsors only the intended user, operation, time window, and cost.
Red flags in code
-
Missing
msg.sender == EntryPointcheck. -
Paymaster signatures do not bind the full operation hash.
-
Token payment logic ignores fee-on-transfer tokens or non-standard returns.
-
postOpcan be reentered or forced into expensive failure paths. -
Deposit and withdrawal controls are weak.
How to test or review it
-
Replay paymaster approvals with changed calldata, nonce, user, or chain.
-
Force the target call to revert and inspect
postOpbehavior. -
Test depleted deposits and withdrawal permissions.
-
Use non-standard ERC20 behavior if the paymaster charges tokens.
-
Call validation functions directly from non-EntryPoint addresses and expect rejection.
Keep learning this topic
ERC-4337
ERC-4337 is an Ethereum account abstraction standard that uses UserOperations, bundlers, paymasters, and an EntryPoint contract without changing Ethereum consensus.
UserOperation
A UserOperation is the ERC-4337 data structure that describes a smart account action, including sender, nonce, calldata, gas fields, optional paymaster data, and signature.
EntryPoint Contract
The EntryPoint contract is the ERC-4337 contract that validates and executes bundles of UserOperations and manages account and paymaster deposits.
Practice this in real audit scenarios
Definitions help, but auditors need reps. SCH turns concepts like Paymaster into exploit labs, code review habits, and report-writing practice.
Start the free trial or see the full smart contract auditing course.