tx · 6Td6sXKS2z8xyu3MAiLg3A4Uffs6o3pHdQMvhdTc7g1Y

3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR:  -0.01400000 Waves

2022.08.18 21:10 [2190262] smart account 3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR > SELF 0.00000000 Waves

{ "type": 13, "id": "6Td6sXKS2z8xyu3MAiLg3A4Uffs6o3pHdQMvhdTc7g1Y", "fee": 1400000, "feeAssetId": null, "timestamp": 1660846285530, "version": 2, "chainId": 84, "sender": "3N9hD7PnazZB7wbwFmr7fw28UKXj593YmTR", "senderPublicKey": "FpRE1aaMXMppRqybhnDRqxp6bkwMczDupk9vbqJHddyr", "proofs": [ "2oEP46B4pv72zTK2QjBBZKpKiEAdcGSFYbYsok6187J4jsVJeNUXPGEa37t4J79s6YgVAwYSHJtyVGQ8inR3Uoz7" ], "script": null, "height": 2190262, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: cVKR6ECmRVLz7wY73EKrDqFqqTxB1pnznVpfhhZ4ppe Next: none Full:
OldNewDifferences
1-{-# STDLIB_VERSION 5 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let admin = base58'3MxZPzVdHQYNjp99N7VRuR4RLmJUqnDg9ok'
5-
6-let coalAssetId = base58'4MhpjsP1MPpC49v6zBr7eAAEPZdmHWcrSqcSv8tZcpjo'
7-
8-func tryGetInteger (key) = match getInteger(this, key) {
9- case b: Int =>
10- b
11- case _ =>
12- 0
13-}
14-
15-
16-func tryGetBoolean (key) = match getBoolean(this, key) {
17- case b: Boolean =>
18- b
19- case _ =>
20- false
21-}
22-
23-
24-func getAssetString (assetId) = match assetId {
25- case b: ByteVector =>
26- toBase58String(b)
27- case _ =>
28- "WAVES"
29-}
30-
31-
32-func tryGetString (key) = match getString(this, key) {
33- case b: String =>
34- b
35- case _ =>
36- ""
37-}
38-
39-
40-func tryGetBinary (key) = match getBinary(this, key) {
41- case b: ByteVector =>
42- b
43- case _ =>
44- base58''
45-}
46-
47-
48-func getAssetBytes (assetIdStr) = if ((assetIdStr == "WAVES"))
49- then unit
50- else fromBase58String(assetIdStr)
51-
52-
53-@Callable(i)
54-func createFurnace (lifetime) = if ((toBase58String(i.caller.bytes) != toBase58String(admin)))
55- then throw("You cannot create furnace")
56- else if ((size(i.payments) != 1))
57- then throw("You should to provide reward")
58- else {
59- let rewardAmount = i.payments[0].amount
60- let rewardAssetId = i.payments[0].assetId
61- let newFurnacesAmount = (tryGetInteger("global_furnacesAmount") + 1)
62- let furnaceId = toString(newFurnacesAmount)
63-[IntegerEntry("global_furnacesAmount", newFurnacesAmount), IntegerEntry((("furnace_" + furnaceId) + "_lifetime"), lifetime), IntegerEntry((("furnace_" + furnaceId) + "_rewardAmount"), rewardAmount), StringEntry((("furnace_" + furnaceId) + "_rewardAssetId"), getAssetString(rewardAssetId))]
64- }
65-
66-
67-
68-@Callable(i)
69-func burn (furnaceId) = {
70- let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished"))
71- let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime"))
72- let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn"))
73- let finisHeight = (lastBurn + lifetime)
74- if (isFinished)
75- then throw("Already finished")
76- else if ((lifetime == 0))
77- then throw("Cannot find furnace")
78- else if (if ((lastBurn > 0))
79- then (height >= finisHeight)
80- else false)
81- then throw("Time is run out")
82- else if ((size(i.payments) != 1))
83- then throw("You should to provide payment")
84- else if ((i.payments[0].assetId != coalAssetId))
85- then throw("Invalid coal")
86- else if ((i.payments[0].amount != 1))
87- then throw("You can burn only 1 coal")
88- else {
89- let callerAddress = toBase58String(i.caller.bytes)
90-[Burn(coalAssetId, i.payments[0].amount), IntegerEntry((("furnace_" + furnaceId) + "_lastBurn"), height), StringEntry((("furnace_" + furnaceId) + "_lastStoker"), callerAddress)]
91- }
92- }
93-
94-
95-
96-@Callable(i)
97-func claim (furnaceId) = {
98- let isFinished = tryGetBoolean((("furnace_" + furnaceId) + "_finished"))
99- let lifetime = tryGetInteger((("furnace_" + furnaceId) + "_lifetime"))
100- let lastBurn = tryGetInteger((("furnace_" + furnaceId) + "_lastBurn"))
101- let rewardAsset = tryGetString((("furnace_" + furnaceId) + "_rewardAssetId"))
102- let lastStoker = tryGetString((("furnace_" + furnaceId) + "_lastStoker"))
103- let rewardAmount = tryGetInteger((("furnace_" + furnaceId) + "_rewardAmount"))
104- let finishHeight = (lastBurn + lifetime)
105- if (isFinished)
106- then throw("Already finished")
107- else if ((lifetime == 0))
108- then throw("Cannot find furnace")
109- else if ((lastBurn == 0))
110- then throw("Furnace not found")
111- else if ((finishHeight > height))
112- then throw("Time has not run out")
113- else if ((rewardAsset == ""))
114- then throw("Cannot find reward asset")
115- else if ((lastStoker == ""))
116- then throw("Cannot find last stoker")
117- else if ((rewardAmount == 0))
118- then throw("Reward already sent to winner")
119- else [BooleanEntry((("furnace_" + furnaceId) + "_finished"), true), ScriptTransfer(Address(fromBase58String(lastStoker)), rewardAmount, getAssetBytes(rewardAsset))]
120- }
121-
122-
123-@Verifier(tx)
124-func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
125-
1+# no script

github/deemru/w8io/03bedc9 
27.25 ms