[Ethereum] Automatic ERC20 Token Payment System – How to

erc-20payments

Before starting to detail my problem, I must say that I am new to ERC20 Tokens and I write this question in ask for guidance.

Is it possible that I can forge a payment system on an ERC20 token?

What I want to do is somehow automatize the Send Ether & Tokens procedure from MyEtherWallet.

The scenario is the following : Let's say that I have a trading platform. User A is the producer of a random product and user B is the client that wants to buy the product. How can I make the users pay using an ERC20 token on a single click ( buy button ), and moreover, how can I do this automatically?

Any kind of help/guidance is really appreciated.

Thank you!

Best Answer

You cannot do this with fewer than 2 clicks, but you can do it with 2.

If your trading platform is a web site, and users are using (or can be persuaded to use) MetaMask (or similar, such as Mist, Toshi, Parity Browser or SpaceSuit), then you can request a payment from within the trading platform, using a JavaScript library (such as Web3, or truffle-contract, or EthJS) to call transfer on the ERC20 token. They would click "Buy" on your site, then the plugin would ask them to confirm the amount and transaction details.

If your users would like future payments to be automated, ERC20 contracts have an approve method, that can be used approve an address to make future withdrawals (which can be limited to a certain amount), so the user would not need to take any further action after the initial approval.

Related Topic