I want to create a smart contract which will allow multiple users to deposit / withdraw funds. My first approach was to simply have one contract address which will store the funds of all users and a mapping which will track individual balances of each of the users, however this would prevent me from being able to identify deposits for particular users, as they would all be depositing to the same address.

In order to overcome this, I want the smart contract to generate a child contract for each user to which that user can deposit funds to. The problem is that deploying this child contract will cost gas. I don't want the user to pay this gas cost, however if I have the parent contract refund the users gas costs, a potential attack arises when someone can create multiple accounts in order to have the contract spend it's whole balance on this task. How can I overcome this?

1 Answer 1


Your first idea was the best, but the following assessment is leading you astray:

however this would prevent me from being able to identify deposits for particular users

Identifying who sent what is precisely what the mapping (and event logs) allow you to do.

What you do with that information relates to undisclosed details of the use-case. Possibly there is an implementation detail with a non-obvious solution?

  • 1
    Well yes, so I want people to have an account with a username / password and be able to deposit from any arbitrary address (exchange, coinbase, wallet etc)... Following the ethcrash model if you're familiar with that, therefore identifying the multiple accounts which one user can deposit from wouldn't be possible using just a single contract for all transactions.
    – mankee
    Commented Jun 1, 2018 at 19:33

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.