Hey @KryptoS
Some things to think about ![:slight_smile: :slight_smile:](https://forum.ivanontech.com/images/emoji/twitter/slight_smile.png?v=9)
function initalDepositToContract()
I am not sure this function is useful.
Also you do not have a deposit function, which means that you are using initalDepositToContract
during your migration but it cannot be used to deposit ether because of what the function does:
function initalDepositToContract() public payable{
contractBalance = address(this).balance;
}
It would be better to write a function deposit and use that one.
function deposit() public payable {
contractBalance += msg.value;
}
You have a modifier:
modifier costs(uint cost){
require(msg.value >= cost);
_;
}
but then you also require (contractBalance > 2*msg.value);
in your function playFlipCoin()
, the modifier can be improved:
modifier costs(uint cost){
require (contractBalance > 2*msg.value);
_;
}
Or if you also want to set a minimum bet amount, you can also include it in your modifier
modifier costs(uint cost){
require (contractBalance > 2*msg.value && msg.value >= cost);
_;
}
This function:
function resetPlayerStatus() internal {
address creator = msg.sender;
players[creator].countWin = 0;
players[creator].sumWin = 0;
players[creator].countLost = 0;
players[creator].isActive = false;
players[creator].coinSide = 0;
players[creator].betAmount = 0;
}
Can be simplified:
function resetPlayerStatus() internal {
delete(players[msg.sender]);
}
Happy coding and congrats for your 1st dapp ![:slight_smile: :slight_smile:](https://forum.ivanontech.com/images/emoji/twitter/slight_smile.png?v=9)
Dani