Allow users to pay gas with erc20
Enabling users to pay gas fees with ERC-20 tokens enhances the user experience by removing the need to hold native tokens like ETH. This is especially useful for onboarding users who primarily hold stable coins or other ERC-20 assets.
Steps
1. Import required dependencies
2. Setup Wallet Client
Quickly get started by creating a wallet client using createWalletClient
from viem
with local account for your specified network.
3. Create Smart Wallet Client
To initialize a Smart Wallet Client, you can use the createGelatoSmartWalletClient
method.
Use wallet: 'kernel'
when creating the Smart Wallet client to ensure ERC-4337 compatibility.
A Smart Wallet Client serves as an alternative to the standard viem
walletClient, but is purpose-built for managing EOA's as smart wallets instead of traditional EOA (Externally Owned Accounts).
4. Sending transactions
5. Batch multiple transactions
You can batch multiple transactions to be sent on-chain at once by adding them to the calls
array.
Last updated