tx · DBKHQbpqy3hPAy3BuFh3muybWBLHSRjd9XADWRMDmuy7

3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs:  -0.01000000 Waves

2023.08.29 10:58 [2731717] smart account 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs > SELF 0.00000000 Waves

{ "type": 13, "id": "DBKHQbpqy3hPAy3BuFh3muybWBLHSRjd9XADWRMDmuy7", "fee": 1000000, "feeAssetId": null, "timestamp": 1693296006053, "version": 2, "chainId": 84, "sender": "3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs", "senderPublicKey": "8yQuxvQ2qLzXJrgbKZHbsfnNNjuU5wfHheyVujdALGsF", "proofs": [ "4Bsj9RcdKsWJLf4e2AVwy8j3da3Kiv5SYEVSTpChFte47n8Jqy6emjykV2GVmR5S7weAXPmjsg8SKUYBswfGrT3H" ], "script": "base64:BgITCAISABIAEgQKAggBEgUKAwgBCAwADmxvdHRlcnlBc3NldElECQDZBAECLDNMejIzbVNVdlQxRXN3Y0JuMnNVUllKRzJhdDhyRzVhRnVVclRBd2FQTTZRAAp0aWNrZXRTaXplAAEBEGdldEludGVnZXJPckVsc2UCA2tleQN2YWwJAQt2YWx1ZU9yRWxzZQIJAJ8IAQUDa2V5BQN2YWwBD2dldFN0cmluZ09yRWxzZQIDa2V5A3ZhbAkBC3ZhbHVlT3JFbHNlAgkAoggBBQNrZXkFA3ZhbAECbWsBAXgJALkJAgUBeAIBXwERa2V5QWRyVG90YWxTdGFrZWQBA2FkcgkBAm1rAQkAzAgCAgNhZHIJAMwIAgUDYWRyCQDMCAICC3RvdGFsU3Rha2VkBQNuaWwBFWtleUxvdHRlcnlUb3RhbFN0YWtlZAELbG90dGVyeU5hbWUJAQJtawEJAMwIAgIHbG90dGVyeQkAzAgCBQtsb3R0ZXJ5TmFtZQkAzAgCAgt0b3RhbFN0YWtlZAUDbmlsARhrZXlBZHJMb3R0ZXJ5VG90YWxTdGFrZWQCC2xvdHRlcnlOY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lcgMIBQFpBmNhbGxlcgUJYXZhaWxhYmxlBQ5sb3R0ZXJ5QXNzZXRJRAkAzAgCCQEMSW50ZWdlckVudHJ5AgUPX2FkclRvdGFsU3Rha2VkCQBlAgUOYWRyVG90YWxTdGFrZWQFCWF2YWlsYWJsZQUDbmlsAWkBC2luaXRMb3R0ZXJ5Agtsb3R0ZXJ5TmFtZRJsb3R0ZXJ5RmluYWxIZWlnaHQDCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgphZG1pbiBvbmx5CQDMCAIJAQtTdHJpbmdFbnRyeQIFEl9hY3RpdmVMb3R0ZXJ5TmFtZQULbG90dGVyeU5hbWUJAMwIAgkBDEludGVnZXJFbnRyeQIJARVrZXlMb3R0ZXJ5RmluYWxIZWlnaHQBBQtsb3R0ZXJ5TmFtZQUSbG90dGVyeUZpbmFsSGVpZ2h0CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQEVa2V5TG90dGVyeVRvdGFsU3Rha2VkAQULbG90dGVyeU5hbWUAAAUDbmlsAWkBDGRlY2xhcmVQcml6ZQMLbG90dGVyeU5hbWUHcHJpemVJZApwcml6ZVZhbHVlAwkBAiE9AggFAWkGY2FsbGVyBQR0aGlzCQACAQIKYWRtaW4gb25seQkAzAgCCQELU3RyaW5nRW50cnkCCQEUa2V5TG90dGVyeVByaXplVmFsdWUCBQtsb3R0ZXJ5TmFtZQUHcHJpemVJZAUKcHJpemVWYWx1ZQUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tlebsJerI=", "height": 2731717, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: FxpiGXxEC6kAsBUbBeZCsWk35CeNb8ehbVbCBNrCDTDy Next: 3RbYyiDCt9CZiqqLH63b674EmbMfX6vVLA1AxFeR41JU Diff:
OldNewDifferences
66 let ticketSize = 1
77
88 func getIntegerOrElse (key,val) = valueOrElse(getInteger(key), val)
9+
10+
11+func getStringOrElse (key,val) = valueOrElse(getString(key), val)
912
1013
1114 func mk (x) = makeString(x, "_")
2326 func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, "finalHeight"])
2427
2528
29+func keyLotteryPrizeValue (lotteryName,prizeID) = mk(["lottery", lotteryName, "prize", toString(prizeID), "value"])
30+
31+
2632 let _activeLotteryName = mk(["param", "activeLotteryName"])
2733
28-let _lotteryIsActive = mk(["param", "lotteryIsActive"])
29-
30-func activeLotteryName () = if ((valueOrElse(getBoolean(_lotteryIsActive), false) != true))
31- then ""
32- else {
33- let lotteryName = getStringValue(_activeLotteryName)
34- let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
35- if (((height - 1) >= lotteryFinalHeight))
36- then ""
37- else lotteryName
38- }
34+func activeLotteryName () = {
35+ let lotteryName = getStringOrElse(_activeLotteryName, "")
36+ if ((lotteryName == ""))
37+ then ""
38+ else {
39+ let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
40+ if (((height - 1) >= lotteryFinalHeight))
41+ then ""
42+ else lotteryName
43+ }
44+ }
3945
4046
4147 @Callable(i)
9197 @Callable(i)
9298 func initLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this))
9399 then throw("admin only")
94- else [BooleanEntry(_lotteryIsActive, true), StringEntry(_activeLotteryName, lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)]
100+ else [StringEntry(_activeLotteryName, lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)]
95101
96102
97103
98104 @Callable(i)
99-func call () = {
100- let asset = Issue("Asset", "", 1, 0, true, unit, 0)
101- let assetId = calculateAssetId(asset)
102-[BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)]
103- }
105+func declarePrize (lotteryName,prizeId,prizeValue) = if ((i.caller != this))
106+ then throw("admin only")
107+ else [StringEntry(keyLotteryPrizeValue(lotteryName, prizeId), prizeValue)]
104108
105109
106110 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let lotteryAssetID = fromBase58String("3Lz23mSUvT1EswcBn2sURYJG2at8rG5aFuUrTAwaPM6Q")
55
66 let ticketSize = 1
77
88 func getIntegerOrElse (key,val) = valueOrElse(getInteger(key), val)
9+
10+
11+func getStringOrElse (key,val) = valueOrElse(getString(key), val)
912
1013
1114 func mk (x) = makeString(x, "_")
1215
1316
1417 func keyAdrTotalStaked (adr) = mk(["adr", adr, "totalStaked"])
1518
1619
1720 func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, "totalStaked"])
1821
1922
2023 func keyAdrLotteryTotalStaked (lotteryName,adr) = mk(["lottery", lotteryName, adr, "totalStaked"])
2124
2225
2326 func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, "finalHeight"])
2427
2528
29+func keyLotteryPrizeValue (lotteryName,prizeID) = mk(["lottery", lotteryName, "prize", toString(prizeID), "value"])
30+
31+
2632 let _activeLotteryName = mk(["param", "activeLotteryName"])
2733
28-let _lotteryIsActive = mk(["param", "lotteryIsActive"])
29-
30-func activeLotteryName () = if ((valueOrElse(getBoolean(_lotteryIsActive), false) != true))
31- then ""
32- else {
33- let lotteryName = getStringValue(_activeLotteryName)
34- let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
35- if (((height - 1) >= lotteryFinalHeight))
36- then ""
37- else lotteryName
38- }
34+func activeLotteryName () = {
35+ let lotteryName = getStringOrElse(_activeLotteryName, "")
36+ if ((lotteryName == ""))
37+ then ""
38+ else {
39+ let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
40+ if (((height - 1) >= lotteryFinalHeight))
41+ then ""
42+ else lotteryName
43+ }
44+ }
3945
4046
4147 @Callable(i)
4248 func stake () = {
4349 let lotteryName = activeLotteryName()
4450 if ((lotteryName == ""))
4551 then throw("Lottery not active")
4652 else if ((size(i.payments) == 0))
4753 then throw("No payment added")
4854 else if ((size(i.payments) != 1))
4955 then throw("Too many payments added")
5056 else if ((i.payments[0].assetId != lotteryAssetID))
5157 then throw("Wrong payment assetId")
5258 else {
5359 let amount = i.payments[0].amount
5460 let ticketAmount = (amount / ticketSize)
5561 if ((ticketAmount == 0))
5662 then throw("Not enough to buy at least one ticket")
5763 else {
5864 let callerAddress = toString(i.caller)
5965 let _lotteryTotalStaked = keyLotteryTotalStaked(lotteryName)
6066 let lotteryTotalStaked = getIntegerValue(_lotteryTotalStaked)
6167 let _owner = mk(["owner", lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1))])
6268 let _adrTotalStaked = keyAdrTotalStaked(callerAddress)
6369 let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0)
6470 let _adrLotteryTotalStaked = keyAdrLotteryTotalStaked(lotteryName, callerAddress)
6571 let adrLotteryTotalStaked = getIntegerOrElse(_adrLotteryTotalStaked, 0)
6672 let change = (amount - (ticketAmount * ticketSize))
6773 [ScriptTransfer(i.caller, change, lotteryAssetID), IntegerEntry(_lotteryTotalStaked, (lotteryTotalStaked + ticketAmount)), StringEntry(_owner, callerAddress), IntegerEntry(_adrTotalStaked, (adrTotalStaked + ticketAmount)), IntegerEntry(_adrLotteryTotalStaked, (adrLotteryTotalStaked + ticketAmount))]
6874 }
6975 }
7076 }
7177
7278
7379
7480 @Callable(i)
7581 func claim () = {
7682 let callerAddress = toString(i.caller)
7783 let lotteryName = activeLotteryName()
7884 let stakedInActiveLottery = if ((lotteryName == ""))
7985 then 0
8086 else getIntegerOrElse(keyAdrLotteryTotalStaked(lotteryName, callerAddress), 0)
8187 let _adrTotalStaked = keyAdrTotalStaked(callerAddress)
8288 let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0)
8389 let available = (adrTotalStaked - stakedInActiveLottery)
8490 if ((0 >= available))
8591 then throw("No assets available for claim")
8692 else [ScriptTransfer(i.caller, available, lotteryAssetID), IntegerEntry(_adrTotalStaked, (adrTotalStaked - available))]
8793 }
8894
8995
9096
9197 @Callable(i)
9298 func initLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this))
9399 then throw("admin only")
94- else [BooleanEntry(_lotteryIsActive, true), StringEntry(_activeLotteryName, lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)]
100+ else [StringEntry(_activeLotteryName, lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)]
95101
96102
97103
98104 @Callable(i)
99-func call () = {
100- let asset = Issue("Asset", "", 1, 0, true, unit, 0)
101- let assetId = calculateAssetId(asset)
102-[BinaryEntry("bin", base58''), BooleanEntry("bool", true), IntegerEntry("int", 1), StringEntry("str", ""), DeleteEntry("str"), asset, Reissue(assetId, 1, false), Burn(assetId, 1), ScriptTransfer(i.caller, 1, assetId)]
103- }
105+func declarePrize (lotteryName,prizeId,prizeValue) = if ((i.caller != this))
106+ then throw("admin only")
107+ else [StringEntry(keyLotteryPrizeValue(lotteryName, prizeId), prizeValue)]
104108
105109
106110 @Verifier(tx)
107111 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
108112

github/deemru/w8io/026f985 
38.12 ms