6

I have a requirement to have 1000+ ethereum addresses, which in fact used to store small amounts of various ERC20 tokens. I want to move all these crypto assets in all these 1000+ wallets into a single address.

If I could create a pool account with a single private key, it was the best method, but based on my current understanding on ethereum, I believe that it's not possible with ethereum. Every address is associated with another private key.

Now, note that all these 1000+ account has no ethereum in it. So in order to transfer ERC20 token to a common account, I need to transfer ETH in first to these 1000+ accounts for gas price for the ERC20 token transfer for each of these accounts.

Which means I need to transfer in ETH to account for gas, then transfer out ERC20 token to the pool account with the small amount of ETH transferred in.

Though it might work, it seems to be very complicated and a lot of ETH unnecessarily being wasted for gas while I am still in control of all these 1000+ accounts.

Is there any better or easier way for me? Like exchanges do? How can I internally transfer without a gas price? Or is there a way (even a complicated way) that I can have a pool account having single private key with multiple addresses?

Can anyone help?

Thanks,

5 Answers 5

3

Though it might work, it seems to be very complicated and a lot of ETH unnecessarily being wasted for Gas while I am still in control of all these 1000+ accounts.

I think you've mostly self-talked your way through this. If these are standard ERC20 contracts without backdoors, as I assume is the case, then there is simply no way around the constraint that a transfer transaction must be signed by the token holder.

If this were not the case, then it would be possible for a clever contract to spend from other people's wallets (ETH or Tokens). That would lead to a rather quick and disorderly collapse of just about everything.

You have the keys, so you can sign. The fact that the accounts have no ETH to pay for gas is something to think about before sending assets there. I would also give some thought to the cost implications. Gas cost for these transactions is scale-invariant, so you're making everything 1000x more expensive. You didn't mention the purpose of this so it's hard to say if there is a more ideal way to approach the issue.

Hope it helps.

4
  • Thanks Rob, for your answer. I am trying to build an app somewhat similar to an exchange, so each user will get an address where they can deposit/transfer ERC20 token. Each user will get the the address, but I control the private keys. Now any user may use the same address given to them to transfer multiple types of ERC20 tokens. Note that different users will get different addresses. I somehow need to accumulate all these crypto assets from these different addresses into ONE single pool master account for easy management further. Do you have an idea how exchanges are handling this?
    – Jab2Tech
    Sep 4, 2018 at 17:52
  • Another problem I face with is that one single address may hold multiple ERC20 types of tokens, so to transfer the entire assets of the address, each ERC20 token to be transferred separately..right? Which means I need to use more Gas for each transaction corresponding to different ERC20 tokens stored in the account. For example, if an address hold OMG and GNT in it, I need two different transactions to send that to the common pool.
    – Jab2Tech
    Sep 4, 2018 at 18:04
  • Right. You could possibly mitigate that with Raghav's suggestion of deploying contracts instead of externally owned accounts, in which case the contracts could contain logic to do than one thing at a time. Overall, though, I would incline to resisting the idea that so much should be scattered so far. There is no known efficient way to gather it all up. Sep 4, 2018 at 18:47
  • oops ... "more than one thing at a time ..." Sep 5, 2018 at 18:22
4

If you are using 1000 externally owned accounts, this is not possible.

The only way you can have a separate address pay for token transfer costs is by having each user wallet be a contract, and the contract supports ERC20 standards, and can invoke the transfer function.

However, this has the added cost of deploying 1000 contracts as user addresses, which may exceed the cost of simply sending ether and then sweeping it.

1
  • thanks Raghav for your suggestion! It means all the user wallet addresses should be actually a contract address..right, not a regular ETH address against a private key. And every time I need to generate a new address, I need to deploy a contract instead and get the contract address instead of generating a new address with web3.eth.accounts.create()
    – Jab2Tech
    Sep 5, 2018 at 1:52
1

You need to have each of those 1000+ addresses transferring their token to the single final address and, yes, you have to send to each of them some gas to spend before of it.

This is because the ERC20 transfer function uses the msg.sender as hidden parameter in order to understand if the right of transferring is present.

I mean: ERC20 transfer is a "transfer(_to, _value)" type and it implicitly assumes that the _from account is that owned by msg.sender.

This call needs gas!

It could be a different situation if some "transfer(_from, _to, _value)" did exist in the ERC20 standard; but the only "_to, _from, _value" type function in ERC20 standard is the famous "transferFrom(_from, _to, _value)" which, unfortunately, does not work if not some approvance of the "_from, _to" transfer has been given before by means of the approve function.

I.e. you should have to call the "approve(_to, _value)" before, which implements exactly the same mechanism of implicit msg.sender=tokenowner definition.

And this needs gas as well, less or more the same gas than the transfer call.

Sorry for this.

0

I can suggest you to use https://ethersweep.com You can simply transfer the ETH balance to the output address, together with the funds from any converted ERC20 tokens. You also have an option to retain any unsupported tokens (although around 97% of the most common tokens are supported) and these are transferred to your outpayment wallet on completion. Basically a one click solution to detect ERC-20/Airdrop tokens and convert direct to ETH.

0

I've got an answer with exactly what the user requested. A single private key, and hence a single gas pool for all the ERC 20 wallets.

The solution: A contract that generates other contracts that act as receivers.

Relevant Stackexchange Answer: Common Gas Wallet for ERC20 Wallets?

Relevant Github Link: https://github.com/Meshugah/ERC20-CommonGasWallet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.