ERC-20 Paymaster FAQs
A Paymaster is a special smart contract under the ERC-4337 (opens in a new tab) specification that User Operations are able to delegate the responsibility of gas fee payments to. This means that ERC-4337 smart contract wallets no longer need to necessarily be responsible for directly paying gas fees in ETH. The paymaster contracts are able to use custom logic (with certain limitations) to decide whether or not they are willing to sponsor a UserOperation.
An ERC20 Paymaster is a specific type of paymaster that is willing to sponsor the gas fees for a UserOperation if and only if the smart contract wallet pays the paymaster for it in an ERC20 token like USDC, DAI, etc. In effect, this allows smart contract wallets to pay for gas fees purely in ERC20 tokens and means, if designed correctly, they never need to hold any native tokens like ETH.
Check out our tutorial! We wrote a tutorial that takes you through the whole flow of deploying a SimpleWallet and sending your first UserOperation sponsored with USDC.
While the specifics can vary depending on the specific ERC20 token and chain you're using, the general steps are as follows:
You can do this either by:
- going to our ERC20 Paymaster Contracts reference page or
- using our ERC20 Paymaster SDK. For the SDK, you can use the
getERC20Paymasterfunction, specifying an ethers.js provider and the symbol of the token you wish to use, and the SDK will deterministically calculate the ERC20 Paymaster address.
approve function on the ERC20 token you wish to use, specifying the corresponding ERC20 paymaster as the contract you are approving the tokens to.
After doing this, if you are using our Typescript SDK you can call
ERC20Paymaster.verifyTokenApproval with a UserOperation to make sure you have approved enough ERC20 tokens to the paymaster to make sure the UserOperation will succeed on-chain.
paymasterAndData for the ERC20 Paymaster can look in one of two ways.
You can either make the
paymasterAndData simply the ERC20 Paymaster address. In this case, there is no restriction (beyond the token approval limit you set in the previous step) on how much you allow the ERC20 Paymaster to take. In this case, the
paymasterAndData would be 20 bytes long.
Alternatively, you can make the
paymasterAndData a concatenation of the ERC20 Paymaster Address, as well as a
uint256 value that represents the maximum amount of ERC20 tokens you allow the paymaster to take. This can protect against unexpected price movements in between the time you submit the UserOperation and between the time it gets included, and serves a similar purpose as the
amountInMax parameters found in Uniswap's periphery contracts (opens in a new tab). If you specify the maximum ERC20 token amount, the
paymasterAndData should be 56 bytes (20 for the address + 32 for the uint256) long.
If you are using our ERC20 Paymaster SDK, you can call the
ERC20Paymaster.generatePaymasterAndData function documented here that will automatically generate the required
paymasterAndData, including a reasonable maximum ERC20 spend limit.
Do any final touches to your UserOperation, such as signing, then submit the UserOperation to a bundler like ours and watch it be included on-chain!
Check out our Getting Started with the ERC20 Paymaster guide that walks you through deploying your SimpleWallet and getting your first UserOperation sponsored with USDC.
The currently supported tokens are listed here.
Theoretically, we can support any token on any EVM chains that have Chainlink support. If you have a token that you would like supported, please reach out to us (opens in a new tab)!
You can find the contract source code here (opens in a new tab).
No, we do not. The contracts we deploy can never be upgraded. However there are two variables that can be changed by the owner: the
priceMarkup and the
However, an audit does not guarantee complete security. Please use the paymaster at your own risk.
Yes! We have a Typescript SDK under
@pimlico/erc20-paymaster that you can use to make ERC20 Paymaster interaction easier. Check out the documentation here.
Yes. You do not need to go through our backend API to interact with the ERC20 Paymaster.
Currently, no. There is an owner in the ERC20 Paymaster contract that can update the
priceUpdateThreshold, as well as to withdraw the ERC20 tokens accumulated by the paymaster.
The owner of the ERC20 Paymaster has limited admin control. They can withdraw accumulated ERC20 tokens from the contract for the purpose of swapping them back into native tokens and depositing them back into the paymaster. Additionally, the owner can update the
priceUpdateThreshold configurations within predefined limits to manage operational costs and risks.
Please get in touch with us. We will do what we can to see if we can add support for the token you are interested in.
A non-permissionless paymaster could potentially offer a slightly smoother user experience as it could handle token approvals during the execution phase of the UserOperation. However, this would require interaction with a hosted API, which could introduce potential points of failure or trust. By contrast, Pimlico's permissionless design avoids these potential issues but requires users to manually handle token approvals.
However, it is possible to bypass this extra step for smart contract wallets if they are able to make an approve call either during the deployment of the smart contract, or during the validation step of the UserOperation.
Yes, Pimlico takes a fee in the form of a
priceMarkup on the ERC20 token price. This markup serves to compensate us for maintaining the infrastructure and covering risks associated with price fluctuations and slippage risk. The default
priceMarkup we take is 10%, but that can depend on on the token, so double-check before using the paymaster.
priceMarkup can be changed by the owner of the paymaster, however there is a hardcoded maximum of 20% that is enforced by the smart contract. This means we can never set the
priceMarkup to more than 20%.