Account Abstraction Paymaster: Pay EVM Gas Fees with USDT, USDC, or Any Other ERC-20 Token
In the world of decentralized applications (dApps), gas fees have long been a barrier to onboarding. Paying transaction fees on EVM networks requires its native currency. This poses a significant hurdle for newcomers who might not be familiar with cryptocurrencies.
To make your app accessible to all users, there must be a solution to paying these fees: one that doesn’t require extensive cryptocurrency experience.
Introducing the ERC-20 Paymaster—our new feature for thirdweb Connect, allowing users to pay for gas fees using stablecoins like USDT, USDC and other ERC-20 tokens. With this simple integration, developers can offer users an easier, more familiar way to interact with their dApps.
But before we dive into that, what is a paymaster exactly?
What is a Paymaster?
A Paymaster is a tool designed to streamline the gas fee payment process for users of decentralized applications. It acts as an intermediary between the user and the blockchain, enabling developers to pay gas fees for users.
In short, paymasters allow you to customize the user experience when it comes to gas fees, either through sponsoring transactions or adding functionality to accept alternative currencies.
What is an ERC-20 Token Paymaster?
The ERC-20 Paymaster uses account abstraction framework to let users pay for gas fees in any ERC-20 token rather than the native blockchain asset such as ETH. With this integration, developers no longer need to worry about complex workarounds to manage gas fees or sponsor them directly. Instead, users can pay with tokens they already hold, such as USDT, USDC, or even project-specific currencies.
This makes interaction process seamless for everyday users, who may not be familiar with the nuances of different tokens and chains.
Paying gas fees with ERC-20 tokens: the use cases
As decentralized applications become more mainstream, the need to simplify and streamline user onboarding becomes crucial. By allowing users to pay gas fees in stablecoins or other widely-used ERC-20 tokens, developers are lowering the barrier to entry for users who are already familiar with those tokens.
This is especially important in use cases like:
Play-to-earn games
The ERC-20 paymaster removes the need to convert tokens and removes the barrier to onboarding. This is particularly useful for developing web3 games, since players don’t need to hold volatile native tokens or grapple with onramping.
NFT marketplaces
The erc-20 paymaster is also useful for building seamless NFT marketplaces or other consumer apps. Simply, it facilitates smoother transactions for users who prefer to transact in stablecoins—making onboarding easy.
Lending and yield farming platforms
The ERC-20 paymaster also facilitates DeFi platform development, allowing builders to create powerful experiences that scale. Users holding protocol-specific tokens can engage without worrying about native chain gas fees, opening up the market to new users.
By eliminating the need to hold the native gas token, the ERC-20 Paymaster simplifies cross-chain interactions, allowing users to easily pay for one-off transactions on other chains without interrupting their user experience.
How Does a Paymaster Work?
The ERC-20 Paymaster integrates with the TypeScript SDK to allow developers to specify the payment method for transaction fees. Here are its most important features:
Integration Simplicity
Developers simply need to enable the feature in the SDK by adding a single line of code. This means there's no need to deploy or manage your own Paymaster infrastructure, making it an incredibly efficient solution.
Payment Flexibility
When a user initiates a transaction, the Paymaster automatically calculates the required gas fees and processes the payment in the selected ERC-20 token, instead of the native cryptocurrency of the network.
Third-Party Sponsorship
Developers or third-party services can sponsor gas fees, further streamlining the process for users. This removes the need for users to manage multiple tokens or wallets when interacting with dApps.
How to Enable ERC-20 Gas Payments with thirdweb’s Paymaster
Enabling ERC-20 token payments for gas fees with thirdweb Connect is simple.
- Install Connect SDK
npm install thirdweb
- Configure the Paymaster In your SDK code, specify the ERC-20 token you wish to use for gas fees. Currently you may use Lisk LSK, Base USDC or Celo CUSD.
import { base, lisk, celo } from "thirdweb/chains";
import { TokenPaymaster, smartWallet } from "thirdweb/wallets";
// Have users pay for gas in Base USDC
const usdcWallet = smartWallet({
chain: base,
sponsorGas: true,
overrides: {
tokenPaymaster: TokenPaymaster.BASE_USDC,
},
});
// Have users pay for gas in Lisk LSK
const lskWallet = smartWallet({
chain: lisk,
sponsorGas: true,
overrides: {
tokenPaymaster: TokenPaymaster.LISK_LSK,
},
});
// Have users pay for gas in Celo CUSD
const cusdWallet = smartWallet({
chain: celo,
sponsorGas: true,
overrides: {
tokenPaymaster: TokenPaymaster.CELO_CUSD,
},
});
For a detailed guide on implementation, check out the official documentation.
Advantages of the ERC-20 Paymaster
The ERC-20 Paymaster is an easy-to-use, managed solution that requires no infrastructure or smart contract deployment on the part of the developer. Here are some of its key advantages:
No Infrastructure Setup
Developers don’t need to worry about setting up or maintaining Paymaster contracts.
Simple Integration
With a single line of code, you can enable users to pay with ERC-20 tokens.
Increased User Accessibility
Lowering the barrier for new users with familiar stablecoins such as USDC and USDT improves overall user adoption.
Enhanced Onboarding
New users don’t have to deal with volatile gas tokens, making onboarding far simpler.
The ERC-20 Paymaster: Empowering Developers and Users
The ERC-20 Paymaster is an innovative solution to one of the most persistent challenges in blockchain: high and volatile gas fees. By allowing users to pay transaction fees with stablecoins or any ERC-20 token, developers can offer a much smoother and more accessible user experience.
This feature simplifies complex blockchain interactions, eliminates the need for users to manage multiple tokens, and ultimately enables dApps to onboard users with greater ease and less friction. As the blockchain ecosystem grows, features like the ERC-20 Paymaster are key to ensuring that decentralized applications are accessible, efficient, and ready for mass adoption.
For developers looking to simplify user experience and increase adoption, integrating the ERC-20 Paymaster is an essential step forward.