我一直在尝试测试该游戏的第一个入口点。但是,当它尝试编译它时,会显示一些错误。我该如何进行或缺少什么?
[%%version 0.4]
type game = {
number : nat;
bet : tez;
player : key_hash;
}
type storage = {
game : game option;
oracle_id : address;
}
let%entry play (number : nat) storage =
if number>100p then Current.failwith "number must be <=100";
if 2p.Current.amount()>Current.balance() then Current.failwith"less balance";
match storage.game with
|some g -> failwith ("game has already started",g)
|None ->
let bet = Current.amount() in
let storage = storage.game <- Some {number, bet, player} in
(([]:operation list),storage)
答案 0 :(得分:8)
您忘记初始化,请添加以下代码:
let%init storage (oracle_id : address) =
{game = (None : game option); oracle_id}