Tips on Managing Multiple Accounts When Developing an Ethereum Based Small Scale Exchange

Seung Woo Kim
GoCryptobot
Published in
3 min readMay 16, 2018

Continued from the previous article, let’s discuss what is needed to create a small scale exchange. In order to receive Ethereum from the exchange, each user must be assigned an address for deposit. The simplest implementation is as follows: every time a new user is registered, create a random private key and store it, and use that private key to assign addresses for users.

This results in the amount of private keys equaling the number of users in the database. ETH that has been deposited this way are sometimes sent to our exchange address all at once.

However, there is a disadvantage with this design, which is the fact that the server that confirms the deposits of ETH also manages the private key. When dealing with Ethereum, the private key is extremely pivotal information. Once revealed, one can lose all of his/her ETH in possession. Storing and managing this kind of information on a server that is connected to a network is extremely dangerous.

Cold Wallet

A Cold Wallet is an Ethereum wallet that is not connected to the internet. If one needs to send Ethereum, he/she can create a transaction file at the Cold Wallet, and then run the transaction through another wallet that is connected to the internet.

One can also use the Cold Wallet when receiving ETH. The code that checks for ETH deposits checks with only the public key. Once a day, a transaction, which sends received ETH to an administrative address from the Cold Wallet, is produced. After that, the transaction is run.

However, creating a new account causes problems. An account should be created when a user wants at any moment. However, it is not possible to create new accounts every time from the Cold Wallet. Since the Cold Wallet is not connected to the internet, someone has to personally go create an account manually. This means the throughput will be notoriously slow.

On the side of Bitcoin, the HD Wallet can be used in order to solve this problem.

HD Wallet

HD Wallet involves creating private keys from a single private key. Bitcoin recommends that each user should create multiple accounts for security purposes. Thus, by using an HD Wallet, multiple accounts can be easily managed.

An HD Wallet has the following properties. An infinite amount of child keys can be made from a single parent private key. An infinite amount of child public keys can be made from a parent public key. At this point, the child’s private key created from the parent private key, and the child’s public key made from the parent’s public key each make a pair.

Now let’s return to the problem that arises when assigning a new Ethereum address to a new user. If an HD Wallet is used, every time a new Ethereum address is assigned, only the public key that will become a root just has to be held on to. With that root public key, new public keys can be created. The root public key will be stored in the Cold Wallet. transactions that involve sending money from the Cold Wallet can be done by creating necessary private keys from the root private key.

Code

The code above uses a Javascript library called ethereumjs-wallet. It creates the 17th address from the root extended key.

Conclusion

So far, we have discussed the usefulness of the Cold Wallet. In addition, we’ve explored how the Cold Wallet would come to manage the private keys, and how public keys can be created without the private keys. (For the Korean version of this article, click here).

Last but not the least! Now it’s time to enjoy GoCryptobot.
Download from here :)

- App Store: https://apple.co/2KbMipn
- Google Play:
https://bit.ly/2K5tYhx

--

--