Skip to main content
Fee selection is only necessary if you aren’t already using Sequence Builder’s gas sponsorship capabilities! Create your project in Sequence Builder for ease of development today!
import { Session } from '@0xsequence/auth'
import { ethers } from 'ethers'

const config = {
  mnemonic: 'YOUR MNEMONIC',
  projectAccessKey: 'YOUR PROJECT ACCESS KEY',
  chainId: ChainId.YOUR_CHAIN_ID // e.g. ChainId.MAINNET, ChainId.POLYGON, etc.
}

const signer = ethers.Wallet.fromMnemonic(config.mnemonic)

const session = await Session.singleSigner({ signer, projectAccessKey: config.projectAccessKey })

const account = session.account.getSigner(config.chainId, {
  async selectFee(_transactions, options) {
    // This callback is called with the list of candidate fee options.

    console.log('Fee options:', JSON.stringify(options, undefined, 2))

    // Select the USDC fee option.
    return options.find(option => option.token.symbol === 'USDC')
  }
})
I