繁体   English   中英

我试图测试这种流动性智能合约代码,但如果显示错误。 流动性类似于ocaml,tezos的智能合约语言。

[英]I am trying to test this liquidity smart contract code but if shows error. Liquidity is similar to ocaml, tezos's smart contract language.

我一直试图测试这个游戏的第一个切入点。 但是当它试图编译它时,会出现一些错误。 我该怎么办?或者我有什么遗失的东西?

[%%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)

你忘了初始化,添加这段代码:

let%init storage (oracle_id : address) =
  {game = (None : game option); oracle_id}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM