tx · AMTmWknLTqJmBSgN7jgk2LLmvqVpDTpgciCkWMSgbXzW 3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea: -0.00900000 Waves 2022.08.18 21:11 [2190263] smart account 3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea > SELF 0.00000000 Waves
{ "type": 13, "id": "AMTmWknLTqJmBSgN7jgk2LLmvqVpDTpgciCkWMSgbXzW", "fee": 900000, "feeAssetId": null, "timestamp": 1660846313384, "version": 2, "chainId": 84, "sender": "3MxbD7vwyGjwsRxT8fmMB9fngo59VfHcrea", "senderPublicKey": "7kBiESqWjiW6nNeStcbrVX9XRQkWmUM51MZFRZNQEVfR", "proofs": [ "3xzRtVs6iJ3BwPUjRBgAKXk5Jvy7dwA7YZJTBes9WLay2BkxgYLHBrAjbdAaWsLaGgwMnFqddGQCpS2QrPdczwSr" ], "script": "base64:AAIFAAAAAAAAABEIAhIDCgEBEgMKAQgSAwoBCAAAAAgAAAAABWFkbWluAQAAABoBVNjzO1N+o4TglJtDoCbGH7hRDlWj6ppSJAAAAAALY29hbEFzc2V0SWQBAAAAIDHg1fVAt3Hphex6Dm+3r1K6I7ymQhydmjuZJeiJho7mAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIAAAAAAAAAAAABAAAADXRyeUdldEJvb2xlYW4AAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBsAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAB0Jvb2xlYW4EAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIHAQAAAA5nZXRBc3NldFN0cmluZwAAAAEAAAAHYXNzZXRJZAQAAAAHJG1hdGNoMAUAAAAHYXNzZXRJZAMJAAABAAAAAgUAAAAHJ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spentComplexity": 0 } View: original | compacted Prev: 4sxfrA26HCjTiS8nvLZm596VCGSzNukBUEzGvAPXbu5G Next: none Diff:
Old | New | Differences | |
---|---|---|---|
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | - | @Callable(g) | |
20 | - | func mintNazi () = { | |
21 | - | let h = toBase58String(g.caller.bytes) | |
22 | - | let i = c(("lastMint_" + h)) | |
23 | - | if (if ((i > 0)) | |
24 | - | then ((i + 5) > height) | |
25 | - | else false) | |
26 | - | then throw("You need to wait 5 blocks after last mint") | |
27 | - | else [IntegerEntry(("lastMint_" + h), height), Reissue(b, 1, true), ScriptTransfer(g.caller, 1, b)] | |
19 | + | func g (d) = { | |
20 | + | let e = getBoolean(this, d) | |
21 | + | if ($isInstanceOf(e, "Boolean")) | |
22 | + | then { | |
23 | + | let f = e | |
24 | + | f | |
25 | + | } | |
26 | + | else false | |
28 | 27 | } | |
29 | 28 | ||
30 | 29 | ||
31 | - | @Verifier(j) | |
32 | - | func k () = sigVerify(j.bodyBytes, j.proofs[0], j.senderPublicKey) | |
30 | + | func h (i) = { | |
31 | + | let e = i | |
32 | + | if ($isInstanceOf(e, "ByteVector")) | |
33 | + | then { | |
34 | + | let f = e | |
35 | + | toBase58String(f) | |
36 | + | } | |
37 | + | else "WAVES" | |
38 | + | } | |
39 | + | ||
40 | + | ||
41 | + | func j (d) = { | |
42 | + | let e = getString(this, d) | |
43 | + | if ($isInstanceOf(e, "String")) | |
44 | + | then { | |
45 | + | let f = e | |
46 | + | f | |
47 | + | } | |
48 | + | else "" | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func k (d) = { | |
53 | + | let e = getBinary(this, d) | |
54 | + | if ($isInstanceOf(e, "ByteVector")) | |
55 | + | then { | |
56 | + | let f = e | |
57 | + | f | |
58 | + | } | |
59 | + | else base58'' | |
60 | + | } | |
61 | + | ||
62 | + | ||
63 | + | func l (m) = if ((m == "WAVES")) | |
64 | + | then unit | |
65 | + | else fromBase58String(m) | |
66 | + | ||
67 | + | ||
68 | + | @Callable(n) | |
69 | + | func createFurnace (o) = if ((toBase58String(n.caller.bytes) != toBase58String(a))) | |
70 | + | then throw("You cannot create furnace") | |
71 | + | else if ((size(n.payments) != 1)) | |
72 | + | then throw("You should to provide reward") | |
73 | + | else { | |
74 | + | let p = n.payments[0].amount | |
75 | + | let q = n.payments[0].assetId | |
76 | + | let r = (c("global_furnacesAmount") + 1) | |
77 | + | let s = toString(r) | |
78 | + | [IntegerEntry("global_furnacesAmount", r), IntegerEntry((("furnace_" + s) + "_lifetime"), o), IntegerEntry((("furnace_" + s) + "_rewardAmount"), p), StringEntry((("furnace_" + s) + "_rewardAssetId"), h(q))] | |
79 | + | } | |
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | @Callable(n) | |
84 | + | func burn (s) = { | |
85 | + | let t = g((("furnace_" + s) + "_finished")) | |
86 | + | let o = c((("furnace_" + s) + "_lifetime")) | |
87 | + | let u = c((("furnace_" + s) + "_lastBurn")) | |
88 | + | let v = (u + o) | |
89 | + | if (t) | |
90 | + | then throw("Already finished") | |
91 | + | else if ((o == 0)) | |
92 | + | then throw("Cannot find furnace") | |
93 | + | else if (if ((u > 0)) | |
94 | + | then (height >= v) | |
95 | + | else false) | |
96 | + | then throw("Time is run out") | |
97 | + | else if ((size(n.payments) != 1)) | |
98 | + | then throw("You should to provide payment") | |
99 | + | else if ((n.payments[0].assetId != b)) | |
100 | + | then throw("Invalid coal") | |
101 | + | else if ((n.payments[0].amount != 1)) | |
102 | + | then throw("You can burn only 1 coal") | |
103 | + | else { | |
104 | + | let w = toBase58String(n.caller.bytes) | |
105 | + | [Burn(b, n.payments[0].amount), IntegerEntry((("furnace_" + s) + "_lastBurn"), height), StringEntry((("furnace_" + s) + "_lastStoker"), w)] | |
106 | + | } | |
107 | + | } | |
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | @Callable(n) | |
112 | + | func claim (s) = { | |
113 | + | let t = g((("furnace_" + s) + "_finished")) | |
114 | + | let o = c((("furnace_" + s) + "_lifetime")) | |
115 | + | let u = c((("furnace_" + s) + "_lastBurn")) | |
116 | + | let x = j((("furnace_" + s) + "_rewardAssetId")) | |
117 | + | let y = j((("furnace_" + s) + "_lastStoker")) | |
118 | + | let p = c((("furnace_" + s) + "_rewardAmount")) | |
119 | + | let z = (u + o) | |
120 | + | if (t) | |
121 | + | then throw("Already finished") | |
122 | + | else if ((o == 0)) | |
123 | + | then throw("Cannot find furnace") | |
124 | + | else if ((u == 0)) | |
125 | + | then throw("Furnace not found") | |
126 | + | else if ((z > height)) | |
127 | + | then throw("Time has not run out") | |
128 | + | else if ((x == "")) | |
129 | + | then throw("Cannot find reward asset") | |
130 | + | else if ((y == "")) | |
131 | + | then throw("Cannot find last stoker") | |
132 | + | else if ((p == 0)) | |
133 | + | then throw("Reward already sent to winner") | |
134 | + | else [BooleanEntry((("furnace_" + s) + "_finished"), true), ScriptTransfer(Address(fromBase58String(y)), p, l(x))] | |
135 | + | } | |
136 | + | ||
137 | + | ||
138 | + | @Verifier(A) | |
139 | + | func B () = sigVerify(A.bodyBytes, A.proofs[0], A.senderPublicKey) | |
33 | 140 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = base58'3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR' | |
5 | 5 | ||
6 | 6 | let b = base58'4MhpjsP1MPpC49v6zBr7eAAEPZdmHWcrSqcSv8tZcpjo' | |
7 | 7 | ||
8 | 8 | func c (d) = { | |
9 | 9 | let e = getInteger(this, d) | |
10 | 10 | if ($isInstanceOf(e, "Int")) | |
11 | 11 | then { | |
12 | 12 | let f = e | |
13 | 13 | f | |
14 | 14 | } | |
15 | 15 | else 0 | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | - | @Callable(g) | |
20 | - | func mintNazi () = { | |
21 | - | let h = toBase58String(g.caller.bytes) | |
22 | - | let i = c(("lastMint_" + h)) | |
23 | - | if (if ((i > 0)) | |
24 | - | then ((i + 5) > height) | |
25 | - | else false) | |
26 | - | then throw("You need to wait 5 blocks after last mint") | |
27 | - | else [IntegerEntry(("lastMint_" + h), height), Reissue(b, 1, true), ScriptTransfer(g.caller, 1, b)] | |
19 | + | func g (d) = { | |
20 | + | let e = getBoolean(this, d) | |
21 | + | if ($isInstanceOf(e, "Boolean")) | |
22 | + | then { | |
23 | + | let f = e | |
24 | + | f | |
25 | + | } | |
26 | + | else false | |
28 | 27 | } | |
29 | 28 | ||
30 | 29 | ||
31 | - | @Verifier(j) | |
32 | - | func k () = sigVerify(j.bodyBytes, j.proofs[0], j.senderPublicKey) | |
30 | + | func h (i) = { | |
31 | + | let e = i | |
32 | + | if ($isInstanceOf(e, "ByteVector")) | |
33 | + | then { | |
34 | + | let f = e | |
35 | + | toBase58String(f) | |
36 | + | } | |
37 | + | else "WAVES" | |
38 | + | } | |
39 | + | ||
40 | + | ||
41 | + | func j (d) = { | |
42 | + | let e = getString(this, d) | |
43 | + | if ($isInstanceOf(e, "String")) | |
44 | + | then { | |
45 | + | let f = e | |
46 | + | f | |
47 | + | } | |
48 | + | else "" | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func k (d) = { | |
53 | + | let e = getBinary(this, d) | |
54 | + | if ($isInstanceOf(e, "ByteVector")) | |
55 | + | then { | |
56 | + | let f = e | |
57 | + | f | |
58 | + | } | |
59 | + | else base58'' | |
60 | + | } | |
61 | + | ||
62 | + | ||
63 | + | func l (m) = if ((m == "WAVES")) | |
64 | + | then unit | |
65 | + | else fromBase58String(m) | |
66 | + | ||
67 | + | ||
68 | + | @Callable(n) | |
69 | + | func createFurnace (o) = if ((toBase58String(n.caller.bytes) != toBase58String(a))) | |
70 | + | then throw("You cannot create furnace") | |
71 | + | else if ((size(n.payments) != 1)) | |
72 | + | then throw("You should to provide reward") | |
73 | + | else { | |
74 | + | let p = n.payments[0].amount | |
75 | + | let q = n.payments[0].assetId | |
76 | + | let r = (c("global_furnacesAmount") + 1) | |
77 | + | let s = toString(r) | |
78 | + | [IntegerEntry("global_furnacesAmount", r), IntegerEntry((("furnace_" + s) + "_lifetime"), o), IntegerEntry((("furnace_" + s) + "_rewardAmount"), p), StringEntry((("furnace_" + s) + "_rewardAssetId"), h(q))] | |
79 | + | } | |
80 | + | ||
81 | + | ||
82 | + | ||
83 | + | @Callable(n) | |
84 | + | func burn (s) = { | |
85 | + | let t = g((("furnace_" + s) + "_finished")) | |
86 | + | let o = c((("furnace_" + s) + "_lifetime")) | |
87 | + | let u = c((("furnace_" + s) + "_lastBurn")) | |
88 | + | let v = (u + o) | |
89 | + | if (t) | |
90 | + | then throw("Already finished") | |
91 | + | else if ((o == 0)) | |
92 | + | then throw("Cannot find furnace") | |
93 | + | else if (if ((u > 0)) | |
94 | + | then (height >= v) | |
95 | + | else false) | |
96 | + | then throw("Time is run out") | |
97 | + | else if ((size(n.payments) != 1)) | |
98 | + | then throw("You should to provide payment") | |
99 | + | else if ((n.payments[0].assetId != b)) | |
100 | + | then throw("Invalid coal") | |
101 | + | else if ((n.payments[0].amount != 1)) | |
102 | + | then throw("You can burn only 1 coal") | |
103 | + | else { | |
104 | + | let w = toBase58String(n.caller.bytes) | |
105 | + | [Burn(b, n.payments[0].amount), IntegerEntry((("furnace_" + s) + "_lastBurn"), height), StringEntry((("furnace_" + s) + "_lastStoker"), w)] | |
106 | + | } | |
107 | + | } | |
108 | + | ||
109 | + | ||
110 | + | ||
111 | + | @Callable(n) | |
112 | + | func claim (s) = { | |
113 | + | let t = g((("furnace_" + s) + "_finished")) | |
114 | + | let o = c((("furnace_" + s) + "_lifetime")) | |
115 | + | let u = c((("furnace_" + s) + "_lastBurn")) | |
116 | + | let x = j((("furnace_" + s) + "_rewardAssetId")) | |
117 | + | let y = j((("furnace_" + s) + "_lastStoker")) | |
118 | + | let p = c((("furnace_" + s) + "_rewardAmount")) | |
119 | + | let z = (u + o) | |
120 | + | if (t) | |
121 | + | then throw("Already finished") | |
122 | + | else if ((o == 0)) | |
123 | + | then throw("Cannot find furnace") | |
124 | + | else if ((u == 0)) | |
125 | + | then throw("Furnace not found") | |
126 | + | else if ((z > height)) | |
127 | + | then throw("Time has not run out") | |
128 | + | else if ((x == "")) | |
129 | + | then throw("Cannot find reward asset") | |
130 | + | else if ((y == "")) | |
131 | + | then throw("Cannot find last stoker") | |
132 | + | else if ((p == 0)) | |
133 | + | then throw("Reward already sent to winner") | |
134 | + | else [BooleanEntry((("furnace_" + s) + "_finished"), true), ScriptTransfer(Address(fromBase58String(y)), p, l(x))] | |
135 | + | } | |
136 | + | ||
137 | + | ||
138 | + | @Verifier(A) | |
139 | + | func B () = sigVerify(A.bodyBytes, A.proofs[0], A.senderPublicKey) | |
33 | 140 |
github/deemru/w8io/169f3d6 35.62 ms ◑