Assume I have a site and I want to give unique address to each of my users that generated by an HD wallet.
If each user, send a little amount to his/her address,that it was less than transaction fee, unlike Bitcoin, I can't spend them, by generate a transaction with multi input, I think it's so bad.
On the other hand, each contract has only one address, so I can't have a contract with multi address to give each address to each user. What is the best solution in Ethereum world?
- 22,269
- 6
- 62
- 127
- 123
- 7
1 Answers
Instead of deterministic payment addresses, you might want to use a smart contract for the payment.
There is only a single smart contract (address) where the payments go in (you can also deploy multiple contracts e.g. one per store, but this is a different question)
Each payment comes with a reference message in the Data field
Smart contract can automatically reject too small payments
I believe this is how Coinbase payment solution for Ethereum does it as well.
Here is an example Solidity smart contract that is close to your problem. It is a payment forwarder, so it checks that the reference message in each payment is correct:
https://github.com/TokenMarketNet/smart-contracts/blob/master/contracts/PaymentForwarder.sol#L74
Also, the user do not need to manually type in the reference messages like in wire transfers, because Ethereum interaction happens with a web3.js wallet like MetaMask and the website automatically fills the information for the user.
- 22,269
- 6
- 62
- 127
-
Thanks. So if we have a transaction from a wallet or a system that doesn't automatically fill any information, we can't know which one of our user sent amount to our contract right? I think I have to define a minimum amount for receiving, generate address with HD wallet, and finally send all of them to a main account. is this good idea? I know I lost some fee but it's safe to detect deposits. – Hamid Naghipour Jun 08 '20 at 11:00