Skip to main content
Hashbeam

Crypto protocols, markets and policy

9218dc

How a Token With No Gas Can Fund Its Own Swap

An ERC-20 balance cannot pay its own first transaction fee; a compatible paymaster or funded relayer can front native gas and recover the cost in tokens.

The Hashbeam Desk··5 min read

How a Token With No Gas Can Fund Its Own Swap

An ERC-20 token cannot pay the gas for its own transfer from an ordinary externally owned account: the chain charges transaction fees in its native currency before the token contract can move anything. To turn that stranded balance into gas, you need another payer to submit the transaction—a paymaster, a relayer, or a separate wallet that sends a small amount of native currency. The useful distinction is that the token does not become gas at the protocol level; a service advances the gas and collects an agreed token payment.

That distinction matters for swaps. A decentralized exchange call still has to be included in a transaction, and its sender must cover the network fee. For a cross-chain route, the source-chain transaction also needs funding before the asset reaches the swap protocol. The thor swap guide covers that trade path in more detail; the key point here is that a swap interface alone does not remove the source-chain fee requirement.

Why can’t the token pay its own gas?

On Ethereum-style networks, a transaction has a sender, a nonce, a gas limit, and fee fields denominated in the chain’s native currency. The execution layer charges the sender for computation whether the transaction succeeds or reverts. An ERC-20 transfer is a call to the token contract’s transfer function, but that call runs only after the transaction has been accepted and its fee payer established.

The token contract can update balances; it cannot change the chain’s fee rules. A normal wallet holding only an ERC-20 therefore cannot directly submit the transfer needed to sell that token. The same snag applies to a swap: the router call is another transaction, not a special exception. Nor does an ERC-20 allowance solve it. approve is itself a transaction that needs gas.

An EIP-2612-style permit can let a user sign an allowance off-chain, avoiding a separate on-chain approval transaction when the token and application support it. But a relayer still has to submit the transaction, and that relayer must pay gas. A permit changes how authorization is delivered; it does not make the token acceptable to the network as a fee currency.

How does a paymaster turn tokens into a fee payment?

An ERC-4337 paymaster can sponsor a smart account’s operation and charge for that service in a supported ERC-20. The user signs a UserOperation describing the intended call; a bundler submits it through the EntryPoint contract. The EntryPoint checks that the paymaster has enough native currency deposited to cover the operation, then asks the paymaster whether it will sponsor it. If approved, the paymaster fronts the network fee and can collect the token payment under its rules.

This is fee abstraction, not a protocol change to gas accounting. The bundler’s on-chain transaction still pays the network fee in native currency. The paymaster needs that currency in its EntryPoint deposit, and its validation logic decides which users, operations, and tokens qualify. Its service may require a token balance, a signed quote, a fee markup, or an allowance. Support is specific to the account implementation, chain, paymaster, and token; an arbitrary ERC-20 balance is not automatically eligible.

EIP-7702 can let an externally owned account delegate code so it can use smart-account behavior, including sponsored operations when paired with compatible infrastructure. The authorization does not itself supply a sponsor or make every token spendable as a fee. The account still needs to authorize the operation, and a paymaster or other payer must agree to fund it.

What should you check before trying it?

First establish whether the wallet offers a sponsored transaction or token-paid gas flow on that specific network. If it does, check the quoted token charge and the exact action being authorized. The transaction may bundle a token transfer or swap with the sponsored operation, but the sponsor’s policy and token support determine whether that route is available.

  • Confirm the token contract and network. A token with the same ticker on another chain is a different asset and will not pay this operation.
  • Check the displayed token fee, expected output, and minimum received after slippage. The sponsor’s charge can make a small balance uneconomic to recover.
  • Read the wallet prompt for the call target, spending limit, and signature scope. A permit or account delegation can authorize token movement beyond the immediate gas charge if it is too broad.
  • Keep enough token value to cover the fee and execution. A rejected operation may not complete the swap, and a reverted on-chain operation can still consume gas paid by its sponsor.

If no compatible paymaster is available, the dependable route is to have another account send a small amount of the chain’s native currency, then submit the token transfer or swap normally. A centralized service may offer a sponsored deposit path, but that depends on its deposit rules and is not an on-chain guarantee. For most stranded balances, a small, deliberate top-up is simpler than relying on token-specific sponsorship. Where sponsorship is available, it can make the first action possible—but the token is payment to the sponsor, not gas in the chain’s fee market.