TIP-1007: Fee Token Introspection
Protocol Version: TBD
Status: In Review
Authors: Georgios Konstantopoulos
Status: In Review
Authors: Georgios Konstantopoulos
Abstract
TIP-1007 adds agetFeeToken() view function to the FeeManager precompile that returns the fee token address being used for the current transaction. This enables smart contracts to introspect which TIP-20 token is paying for gas fees during execution, allowing for dynamic logic based on the fee token choice.
Motivation
Tempo transactions support paying gas fees in any USD-denominated TIP-20 token via the fee token preference system. However, prior to this TIP, there was no way for a smart contract to determine which fee token is being used for the current transaction during execution. This capability was requested by a partner. It could be useful for contracts that want to:- Adjust their internal logic based on which fee token is being used
- Provide fee token-aware pricing or routing decisions
- Emit events or logs that include the fee token for off-chain indexing
- Implement fee token-specific behavior in cross-chain messaging
Specification
New Function
The following function is added to theIFeeManager interface:
Behavior
Fee Token Resolution
The fee token returned bygetFeeToken() is the same token that was resolved by the protocol during transaction validation, following the fee token preference rules.
Storage
The fee token is stored in transient storage (EIP-1153) within the FeeManager precompile. This means:- The value is automatically cleared at the end of each transaction
- No persistent storage writes occur, minimizing gas costs
- The value is consistent across all calls within a transaction (including internal calls and subcalls)
Timing
The fee token is set by the protocol in thevalidate_against_state_and_deduct_caller handler phase, before any user code executes. This ensures the value is available throughout the entire transaction execution.
Gas Cost
Reading the fee token costs the standard warm transient storage read cost (100 gas for TLOAD). This is the cost of callinggetFeeToken() itself; callers should account for additional gas used by the CALL opcode to invoke the precompile.
Edge Cases
| Scenario | Return Value |
|---|---|
| Normal transaction | The resolved fee token address |
| Free transaction (zero gas price) | The resolved fee token (may still be set) |
eth_call simulation | address(0) (no transaction context) |
address(0) is returned is in simulation contexts (e.g., eth_call) where the protocol handler does not execute.
Example Usage
Invariants
getFeeToken()must return a consistent value across all calls within the same transactiongetFeeToken()must returnaddress(0)in simulation contexts (e.g.,eth_call) where no transaction handler runsgetFeeToken()must be callable fromstaticcallcontexts without reverting- The fee token returned must match the token used for actual fee deduction in
collectFeePreTxandcollectFeePostTx - Reading the fee token must not modify any state (view function)