Web3: How to pay transaction fee from another wallet?

916 views Asked by At

I need help. I have a webpage, where user register and I create a new wallet address for him (I own private key). Then he receive erc20 tokens on that address and he can withdraw them to his own private wallet. Problem is that on that newly created wallet there is no native token (for example MATIC which is used to pay for transaction fee). How can I pay fee from another wallet for that transaction? Is that even possible? How else can this be solved?

Its kinda stupid that I need to send MATIC to that new wallet first, so I can pay for fees, isn't it? I will actually pay double fee for that.

What I want is kinda the same system as exchanges have. You can deposit tokens and withdraw them. But I am confused how they pay for transactions fees?

1

There are 1 answers

0
Petr Hejda On BEST ANSWER

Paying gas fees for another address is not natively supported by EVM networks.

Exchanges usually withdraw tokens from their hot wallets that hold multiple tokens as well as the native token of the network.

When exactly they collect ERC-20 tokens from the deposit wallets, that's part of their business strategy. It might depend on:

  • Whether the user deposits native tokens as well
  • How much of them
  • What is the exchange's balance of that specific ERC20 token in the hot wallet. If it's low, the exchange might be willing to pay a premium by sending native tokens to some deposit wallets to be able to collect the ERC20 token quickly.
  • Regular cleanup schedule of all deposit wallets. E.g. once in a month they might send native tokens to all of their deposit wallets and transfer all ERC20 tokens to their hot wallet.
  • etc...