Get User Fee Token
fee.getUserToken
Gets an account's default fee token.
Returns null when the account has no fee token preference set.
Usage
import { } from './viem.config'
const = await ..()
.('Fee token:', )
Fee token: { address: '0x20c0000000000000000000000000000000000001', id: 1n }import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Recipes
Show the Gas Token in Wallet Settings
Use the null return to fall back to pathUSD when rendering fee settings for an account that has not chosen a token.
import { } from './viem.config'
const = '0x20c0000000000000000000000000000000000000'
const = await ..()
const = ??
.('Gas is paid in:', )
Gas is paid in: 0x20c0000000000000000000000000000000000000import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Audit Preferences Across Payout Accounts
Pass account to read the preference of any account, such as payout or treasury accounts a backend operates alongside the Client's own.
import { } from './viem.config'
const = [
'0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
'0x8ba1f109551bD432803012645Ac136ddd64DBA72',
] as
for (const of ) {
const = await ..({ })
.(, )
}import { , } from 'viem/tempo'
export const = .({
: .('0x...'),
})Return Value
type ReturnType = {
/** Fee token contract address. */
address: Address
/** Fee token id. */
id: bigint
} | nullThe account's fee token address and id, or null if unset.
Parameters
account
- Type:
Account | Address - Default:
client.account
Account to read the fee token of. Defaults to the Client's account.
blockNumber (optional)
- Type:
bigint
Block number to read the state from.
blockOverrides (optional)
- Type:
BlockOverrides
Block overrides to apply to the state.
blockTag (optional)
- Type:
BlockTag
Block tag to read the state from.
stateOverride (optional)
- Type:
StateOverride
State override to apply.