As I'm learning more and more about developing Dapps, I'm having trouble understanding what needs to be stored in the smart contract (over our database etc..).
Let's take the case of a simple betting website. The way I picture creating a Dapp of a betting website would be the following and please correct me if I'm wrong.
Technology Used: Ruby on Rails (Back-End), React (Front end), Solidity(Smart Contract)
1) I would store in my database the following informations :
- User (name, email, etc..)
- List of available bets
- List of user's bet
2) Upon creation of a user, I would create a new Ethereum Wallet with the same password as his credentials and store the public address of his wallet in the database.
3) I would store in the Smart Contract:
- ID of the user (from the database)
- ID of the bet (from the database)
- amount bet
- bet result/state
- user ethereum wallet address
- my website ethereum wallet address
- and the code to execute the transaction based on the bet result (win : transfer his winnings to the user wallet, lose : transfer his betting amount to my website wallet)
As a result, the smart contract would only contain information related to a betting transaction (bet results, amount bet) and the database will contain the rest. To retrieve a user's history of bets, I would retrieve the list from the database and retrieve the results from the smart contract (linked by the ID of the bet and user).
Am I completely misunderstanding the Dapps/Smart contract concept ? Please advise, thanks !!