
In the Ethereum blockchain one of the major hurdles that decentralized finance applications developers and owners face is paying the gas fee in the base asset i.e. ETH and setting up a gas station which allows to transfer of some base gas assets to the customer wallet so that customer can proceed with the payment. But this makes the user experience very poor and slow since the customer has to wait for the gas fee to be added or the transaction is not completed due to insufficient fee. To tackle this problem ERC 4337 was created which has a unique feature called paymaster (specifically deposit paymaster) and one of the uses of paymaster is to allow users to pay the gas fee in ERC20 tokens.
Pay gas fee in ERC-20 tokens | Leveraging Paymasters
Gas fee payments using an ERC-20 token are made easier with the deposit paymaster. The ERC-20 token is selected by the developer of the contract, and they also specify which wallet addresses for smart contracts are eligible/whitelisted for sponsored user operations and all the transactions takes place accordingly. For example, a web3 dApp that wants to pay for its first 1,000 customers’ transactions could use its own ERC-20 token.
Although fee sponsorship using ERC-20 tokens is permitted by the deposit paymaster, the real transaction costs are settled in ETH and subtracted from the paymaster’s deposited reserve amount (which is in ETH) in the entry point contract. To guarantee that the quantity of ETH needed to pay the fees is equal, there is a function: postOp() which is available and it includes logic to withdraw the corresponding number of ERC-20 tokens from the sender, as established by an oracle’s quoted price.
Paying in ERC20 tokens is just one of the function of paymaster, there are several other functions too which will be covered in our subsequent blogs. Below is the illustration which depicts how do a paymaster work in real time.
How paymaster transaction flow works
In the subsequent blog we will be covering a series of ERC-4337 along with paymasters, which will also cover the development perspective with code snippets to help any developers which are developing gas stations for their DeFi applications. For any queries regarding paymasters, gas station, ERC-4337 or blockchain development in general, you can contact us at info@simplileap.com and our blockchain experts will be happy to help you.

Co-Founder Simplileap
Passionate Full Stack Developer with an unwavering enthusiasm for technology and a relentless drive for continuous learning with more than 10 years of experience in Web Development, SEO and Software Development. Committed to pushing boundaries, I thrive in dynamic environments where I can leverage my expertise in front-end and back-end development to create innovative solutions. With a strong foundation in various programming languages and frameworks, I am dedicated to staying updated with the latest industry trends and incorporating them into my work.