Can someone tell me how it is possible to implement the generation of unique erc20 addresses for registered users?

  • 1
    What do you mean by "registered users"? A user is typically identified by its address, which means a registered user already has a unique address (with which it is registered)! – goodvibration Oct 27 '19 at 15:48
  • @goodvibration Suppose a new user is registered on the exchange, and I need to generate a unique eth address for him – Eliness Oct 27 '19 at 15:54
  • An address typically comes with a private key. How do you want to give him/her that private key while keeping him/her confident that you haven't kept a copy of it for yourself? The user, or at least your code running on his/her machine (aka client code) should be the one providing you (i.e., your server) this address, not vice-versa. – goodvibration Oct 27 '19 at 16:02
  • @goodvibration But how then are eth addresses given to users on exchanges? – Eliness Oct 27 '19 at 16:26
  • 1
    They probably let the user register with a password, and keep the user's private key and public address on their servers (which technically violates the blockchain's fundamental idea of decentralization). – goodvibration Oct 27 '19 at 16:37

So, reading the comments it seems you are running an exchange and you want to generate accounts (addresses included) for your users so that they can deposit funds, while you control the accounts (you have the private keys), and not them. You can do that using an HD wallet, as described in BIP32.

In javascript there are many options out there like ethereumjs-wallet or the one truffle made.

Also notice that whenever your users send you ERC20 tokens you won't be able to retrieve them so easily, since in order to do so you'll firstly need to send enough ETH to the account you want to retrieve funds from, sacrificing a bit of dust in the process.


As a possible solution, you could use this method to derive accounts for your users. For instance, assuming your users have unique IDs as integers, you could do the following:

var hd_key = EthereumHDKey.fromMasterSeed(<seed>);
var account = hd_key.derivePath("m/44'/60'/0'/<your user ID as a string>/");

That will generate public/private keys and an address for the user identified by its ID.

  • You understood me correctly, but you don’t have any sources with minimal functionality? – Eliness Oct 27 '19 at 17:10
  • I updated the answer. – Molina Oct 27 '19 at 17:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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