tx · 7nv2AegxVknj7GqRr3cJvx42qp2FUKfwsmoedpSCGPFE

3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs:  -0.01000000 Waves

2023.08.29 12:11 [2731791] smart account 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs > SELF 0.00000000 Waves

{ "type": 13, "id": "7nv2AegxVknj7GqRr3cJvx42qp2FUKfwsmoedpSCGPFE", "fee": 1000000, "feeAssetId": null, "timestamp": 1693300327307, "version": 2, "chainId": 84, "sender": "3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs", "senderPublicKey": "8yQuxvQ2qLzXJrgbKZHbsfnNNjuU5wfHheyVujdALGsF", "proofs": [ "54vK747Gwf8jz6gERpjAgfYKA3kMAW2DPGMCd4fo2a5nJ2CrE1zgmHu92wgK3xeHpe8BDzR6BEKSLdizaj3cMExf" ], "script": "base64:BgIZCAISABIAEgQKAggBEgUKAwgBCBIECgIIAQ0ADmxvdHRlcnlBc3NldElECQDZBAECLDNMejIzbVNVdlQxRXN3Y0JuMnNVUllKRzJhdDhyRzVhRnVVclRBd2FQTTZRAAp0aWNrZXRTaXplAAEBEGdldEludGVnZXJPckVsc2UCA2tleQN2YWwJAQt2YWx1ZU9yRWxzZQIJAJ8IAQUDa2V5BQN2YWwBD2dldFN0cmluZ09yRWxzZQIDa2V5A3ZhbAkBC3ZhbHVlT3JFbHNlAgkAoggBBQNrZXkFA3ZhbAECbWsBAXgJALkJAgUBeAIBXwERa2V5QWRyVG90YWxTdGFrZWQBA2FkcgkBAm1rAQkAzAgCAgNhZHIJAMwIAgUDYWRyCQDMCAICC3RvdGFsU3Rha2VkBQNuaWwBFWtleUxvdHRlcnlUb3RhbFN0YWtlZAELbG90dGVyeU5hbWUJAQJtawEJAMwIAgIHbG90dGVyeQkAzAgCBQtsb3R0ZXJ5TmFtZQkAzAgCAgt0b3RhbFN0YWtlZAUDbmlsARhrZXlBZHJMb3R0ZXJ5VG90YWxTdGFrZWQCC2xv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lcnlOYW1lBQdwcml6ZUlkBQZjaG9pY2UFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkyZVgQ", "height": 2731791, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5rxT1MWEwcwwUD3qydr6f7zcpkDfgaAjDLmyViRqxCQw Next: 2c4qd4Kg7oweKqkdKQLzX6DVJLwGxV8v3sytMRHVCYZS Diff:
OldNewDifferences
130130 then throw("prize does not exist")
131131 else {
132132 let finalBlock = value(blockInfoByHeight(lotteryFinalHeight))
133- let randomHash = sha256((toBytes(prizeId) + value(finalBlock.vrf)))
133+ let randomHash = sha256(((toBytes(prizeId) + value(finalBlock.vrf)) + toBytes("dodlllottery")))
134134 let choice = toInt((toBigInt(randomHash) % toBigInt(lotteryTotalStaked)))
135135 [StringEntry("lastHash", toString(toBigInt(randomHash))), IntegerEntry(keyLotteryPrizeChoice(lotteryName, prizeId), choice)]
136136 }
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)
99
1010
1111 func getStringOrElse (key,val) = valueOrElse(getString(key), val)
1212
1313
1414 func mk (x) = makeString(x, "_")
1515
1616
1717 func keyAdrTotalStaked (adr) = mk(["adr", adr, "totalStaked"])
1818
1919
2020 func keyLotteryTotalStaked (lotteryName) = mk(["lottery", lotteryName, "totalStaked"])
2121
2222
2323 func keyAdrLotteryTotalStaked (lotteryName,adr) = mk(["lottery", lotteryName, "adr", adr, "totalStaked"])
2424
2525
2626 func keyLotteryFinalHeight (lotteryName) = mk(["lottery", lotteryName, "finalHeight"])
2727
2828
2929 func keyLotteryPrizeValue (lotteryName,prizeID) = mk(["lottery", lotteryName, "prize", toString(prizeID), "value"])
3030
3131
3232 func keyLotteryPrizeChoice (lotteryName,prizeID) = mk(["lottery", lotteryName, "prize", toString(prizeID), "choice"])
3333
3434
3535 let _activeLotteryName = mk(["param", "activeLotteryName"])
3636
3737 func activeLotteryName () = {
3838 let lotteryName = getStringOrElse(_activeLotteryName, "")
3939 if ((lotteryName == ""))
4040 then ""
4141 else {
4242 let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
4343 if (((height - 1) >= lotteryFinalHeight))
4444 then ""
4545 else lotteryName
4646 }
4747 }
4848
4949
5050 @Callable(i)
5151 func stake () = {
5252 let lotteryName = activeLotteryName()
5353 if ((lotteryName == ""))
5454 then throw("Lottery not active")
5555 else if ((size(i.payments) == 0))
5656 then throw("No payment added")
5757 else if ((size(i.payments) != 1))
5858 then throw("Too many payments added")
5959 else if ((i.payments[0].assetId != lotteryAssetID))
6060 then throw("Wrong payment assetId")
6161 else {
6262 let amount = i.payments[0].amount
6363 let ticketAmount = (amount / ticketSize)
6464 if ((ticketAmount == 0))
6565 then throw("Not enough to buy at least one ticket")
6666 else {
6767 let callerAddress = toString(i.caller)
6868 let _lotteryTotalStaked = keyLotteryTotalStaked(lotteryName)
6969 let lotteryTotalStaked = getIntegerValue(_lotteryTotalStaked)
7070 let _owner = mk(["owner", lotteryName, toString(lotteryTotalStaked), toString(((lotteryTotalStaked + ticketAmount) - 1))])
7171 let _adrTotalStaked = keyAdrTotalStaked(callerAddress)
7272 let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0)
7373 let _adrLotteryTotalStaked = keyAdrLotteryTotalStaked(lotteryName, callerAddress)
7474 let adrLotteryTotalStaked = getIntegerOrElse(_adrLotteryTotalStaked, 0)
7575 let change = (amount - (ticketAmount * ticketSize))
7676 [ScriptTransfer(i.caller, change, lotteryAssetID), IntegerEntry(_lotteryTotalStaked, (lotteryTotalStaked + ticketAmount)), StringEntry(_owner, callerAddress), IntegerEntry(_adrTotalStaked, (adrTotalStaked + ticketAmount)), IntegerEntry(_adrLotteryTotalStaked, (adrLotteryTotalStaked + ticketAmount))]
7777 }
7878 }
7979 }
8080
8181
8282
8383 @Callable(i)
8484 func claim () = if ((size(i.payments) > 0))
8585 then throw("No payments needed")
8686 else {
8787 let callerAddress = toString(i.caller)
8888 let lotteryName = activeLotteryName()
8989 let stakedInActiveLottery = if ((lotteryName == ""))
9090 then 0
9191 else getIntegerOrElse(keyAdrLotteryTotalStaked(lotteryName, callerAddress), 0)
9292 let _adrTotalStaked = keyAdrTotalStaked(callerAddress)
9393 let adrTotalStaked = getIntegerOrElse(_adrTotalStaked, 0)
9494 let available = (adrTotalStaked - stakedInActiveLottery)
9595 if ((0 >= available))
9696 then throw("No assets available for claim")
9797 else [ScriptTransfer(i.caller, available, lotteryAssetID), IntegerEntry(_adrTotalStaked, (adrTotalStaked - available))]
9898 }
9999
100100
101101
102102 @Callable(i)
103103 func startLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this))
104104 then throw("Admin only")
105105 else [StringEntry(_activeLotteryName, lotteryName), IntegerEntry(keyLotteryFinalHeight(lotteryName), lotteryFinalHeight), IntegerEntry(keyLotteryTotalStaked(lotteryName), 0)]
106106
107107
108108
109109 @Callable(i)
110110 func declarePrize (lotteryName,prizeId,prizeValue) = if ((i.caller != this))
111111 then throw("Admin only")
112112 else [StringEntry(keyLotteryPrizeValue(lotteryName, prizeId), prizeValue)]
113113
114114
115115
116116 @Callable(i)
117117 func finalaizePrizeChoice (lotteryName,prizeId) = if ((i.caller != this))
118118 then throw("Admin only")
119119 else {
120120 let lotteryFinalHeight = getIntegerValue(keyLotteryFinalHeight(lotteryName))
121121 if ((lotteryFinalHeight > height))
122122 then throw("Lottery is not over yet")
123123 else {
124124 let lotteryTotalStaked = getIntegerValue(keyLotteryTotalStaked(lotteryName))
125125 if ((lotteryTotalStaked == 0))
126126 then throw("No one entered the lottery")
127127 else {
128128 let lotteryPrizeValue = getStringOrElse(keyLotteryPrizeValue(lotteryName, prizeId), "")
129129 if ((lotteryPrizeValue == ""))
130130 then throw("prize does not exist")
131131 else {
132132 let finalBlock = value(blockInfoByHeight(lotteryFinalHeight))
133- let randomHash = sha256((toBytes(prizeId) + value(finalBlock.vrf)))
133+ let randomHash = sha256(((toBytes(prizeId) + value(finalBlock.vrf)) + toBytes("dodlllottery")))
134134 let choice = toInt((toBigInt(randomHash) % toBigInt(lotteryTotalStaked)))
135135 [StringEntry("lastHash", toString(toBigInt(randomHash))), IntegerEntry(keyLotteryPrizeChoice(lotteryName, prizeId), choice)]
136136 }
137137 }
138138 }
139139 }
140140
141141
142142 @Verifier(tx)
143143 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
144144

github/deemru/w8io/026f985 
48.41 ms