Alt-fee gas payment on Morph L2 — pay gas with alternative ERC20 tokens via tx type 0x7f
Pay gas with alternative tokens (tx type
0x7f) on Morph Mainnet (Chain ID: 2818). All commands output JSON. Morph-exclusive feature not available on other L2s.
Use this skill when the user wants to: list fee tokens, check fee token info, estimate gas cost in an alternative token, or send a transaction paying gas with a non-ETH token on Morph.
pip install requests eth_account
# Run from repository root
python3 scripts/morph_api.py <command> [options]
No API keys required. Queries the on-chain TokenRegistry at 0x5300000000000000000000000000000000000021.
Decide the mode once via the root SKILL.md and docs/social-wallet-integration.md.
altfee-send requires --private-key (local signing only).no_gas mode).altfee-tokensList all supported fee tokens from the on-chain TokenRegistry.
python3 scripts/morph_api.py altfee-tokens
altfee-token-infoGet details for a specific fee token: contract address, scale, feeRate, decimals, active status.
python3 scripts/morph_api.py altfee-token-info --id 5
altfee-estimateEstimate the minimum feeLimit needed to pay gas with a fee token. Includes a 10% safety margin.
# Estimate for a simple ETH transfer (21000 gas)
python3 scripts/morph_api.py altfee-estimate --id 5
# Estimate for an ERC20 transfer (200000 gas)
python3 scripts/morph_api.py altfee-estimate --id 5 --gas-limit 200000
altfee-sendSign and broadcast a transaction paying gas with an alternative fee token (tx type 0x7f). --fee-limit defaults to 0 (no limit — uses available balance, unused portion is refunded).
# Simple ETH transfer, pay gas with USDT (token ID 5)
python3 scripts/morph_api.py altfee-send --to 0xRecipient --value 0.01 --fee-token-id 5 --private-key 0xKey
# Contract call with explicit fee limit and gas limit
python3 scripts/morph_api.py altfee-send --to 0xContract --data 0xCalldata... --fee-token-id 5 --fee-limit 500000 --gas-limit 200000 --private-key 0xKey
altfee-send — show the recipient, amount, fee token, and fee limit before signing.feeLimit=0 means no limit — unused portion is refunded, but confirm this with the user.0x7f1=USDT.e, 2=USDC.e, 3=BGB (old), 4=BGB, 5=USDT, 6=USDCfeeLimit >= (gasFeeCap × gasLimit + L1DataFee) × tokenScale / feeRatefeeLimit = 0 means "no limit" — uses entire balance, unused portion is refunded0xe7cd86e13AC4309349F30B3435a9d337750fC82D)Pay gas with alternative token:
altfee-tokens (list available) → altfee-estimate (calculate cost) → altfee-send (sign & broadcast)
DEX swap with alt-fee gas payment:
dex-quote --recipient 0xAddr (morph-dex skill) → altfee-send --data 0xCalldata... --fee-token-id 5
| Command | --fee-token-id support |
|---|---|
altfee-send | Yes (required) — standalone altfee transaction |
agent-register | Yes (optional) — inline altfee gas payment |
agent-feedback | Yes (optional) — inline altfee gas payment |
transfer | No — use altfee-send --to ... --value ... instead |
transfer-token | No — use altfee-send --to ... --data ... instead |
dex-send | No — use altfee-send --to ... --data ... instead |
dex-quote (morph-dex) to get swap calldata, then pass to altfee-send for gas payment with alt tokens.token-balance (morph-wallet) to check fee token balance before sending.balance (morph-wallet) to check if user has ETH — if not, suggest alt-fee.no_gas mode).