I'm trying to implement a mechanism to generate random addresses for users to deposit ERC20 tokens and then consolidate the deposited tokens to a cold wallet address later, somewhat like what an exchange does when users deposit tokens to exchange addresses. Right now it seems I have two options:

  1. Generate a new address for each user (with random private keys or with an HD wallet scheme). After a user deposit tokens to the generated address, we need to first send some ether as gas to the address, then call the token method to transfer the token back to our cold wallet.

  2. Generate a new contract address for each user with a master address. After a user deposit tokens to the generated address, we call the contract with the master owner address to withdraw the token to our cold wallet.

Both methods seem to have their own caveats, as for generating a new normal address for each user, when consolidating we need to first calculate the ether required as gas, and send ether to that address, and then call the token contract to transfer the tokens, which is quite convoluted and need two transactions meaning spending gas twice.

For generating a new contract address for each user, it means for each new user we need to spend gas to create the new contract, which could be a waste if there are many users that don't deposit tokens.

I'm wondering if anyone has any idea what's the standard procedure used by those top exchanges nowadays, how do they handle the gas fees when consolidating ERC20 tokens to cold wallet and withdrawing the ERC20 tokens?

1 Answer 1


For number 2, you could just have the contract you create for each user forward the tokens directly to your . You would have to use the approve/transferFrom functions in the erc20 standard to make it work.

An alternative is to create a dApp interface. Generate a unique id for each user and have them call your 1 smart contract submitting the unique id, token address, and token amount, then you can transferFrom them into your cold storage address.

  • I'm looking for a mechanism so the average users can deposit tokens into my platform using generic wallet software like imToken or Coinomi, so methods involving a new specific dApp or more complicated contract operations like calling the "approve" method is not really suited here, also considering there are different non-standard implementations of the "approve" method out there with different tokens, I'd rather use a mechanism that only involves the user calling the "transfer" method from their end to deposit the tokens.
    – hellopeach
    Commented Nov 9, 2018 at 3:45

Your Answer

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

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