hello,
thanks finally i got the eth on metamask ropsten network.
I get the same mistake when migrating as in the other post you are helping me with, so some error with the constructor
"coin" hit a require or revert statement somewhere in its constructor. Try:
* Verifying that your constructor params satisfy all require conditions.
* Adding reason strings to your require statements.
this is the contract
import"./Ownable.sol";
import"./provableAPI.sol";
pragma solidity 0.5.16;
contract coin is Ownable, usingProvable{
struct player {
uint amount; // amount the player want to bet in ether
uint bet; // what the player want to bet: 0 or 1
address payable playerAddress; // address of the player
string message; // message after flip: WIN or LOSE
uint result; // result of the coin flip returned from provable
}
uint public balance; // updated balance of the contract
uint public minBet; // minimum bet set by the owner
uint256 constant NUM_RANDOM_BYTES_REQUESTED = 1;
bytes32 queryId;
event logNewProvableQuery(string description);
event generateRandomNumber(uint256 randomNumber);
modifier costs(uint cost){
require(msg.value >= cost);
_;
}
// owner send money to the contract at the moment of deployment
constructor() public payable{
require(msg.value >= 1000000);
balance += msg.value;
}
mapping (address => player) private players; // link player to his address
mapping (bytes32 => player) private playerId; // link player to his queryId
mapping (address => bool) private waiting; // link player to his waiting status: true or false
// player set his bet (0 or 1), his bet amount and send that amount to the contract
function setBet(uint amount, uint bet) public payable costs( (players[msg.sender].amount)*1000000000000000000 ){
require(waiting[msg.sender] = false); // player which is waiting for bet result can't bet before to know the result
waiting[msg.sender] = true; // once th player set the bet his waiting status is set to true
player memory newPlayer;
newPlayer.amount = amount;
newPlayer.bet = bet;
newPlayer.playerAddress = msg.sender;
insertPlayer(newPlayer); // players[msg.sender] = newPlayer
// require that the amount bet is lower than half balance
require((players[msg.sender].amount)*1000000000000000000 <= balance/2, "Bet over contract funds");
balance += msg.value;
update();
playerId[queryId] = newPlayer;
}
function __callback(bytes32 _queryId, string memory _result, bytes memory proof) public {
require(msg.sender == provable_cbAddress()); //l'address deve essere quello dell'oracle
uint256 randomNumber = uint256(keccak256(abi.encodePacked(_result))) % 2;
emit generateRandomNumber(randomNumber);
if(randomNumber == (playerId[_queryId].bet)){
balance = balance - (playerId[_queryId].amount)*1000000000000000000*2;
playerId[_queryId].playerAddress.transfer( (playerId[_queryId].amount)*1000000000000000000*2 );
players[playerId[_queryId].playerAddress].message = "WIN";
players[playerId[_queryId].playerAddress].result = randomNumber;
}
else{
players[playerId[_queryId].playerAddress].message = "LOSE";
players[playerId[_queryId].playerAddress].result = randomNumber;
}
waiting[playerId[_queryId].playerAddress] = false;
}
function update() payable public {
uint256 QUERY_EXECUTION_DELAY = 0;
uint256 GAS_FOR_CALLBACK = 20000;
queryId = provable_newRandomDSQuery(
QUERY_EXECUTION_DELAY,
NUM_RANDOM_BYTES_REQUESTED,
GAS_FOR_CALLBACK
);
emit logNewProvableQuery("Provable query was sent, standing by for answer");
}
function getResult() public view returns(uint amount, uint bet, string memory message, uint result){
address creator = msg.sender;
return (players[creator].amount, players[creator].bet, players[creator].message, players[creator].result);
}
// only owner can set the minimum bet
function minimumBet(uint minimum) public onlyOwner {
minBet = minimum;
}
// only owner can withdraw money
function withdrawFunds(uint withdraw) public onlyOwner {
balance = balance - withdraw*1000000000000000000;
msg.sender.transfer(withdraw*1000000000000000000);
}
function insertPlayer(player memory newPlayer) private {
address creator = msg.sender;
players[creator] = newPlayer;
}
}
in this case the constructor is sending much less than 1 eth but still there is the error (in metamask I have 1 eth)