Hi @FrankB
As you are modifying the state of your contract you should use send instead of call
contractInstance.methods.sendMoney(customerAddress, gain).send({from: owner}).then(function(transferAmount){
There is a logical issue in your Dapp, why the random function and the sendMoney are callable only by the owner âonlyOwnerâ ?
If someone else than the contract owner is playing this function will be reverted .
The owner is playing then he is supposed to send ETH to a customer ?
Split your function into smaller functions, your submitAndPlay is too big and confusing, all the code inside your callback should be inside separate functions.
Finally the random function is working fine with
now()%2
As itâs taking the timestamp when a block is mined, it will produce 1 or 0.
Your way of generating a random number is interesting but you canât let the user choose for this number.
Keep in mind that the user is able to modify the frontend code of your Dapp.
Inside the console
encoding
"RETEEssdf34fgdcccvv565(some random string)"
encoding = 0
0
Now you will pass date + 0 to your random function and do a module 10 on it. So i just have to create a javascript function which call your submitAndPlay function when i am able to win. Itâs really easy to broke.
This is not secure at all, all the operation have to be done inside your smart contract and not in your frontend
An other point, why arenât you using the accounts[0] value instead of asking the user to enter his own address ?