I am ultra beginner in Sophia and Blockchain in general. I would like to create my own smart contract based by a gamble game named satoshi dice. I start writing the contract and get some errors. but first I would like to know if this contract that I create is logic or not. I mean by logic if the syntax errors that I met are few. and Thanks
contract SatoshiDice =
record Bet = {
user : address,
block : int,
cap : int,
amount : int}
FEE_NUMERATOR = 1;
FEE_DENOMINATOR = 100;
MAXIMUM_CAP = 100000;
MAXIMUM_BET_SIZE : 100000000;
owner : address;
counter = 0; *// I want to make this a int and be public*
bets : map(int, Bet) *// also those bets must be public*
datatype event =
BetPlaced(id int, user address, cap int, amount int);
| Roll(id int, rolled int); *//Here I mean the two events ,this syntax is true?*
entrypoint SatoshiDice() =
owner = Call.caller;
payable stateful entrypoint wager(cap : int)=
require(cap <= MAXIMUM_CAP);
require(Call.value <= MAXIMUM_BET_SIZE);
counter++;
bets[counter] = Bet(Call.caller, block.number + 3, cap, Call.value);
BetPleaced(counter, Call.caller, cap, Call.value);
stateful entrypoint roll(id : int)=
Bet storage bet = bets[id];
require(Call.caller == bet.user);
require(block.number >= bet.block);
bytes(32) random = String.sha3(block.blockhsh(bet.block), id);
int rolled = Bytes.to_int(random) % MAXIMUM_CAP;
if(rolled < bet.cap)
payout = bet.amount * MAXIMUM_CAP / bet.cap;
fee = payout * FEE_NUMERATOR / FEE_DENOMINATOR;
payout -= fee;
transfer_item(payout);
Roll(id,rolled);
delete bets[id];
payable stateful entrypoint()