Please read some useful posts first:
- Issue your ERC20 token with Solidity on Ethereum Blockchain [https://medium.com/p/6e640eb613ff]
- SmartContract ICO Crowdsale simple [https://medium.com/p/35dc5ff02459]
In this demo, I use web3 version 1.0.0-beta.33, solidity 0.4.21. We can implement on frontend or backend separately.
We can implement on server, all request from client must send to server handle. But the limitation is server must have private key of wallet to sign transaction and sending.
Implement on frontend only using Metamask provider for payment. But the limitation is Metamask not support for subscribe event emit from Ethereum network.
Implement both on frontend and backend also, connect its by socket.io and use backend listen event and transit to frontend.
My demo project just stop at a haft of Approach 3. It implement on both frontend and backend also, listen event on backend but not implement socket communication to send event to frontend. It can be easy. But I don’t have VPS so to deploy backend, so I wont. Do it yourself 😀
Simple smart contract source