ERC-20 Paymaster Architecture
Design
Pimlico's ERC-20 Paymaster is an ERC-4337 Paymaster that relies on an offchain API, powered by Pimlico, to supply the user with an up-to-date token price, alongside a signature from a valid signer address. The paymaster is able to pay for the gas fees of your users in exchange for ERC-20 tokens that are drawn from the user.
Estimating the amount of tokens required for a user operation
After calling the pimlico_getTokenQuotes
function, the Pimlico API will return two important values, exchangeRate
and postOpGas
. You can use these two values, alongside information about the user operation you're looking to sponsor, to get an estimate of the amount of tokens required for the user operation.
You can do this by using this onchain function on the paymaster.