Fee Options
The content provides detailed information on implementing Fee Options for gas fees when sending transactions using an Embedded Wallet with the Sequence stack.
When implementing an Embedded Wallet, one will need to be able to pay for the gas fees on a non-testnet network to send a transaction.
Fee options provide a quote to cover the gas fees only useable for a certain period of time (which is unique to the Sequence stack).
To send a transaction successfully, you have a few directions you can take:
- Testnets: Using a testnet, transactions with Sequence are free, not requiring a fee option inputted into the SDK call.
- Sponsored Contract or Wallet: Having the smart contract or wallet sponsored, not requiring a fee option inputted into the SDK call. You can learn about sponsoring a contract or wallet here.
- Fee Options: Using a Sequence API to get a custom fee quote and fee options object, pass both into the waas sdk call. See below.
You will know if you need to either sponsor your contract or wallet, or, implement fee options if you receive the following response from the WaaS API:
Implementing Fee Options
Before implementing the following “Fee Options” flow, you will need to ensure that your wallet has sufficienct funds to pay for your transaction on the specific network in the native currency.
You can either transfer tokens to your wallet, or, use the on-ramp feature using the Sequence Kit solution.
And ensure that the following packages are installed:
Generalized API for Fee Options & Fee Quote
To implement fee options passed into the request, a first call to sequence.feeOptions({...})
is required, which is wrapped in the following function checkTransactionFeeOptions
:
In the following examples, the sequence
variable is an Embbeded Wallet object intialized from the @0xsequence/waas
npm package with the WaasConfigKey
and ProjectAccessKey
. Learn how to do this here
Crafting Fee Options & Fee Quote with Transaction
Implementing an ERC20 Transaction
Implementing an ERC1155 / ERC721 Transaction
For ERC721 just replace erc1155({...})
with erc721({...})
and call sequence.sendERC721({...})
Implementing an Native Currency Transaction
Implementing a Custom Contract Transaction
Was this page helpful?