Pay Gas in ERC20
Learn how to pay gas in ERC20 using Web SDK
Setup Web SDK
Make sure you completed the Getting Started guide.
Basic unsponsored transaction, paying with ETH
Next, we’ll create a simple page that allows users to send an unsponsored transaction using their smart wallet’s native currency, nothing special here.
Let's pay the gas with an ERC20 token
We’ll use the useWaasFeeOptions
hook to allow users to pay gas in ERC20.
Behind the scenes, the WaaS connector intercepts this transaction request and triggers the fee confirmation flow.
Now that we declared the useWaasFeeOptions
hook, it has set up an effect that overrides the default feeConfirmationHandler
of the WaaS provider adding the possibility to pay with ERC20 tokens.
In this example we default to the first option, in the next step we’ll add a UI to allow users to choose the fee token they want to pay with.
Add a fee token selector (UI)
Next, we’ll add a fee token selector to allow users to choose the fee token they want to pay with.
Each fee option also contains a boolean property called hasEnoughBalanceForFee
that you can use to inform the user if they have enough balance to pay for the fee as well as a balance
property that contains the balance of the token.
Congratulations! You’ve just learned how to pay gas in ERC20 using Sequence Kit.
Was this page helpful?