2

Say I am an exchange that has many users. When I ask a user to deposit ETH I give him a unique address so I can attribute the ETH to him.

With Bitcoin this is easy. The bitcoin wallet software handles this and I can have BTC on multiple addresses and it's treated as one account.

I understand that with Ethereum this is different.

I found 2 options to achieve this:

  1. Deploy a forwarder smart contract once for each user, give the address to the user. When the smart contract receives ETH, it forwards it to my main ETH address.
    Pros:

    • User pays the gas cost of forwarding ETH
    • Only have to keep track of one account (1 private key).

    Cons:

    • I have to pay gas cost of deploying the forwarder contract multiple times
  2. Create an account for each user. Don't give the private key to the user. Periodically go over all "user accounts" I control and send the ETH to the "main account"

    Pros:

    • I don't have to pay gas for deploying any smart contracts

    Cons:

    • I have to keep track of multiple accounts

Which of these two approaches will cost me more gas? Intuitively I think 2nd would cost less gas because deploying smart contracts is more expensive than sending ETH. But the 1st approach seems to be the one that is more popular with exchanges. Why is that?

I should note that I don't expect users to deposit ETH more than once. (Or rather for each deposit I would give them a new address so it's easier to keep track of their deposits)

  • in #2 you have to pay gas for each transaction. – Nulik Sep 24 '18 at 22:31
  • deploying a contract is done only once, so you don't have to deploy a contract every time an account is added – Nulik Sep 24 '18 at 22:34
  • But since I want an unique address to each user, I have to deploy the contract once for each user, correct? – Juraj Petrik Sep 25 '18 at 9:41
  • I was reffering to a contract, that manages balances of accounts internally, and since internally you can do anything, you can generate a unique address for each user. – Nulik Sep 25 '18 at 12:27
1

Say I am an exchange that has many users. When I ask a user to deposit ETH I give him a unique address so I can attribute the ETH to him.

With Bitcoin this is easy. The bitcoin wallet software handles this and I can have BTC on multiple addresses and it's treated as one account.

I understand that with Ethereum this is different.

Not sure I understand what you are trying to achieve. If you want to let people deposit Ether into your contract, can't you simply maintain a mapping of addresses to balances? You would get the address of the sender with msg.sender

  • Let me describe it from a user experience POW. Each user is given an unique Ethereum address where he can deposit Ether. The Ether from all these addresses ends up in a single Ethereum address that I control. Does that make it clearer? – Juraj Petrik Sep 25 '18 at 9:40
  • It is unusually complicated this way. You should give to any user the same address to deposit, then to maintain in the contract their personal address, readed when they deposit, coupling to the address the current balance of that user. A simple mapping is enough. What is the meaning of giving different deposit address to different depositer when it is so simple to understand who is depositing what? – Rick Park Sep 25 '18 at 12:21
  • There is user in an off chain system let's say identified by his email. I want to ask this user to pay an invoice with ETH. I need a way to identify that this invoice has been paid. I don't want to ask the user for his ethereum address for UX reasons. If I give him a unique ETH address to send the ETH to, then once the ETH is sent to the address I know that I should credit this user in my off chain system. Makes sense? I also don't want to ask the user to call a contract and pass his email address, I want him to send a regular ETH transaction. – Juraj Petrik Sep 25 '18 at 19:34
0

You would a contract that create contracts. Your master contract creates new 'child wallets'for your users.

You can then have the children listen to a given owner that is created upon making the new wallet. That way they have a specific address that you control. If you want to just send the money instantly to your own wallet, you can just have one function in the new contract which is a fallback function that sends all the ETH to some given address.

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.