0

I am developing an app using Web3.js where users send an amount of tokens to a new wallet. What I want is forward the tokens to another wallet but I am unable because the wallets where tokens are received don't have ETH to pay gas fee. Are there any way to forward the tokens without ETH, I was thinking to use an account just for paying fees. For example Wallet A send 30 tokens to Wallet B, this wallet sign the transaction and Wallet C which have ETH will send the signed transaction so another Wallet D could receive the tokens. Is it possible?

sendfy
  • 3
  • 2

1 Answers1

0
  • Since each Ethereum transaction requires computational resources to execute, each transaction requires a fee. Gas refers to the fee required to conduct a transaction on Ethereum successfully. See these links to know more about fees: 1, 2.

  • Gas fees are paid in Ethereum's native currency, ether (ETH).

  • If you are looking for a centralized architecture, you can start with these links: 1, 2, 3. If you are not going to use smart contracts' approach and want to go with the EOA one, just simply send the (estimated gas * gas price) to the sender's account, before proceeding the token transfer. These links might be useful on the gas subject: 1, 2.

Hope this helps.

Rouhollah Joveini
  • 488
  • 1
  • 3
  • 16
  • Thank you for your answer. I think the best option would be create a "parent" wallet to generate multiple public deposit wallets as you mentioned before. Do you have more information about it? – sendfy Jan 24 '22 at 20:50
  • @sendfy, github repo: https://github.com/cipherzzz/erc20-megawallet – Rouhollah Joveini Jan 25 '22 at 04:55
  • Are you aware of this fact that within this approach, you have to create a contract address for each user (here named ERC20Wallet)? It costs you at least $100 per user to deploy their smart contracts on the Ethereum network, depending on the gas price. However as I mentioned in my stack Q, there are a few workarounds to minimize the fee, but not zero. – Rouhollah Joveini Jan 25 '22 at 05:00
  • But, the pros are: 1. auto-forwarding deposit Ether to the master account with zero fee (in the EOA model you have to pay 1 fee). 2. paying 1 transaction fee to (NOT_AUTO-)forward erc20s to the master account (in the EOA model you have to pay 2 fees). – Rouhollah Joveini Jan 25 '22 at 05:04
  • In case you are not familiar with contract addresses: https://info.etherscan.com/what-is-an-ethereum-address/#:~:text=There%20are%20two%20types%20of,(EOA)%20and%20Contract%20Address. – Rouhollah Joveini Jan 25 '22 at 05:07
  • Thank you for your help again @RoliJ I have read about HD Wallets, but I don't know if I would need to pay more gas fee to forward payments to master wallet. What I am looking is a cheap way to receive ERC-20 tokens to a wallet and then forward them to master wallet. – sendfy Jan 25 '22 at 11:43
  • EOA model: 1. Suppose that user A has a deposit of 1 ETH to his EOA wallet. If you are going to forward this amount to your master wallet M (which is EOA, too), you can send 1-fee ETH to the wallet M and then charge user A for 1 ETH in your database. 2. Suppose that user A has a deposit of 10 erc20 token unit to his EOA wallet. If you are going to forward this amount to your master wallet M (which is EOA, too), you have to send fee ETH to his wallet (this means that you have to pay 2 fees) and then send 10 tokens to the wallet M and then charge user A for 10 erc20 token unit in your database. – Rouhollah Joveini Jan 26 '22 at 05:10
  • Smart contract model: 1. Suppose that user A has a deposit of 1 ETH to his SC wallet. This amount will be forwarded automatically with zero fee to the master wallet M (which is EOA), and you can charge user A for 1 ETH in your database. 2. Suppose that user A has a deposit of 10 erc20 token unit to his SC wallet. If you are going to forward this amount to your master wallet M (which is EOA), you have to call the sweep function of his SC and pay the gas with M's non-zero ETH balance (this means that you have to pay 1 fee) and then charge user A for 10 erc20 token unit in your database. – Rouhollah Joveini Jan 26 '22 at 05:14
  • In the EOA model, example 1, each fee is in the order of $10 (with ETH being almost $3K).
  • In the EOA model, example 2, you have to send almost $30-60 with fee of almost $10 to the A wallet (with ETH being almost $3K).
  • In the SC model, example 1, you don't have to pay anything.
  • In the SC model, example 2, fee is in the order of $30-60 (with ETH being almost $3K).
  • – Rouhollah Joveini Jan 26 '22 at 05:19
  • Note that in the EOA model you don't have to pay anything for creating wallets for users, but in the SC model you have to pay almost $100-300 for creating wallets for each user. – Rouhollah Joveini Jan 26 '22 at 05:21
  • So, as you can see, it is your call to choose one model for your architecture. I think the SC model would be more cost-effective than the EOA one in a long run. But you have to pay almost $100K-300K for 1000 users. You can decrease this amount by modifying Megawallet's approach's solidity code. You can also deploy your smart contracts in evm compatible chains with lower fees. I think that if you follow this path, you may reach to a number in the order of $1K rather than $100K-300K. – Rouhollah Joveini Jan 26 '22 at 05:34
  • Take a deeper look to this Q and all the answers and comments. – Rouhollah Joveini Jan 26 '22 at 05:35
  • Note that for using both models, you have to have centralized trade center (where you only change users' balances in your database without forwarding their requests to the blockchain) in your website, so you can retrive what you paid by getting low fees for users' trades. In this case you can make deposit requests' fees of your website, zero. – Rouhollah Joveini Jan 26 '22 at 05:38
  • Last but not least, SC model may be more cost-effective than the EOA model. But, you have to pay some dollars for creating the wallets before anything gets started. And, EOA model may be better choise for those who cannot pay the wallet creation cost (i.e. those who cannot pay the seed money). Your call. – Rouhollah Joveini Jan 26 '22 at 05:48
  • Really appreciate your help @RoliJ. I will choose maybe EOA model, but I'll need more help to understand the concept. I was thinking if i'll be able to pay for someone gas fee, for example sign a transaction with 0 gas fee and then broadcast it with an account with eth. Because what i would like to do is from Wallet A send to Wallet B a percentage and Wallet C, so if a send for example to wallet A some eth to pay for doing two transactions i'll pay x3 – sendfy Jan 26 '22 at 22:19
  • I am planning to use Binance Smart Chain too so it would not be a drawback as fees are too low. – sendfy Jan 26 '22 at 22:22
  • In addition how Coinbase and Binance work? I mean if I make a deposit of 20$ of an ERC-20 token and then I would like to withdraw how and fees are i.e 30$, how can it be affordable? – sendfy Jan 26 '22 at 22:24
  • Apologies for the delayed response. Abount the Binance Smart Chain (BSC), fees are almost 1% of the same transaction in Ethereum network, e.g. $0.3 rather than $30. But, you have to work with pegged tokens (not all ERC20s are pegged, I suppose). – Rouhollah Joveini Feb 04 '22 at 20:22
  • And about the EOA model: almost all centralized exchanges I know, are using this model. This works as follows: someone from outside of your website, sends say 2 UNI to your website user Sam. You want to withdraw Sam's UNI balance to the website owner's master account. To do that, just simply estimate the gas required for transferring 2 UNI from Sam's account to the master account ($60). Send the estimated gas to Sam's account ($30 fee). Now that Sam's account has the sufficient gas from transferring 2 UNI to the master account, do the transaction. Thus, you have to pay $90 to do the job. – Rouhollah Joveini Feb 04 '22 at 20:31
  • To send Sam's balance to two master accounts, you have to send ($60 + $60)-valued ETH to Sam's account ($30 fee). And now you are free to do the job. Note that these numbers are for examples. It changes due to the change in ETH price and of cource the network's gas price. i.e. it can be lesser or higher. – Rouhollah Joveini Feb 04 '22 at 20:34
  • An advice, for new questions that are not related directly to your main question like the bsc one, ask it as a new question, so professionals may become encouraged to help you better. This will be also very useful for those who might have the same question. – Rouhollah Joveini Feb 04 '22 at 20:37