Was this helpful?
Enable users to pay transaction fees using your stablecoin. Tempo supports flexible fee payment options, allowing users to pay fees in any stablecoin they hold.
When users pay transaction fees with your stablecoin, Tempo's fee system automatically handles the conversion if validators prefer a different token. The Fee AMM ensures seamless fee payments across all supported stablecoins.
Users can select your stablecoin as their fee token through:
Learn more about how users pay fees in different stablecoins and the complete fee token preference hierarchy.
Regularly check your token's fee pool reserves to ensure users can consistently pay fees with your stablecoin. Low liquidity can prevent transactions from being processed.
Keep sufficient validator token reserves in your fee pool to handle expected transaction volume. Consider your user base size and typical transaction frequency when determining reserve levels.
As fees accrue in your token, the pool will run low on validator tokens and need to be rebalanced. Use rebalanceSwap to replenish validator token reserves when they become depleted.
Before promoting fee payments with your token, thoroughly test the flow on testnet:
First, create and mint your stablecoin by following the Create a Stablecoin guide.
Before users can pay fees with your token, you need to provide liquidity in the Fee AMM between your token and a liquid quote token, or directly against validator payout tokens where you want explicit direct-route coverage.
To determine which validator tokens are needed, sample recent blocks and check the miner's preferred fee token using getValidatorToken on the FeeManager contract. For example, on Moderato testnet, validators accept fees in pathUSD and AlphaUSD. On mainnet, this token mix is different and subject to change.
Add liquidity to your token's fee pool:
import { } from 'wagmi/tempo'
import { } from 'viem'
import { } from 'wagmi'
const { } = ()
const = '0x...' // Your issued token address
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD on testnet
const = ..()
// Add 100 AlphaUSD of liquidity to the fee pool
.({
: ,
: ,
: ,
: ,
: ('100', 6),
}) IFeeAMM feeAmm = IFeeAMM(TIP_FEE_AMM_ADDRESS);
address yourToken = 0x20c0000000000000000000000000000000000004; // Your issued token
address validatorToken = 0x20c0000000000000000000000000000000000001; // AlphaUSD
// Add 100 AlphaUSD of liquidity to the fee pool
feeAmm.mint(
yourToken,
validatorToken,
100_000_000,
You can also check your token's fee pool liquidity at any time:
If the pool has no liquidity (reserveValidatorToken == 0), you'll need to add liquidity to the fee pool before users can pay fees with your token. See the Create a Stablecoin guide for instructions on minting fee AMM liquidity.
import { } from 'wagmi/tempo'
const { : } = ..({
: yourToken,
: '0x20c0000000000000000000000000000000000001', // AlphaUSD on testnet
})
const = && . > 0nIFeeAMM feeAmm = IFeeAMM(TIP_FEE_AMM_ADDRESS);
address yourToken = 0x20c0000000000000000000000000000000000004; // Your issued token
address validatorToken = 0x20c0000000000000000000000000000000000001; // AlphaUSD
// Get pool reserves
(uint256 reserveValidator, uint256 reserveUser) = feeAmm.getReserves
import React from 'react'
import { } from 'wagmi/tempo'
import { } from 'wagmi'
import { , , , } from 'viem'
export function () {
const { } = ()
const [, ] = React.<string>('')
const [, ] = React.<string>('')
const = '0x...' // Your issued token address
const = '0x20c0000000000000000000000000000000000001' // AlphaUSD
const { : , : } =
..({
: ,
: ,
})
const { : , : } =
..({
: ,
: ,
})
const = ..({
: {
() {
()
()
},
},
})
const = && ()
const = () => {
if (!) return
.({
: ('100', 6),
: as `0x${string}`,
: ,
: ? ((), { : 32 })
, // Pay fees with your issued token
})
}
return (
<>
<>
<>Recipient address</>
<
="text"
={}
={() => (..)}
="0x..."
/>
</>
<>
<>Memo (optional)</>
<
="text"
={}
={() => (..)}
="INV-12345"
/>
</>
<
={! || ! || .
={}
="button"
>
{. ? 'Sending...' : 'Send'}
</>
</>
)
}import { , } from 'wagmi'
import { }
ITIP20 token = ITIP20(0x20c0000000000000000000000000000000000001); // AlphaUSD
address yourToken = 0x20c0000000000000000000000000000000000004; // Your issued stablecoin
address recipient = 0xbeefcafe54750903ac1c8909323af7beb21ea2cb;
// Send payment using your token for fees
IFeeManager feeManager = IFeeManager(TIP_FEE_MANAGER_ADDRESS);
feeManager.
use alloy::{
primitives::{address, U256},
providers::ProviderBuilder,
};
use tempo_alloy::{
TempoNetwork,
contracts::precompiles::{ITIPFeeAMM
Users can set your stablecoin as their default fee token at the account level, or specify it for individual transactions. Learn more about how users pay fees in different stablecoins.