I have a ERC20 token on a wallet called ETH (Ethereum Meta) but I don't have any ETH on that address so I can't transfer the ERC20 tokens because I cant pay the gas fee. I have some ETH on another address. I don't want to send/deposit my ETH to the wallet that have the ERC20. so what I wanted was to know if it was by any way possible to pay the gas fee from another wallet? or let the receiver of the ERC20 pay the gas fee??
1 Answer
What you want isn't entirely possible, but there are edge cases that could help.
No, one account can't pay the gas fee for another accounts transaction at the lowest level in Ethereum. You would, in most cases, need to transfer the ETH from that account to the account that needs to do the other transaction.
However, ERC20 tokens do have the approve
and transferFrom
methods. With these, the account holding your ERC20 tokens could approve
the account with ETH to transfer its assets, paying the ETH fees for the transfer. (using transferFrom
). This does, of course, requires that the ERC20 account has already paid the ETH fee to do a transaction calling approve
. If you haven't done that, and can't, then the other account wont have the allowance to do a transferFrom
. At least, usually.
There are even more specific cases though where contracts allow you to set an allowance without needing to call approve
from the ERC20 account at all. An example is USDC (current implementation), specifically the permit
and transferWithAuthorization
functions.
The former allows the USDC account to sign a message off-chain that says that another account can call the permit
function to set the allowance themselves, once. This is good if the approved account is then expected to transfer multiple/many times in the future without needing further approval/interaction with the USDC account holder.
The transferWithAuthorization
function is similar, but the USDC account signs a message that allows the other account to transfer up to a specific amount just once. This would be good for you if you just wanted to transfer all of the USDC out of an account one time.
In both of these cases, your USDC account wouldn't need any ETH to transferred to it to get the USDC fully out. However these aren't standard ERC20 functions. Some contracts may follow USDC and have them, some may implement similar but different methods, and most ERC20s don't have this at all.
-
1Could he sign a transaction with the account holding ERC20 tokens and let account with ETH broadcast it to the network?– SkyCommented Apr 3, 2022 at 17:29
-
1@Sky No, an actual transaction on the Ethereum blockchain will pay the fee from the signer of the transaction. There isn't a way to pay for someone else's raw transaction, though some smart contract wallets like Gnosis Safe enable the ability to do so. There are also EIPs for implementing account abstraction that may enable it, but they are as of yet not implemented Commented Apr 3, 2022 at 17:32
-
Until the ETH blockchain includes EIP-2612 (eips.ethereum.org/EIPS/eip-2612) in a hardfork, we'll have to pay ERC-20 with gas from the wallet the ERC-20 tokens reside on Commented May 12, 2023 at 12:15