5

Let's assume we have 50 ERC20 tokens that we would like to support (deposits) on our website. People are depositing tokens to the ETH adresses we've generated for them.
In the end of the day, we want to geather tokens from all the generated addresses and send it to our cold wallet.

How can we make the transfer to the cold wallet if the newly generated addresses don't have any ether on it (this means no gas) and we don't want send there any ether?

Preferably, I would like to pay all the GAS that's requried for transactions from the cold wallet address - is it possible?

How exchanges are managing such situations? Do they generate the adresses and every time they are sending there eth to have enought for gas? In the end of the day, they have to move assests to one account. That's sounds... unefficent.

susanoo
  • 51
  • 1
  • 3

3 Answers3

2

This is not currently possible with the ERC20 standard. There are a few proposals that address this issue from different angles, but none of them is accepted as a standard yet:

  • EIP 865 supports delegatedTransfer
  • EIP 965 extends ERC777 with a "Cheque Operator". The use case you asked about is described here.

Both these proposals require changes in the token contract though, so they won't work for already existing ERC20 tokens.

So the obvious solution, unfortunately, is to send just enough ether to the generated addresses to cover the gas costs for moving the tokens out.

If you happen to own significant mining power to produce a block every X hours and you're ready to wait X hours to move those tokens out, you can configure your mining software to include your own zero-fee transactions in your own blocks.

Lucian Boca
  • 161
  • 6
  • 1
    thanks, i saw it's not a standard but somehow exchanges have to collect even small amounts of tokens from great amount of addresses and I'm pretty sure they are not sending GAS for each of these accounts as it will be expensive – susanoo Aug 22 '18 at 17:21
  • 2
    That's precisely what most (if not all) the custodian exchanges are doing: generate an address, fund it with enough ether to cover the gas fees for a few token transactions, then get the ether out if the user gets inactive for too long. They use a single address for all the tokens, so it's one address per user. – Lucian Boca Aug 23 '18 at 19:53
1

Instead of making EAOs for the users, make contracts wallets with a transfer function that you can call from the address you want to send the token. That said, the system that you propose is a bit strange, as the users have to trust you. In such case, you can just have a contract with balances for each user, just like the token contract.

Hope this helps

Jaime
  • 8,340
  • 1
  • 12
  • 20
  • Hi Jamie! That sounds great, could you explain it a little bit more? How it should work? What should I google for each step. – susanoo Aug 22 '18 at 15:53
  • which one, the wallet contract or the contract with balances for each user?, notice that if they need to trust you, you can just ask them to send you the tokens – Jaime Aug 22 '18 at 15:58
  • Acually both. I'm providing the small local exchange. I'm generating them address and share it on frontend. People are sending me tokens to exchange to USD. Therefore in the end I have to collect it to main cold wallet but I don't want to send ether to each of these wallets as the amounts sometimes are really small and it's not efficent. I'm wondering how big exchanges doing it because cost is really big in great scale. From what I undestrood from your post I can write some contract that will allow me for exmple to transfer Tron token directly to cold wallet and I will pay the fee? – susanoo Aug 22 '18 at 17:17
  • I just need more details and buzzwords so I could look it up on google what can I use to cover gas price with mine wallet rather than sending it to each of wallet I generate – susanoo Aug 22 '18 at 17:18
  • I just want to be sure I understand what you need. Why not asking them to send the tokens to your wallet directly? – Jaime Aug 22 '18 at 21:06
  • I want to provide same system as on exchanges - everyone get's newly generated eth account on my wallet. If I want to support multiple known tokens, would wallet contract or contract wilth balances work ? – susanoo Aug 23 '18 at 07:19
  • @susanoo is asking for a custodian setup. He needs different addresses for each user so he can associate the deposits with the corresponsing users. – Lucian Boca Aug 23 '18 at 19:27
  • @Jaime could you help me with that? – susanoo Aug 26 '18 at 18:34
  • Sorry, I still do not understand why you need to create eth addresses if people already have their tokens in eth addresses. You can just ask them to send the tokens to the main address instead. Given that the ERC fire events on transfer, then you can know who sent you tokens in the back end. Let me know if I am missing something. The solution I proposed will still cost you gas for each transaction, but will cost you nothing if they send the tokens to your address. – Jaime Aug 27 '18 at 07:47
0

You can do with "flashbots"

  • Welcome to the Ethereum Stack Exchange! Answers here need to a be a little more detailed :) This was auto-flagged and the only choice I have is whether this answer is low quality or not, and it doesn't meet the bar of the latter... EDIT: apparently I can leave this comment without the system deleting your answer. – eth Jan 18 '22 at 03:18