I want to receive payments in my web-service in ethereum tokens, for example, Eos or Rep. And, of course, I must provide each user with different addresses for payment to determine who is the payer, so I create a new account and give an address to the user. After the payment has been received, I must send received tokens to the main account, but gas is needed for such transfer. What is the best way to receive ethereum erc-20 tokens in web-service?

2 Answers
2

If you want to receive ethers as payment. This is obviously the case like you will receive funds in different accounts and then transfer these ethers to your main account. You will definitely need gas for such transaction. But it depends on your requirements.

For transferring ethers the gas used by the transaction is 21,000. If you set gas price to 21GWei, the transaction will cost you 0.000441 Ether ($0.13, quoted from etherscan.io). So you have to spend $13 for every 100 users. This is not a big amount you should be worried about but again it depends on requirements of the product. I don't see this as a major concern.

The major issue arises when you start accepting erc-20 tokens as payment, in that case when you wish to transfer tokens from each user's address to your main account, each user account must have ethers (to pay for transaction fee), but users have only transferred tokens. This is the thing you should be worried about. One possible way is you ask users for tokens as well as few ethers (for transaction fee).

The other possible solution could be having a pool of fixed addresses and providing users with repeated addresses. In that case, you have to either ask the user for transaction hash or account from which they are willing to pay to identify user's payment. This solution has privacy concerns like anyone can track the funds that you are possessing from block explorers.

The reason behind this is the basic difference between bitcoin and ethereum architecture. Bitcoin was made to use as currency but ethereum has much more to offer. That is why this implementation is quite easy in bitcoin but not in case of ethereum. I am not sure, whether there any merchant API's available for integrating erc-20 tokens as the payment method.

PS: The question asks for the best way. If somebody has the better solution, I'll love to hear that. Please edit the answer if this needs updation/modification.

Hi may be its late for your case,
but it might help for others, you can solve this by create a simple smart contract(if normal account, you will need to have eth to pay fee when you want to collect eth/token to the main account) to receive eth/token for each user. since user deposit into this, an event will be trigger and from here, an owner/admin account(this guy pay fee) will do the call the collection.
hope this help!