17 | | - | func i (g,h) = (((g + "_") + toString(h)) + "_txid") |
---|
18 | | - | |
---|
19 | | - | |
---|
20 | | - | func j (g,h) = (((g + "_") + toString(h)) + "_fh") |
---|
21 | | - | |
---|
22 | | - | |
---|
23 | | - | func k (g,h) = (((g + "_") + toString(h)) + "_di") |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | func l (m) = { |
---|
27 | | - | let n = { |
---|
28 | | - | let o = getInteger(this, m) |
---|
29 | | - | if ($isInstanceOf(o, "Int")) |
---|
30 | | - | then { |
---|
31 | | - | let p = o |
---|
32 | | - | p |
---|
33 | | - | } |
---|
34 | | - | else 0 |
---|
35 | | - | } |
---|
36 | | - | n |
---|
37 | | - | } |
---|
38 | | - | |
---|
39 | | - | |
---|
40 | | - | func q (r,s,t,u) = { |
---|
41 | | - | let v = value(blockInfoByHeight((t - 1))) |
---|
42 | | - | let w = sha256((s + value(v.vrf))) |
---|
43 | | - | (toInt(w, (u * 8)) % r) |
---|
44 | | - | } |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | func x (s,t) = { |
---|
48 | | - | let y = q(2, s, t, 0) |
---|
49 | | - | if ((y == 0)) |
---|
50 | | - | then "type1" |
---|
51 | | - | else "type2" |
---|
52 | | - | } |
---|
53 | | - | |
---|
54 | | - | |
---|
55 | | - | @Callable(z) |
---|
56 | | - | func startAssetGaming () = { |
---|
57 | | - | let A = value(z.payments[0]) |
---|
58 | | - | let h = l(a) |
---|
59 | | - | [IntegerEntry(f(toString(z.caller), h), d), StringEntry(i(toString(z.caller), h), toBase58String(z.transactionId)), IntegerEntry(j(toString(z.caller), h), (height + c)), IntegerEntry(a, (h + 1))] |
---|
60 | | - | } |
---|
61 | | - | |
---|
62 | | - | |
---|
63 | | - | |
---|
64 | | - | @Callable(z) |
---|
65 | | - | func finishAssetGaming (h) = { |
---|
66 | | - | let B = f(toString(z.caller), h) |
---|
67 | | - | let C = j(toString(z.caller), h) |
---|
68 | | - | let D = k(toString(z.caller), h) |
---|
69 | | - | let E = i(toString(z.caller), h) |
---|
70 | | - | let F = l(B) |
---|
71 | | - | let t = getIntegerValue(this, C) |
---|
72 | | - | let G = fromBase58String(getStringValue(this, E)) |
---|
73 | | - | if ((F == e)) |
---|
74 | | - | then { |
---|
75 | | - | let H = getStringValue(this, k(toString(z.caller), h)) |
---|
76 | | - | throw(("The asset was gamed and claimed already, here is the folowing: " + H)) |
---|
77 | | - | } |
---|
78 | | - | else if ((t > height)) |
---|
79 | | - | then throw((((("Gaming is not finished yet " + toString((t - height))) + " blocks remaining, it will take around ") + toString((t - height))) + " minutes")) |
---|
80 | | - | else { |
---|
81 | | - | let I = x(G, t) |
---|
82 | | - | let J = Issue(I, I, 1, 0, false, unit, t) |
---|
83 | | - | let H = calculateAssetId(J) |
---|
84 | | - | [IntegerEntry(B, e), StringEntry(D, toBase58String(H)), StringEntry(toBase58String(H), D), J, ScriptTransfer(z.caller, 1, H)] |
---|
85 | | - | } |
---|
86 | | - | } |
---|
| 6 | + | @Callable(a) |
---|
| 7 | + | func startAssetGaming () = [ScriptTransfer(a.caller, 1, unit)] |
---|