tx · 7PTXUoKUMVyBB2cBR1uQJwRrFqsFAix81yJJkt2QBFwg

3MyEYRPtg6etpXQE5zv1AWQrMe78q4Ez9Fq:  -0.00700000 Waves

2024.06.04 14:55 [3135921] smart account 3MyEYRPtg6etpXQE5zv1AWQrMe78q4Ez9Fq > SELF 0.00000000 Waves

{ "type": 13, "id": "7PTXUoKUMVyBB2cBR1uQJwRrFqsFAix81yJJkt2QBFwg", "fee": 700000, "feeAssetId": null, "timestamp": 1717502135954, "version": 2, "chainId": 84, "sender": "3MyEYRPtg6etpXQE5zv1AWQrMe78q4Ez9Fq", "senderPublicKey": "DtK3M7kDmHS6LmfshkJuVF8TP4ytP9G6BmNviTqZMsmE", "proofs": [ "4ibwXtmFEckviNSH6NhAfjrrapejNx7FmpSGdhnAbDx29hScvVBdzNJhyCo6JaL4x3BhMtg8Twc9z4L3rnxrDFzG" ], "script": "base64:BgIWCAISBgoEAQEIAhIECgIBAhIECgIBAhcAA1NFUAICX18BBGpvaW4BBWFycmF5CQC5CQIFBWFycmF5BQNTRVABCHNlcGFyYXRlAQZzdHJpbmcJALUJAgUGc3RyaW5nBQNTRVAAC2Rlbm9taW5hdG9yAOgHAAt3aW5uZXJTaGFyZQC8BQAKYWRtaW5TaGFyZQDIAQAMY3JlYXRvclNoYXJlADIADXJlZmVycmVyU2hhcmUAMgEPbG90dGVyeUNvdW50S2V5AAkBBGpvaW4BCQDMCAICAiVzCQDMCAICDGxvdHRlcnlDb3VudAUDbmlsARhsb3R0ZXJ5RW5kQmxvY2tIZWlnaHRLZXkBCWxvdHRlcnlJZAkBBGpvaW4BCQDMCAICAiVzCQDMCAICFWxvdHRlcnlFbmRCbG9ja0hlaWdodAkAzAgCCQCkAwEFCWxvdHRlcnlJZAUDbmlsARJsb3R0ZXJ5QmV0UHJpY2VLZXkBCWxvdHRlcnlJZAkBBGpvaW4BCQDMCAICAiVzCQDMCAICD2xvdHRlcnlCZXRQcmljZQkAzAgCCQCkAwEFCWxvdHRlcnlJZAU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VN0cmluZwEFDmJldEFzc2V0U3RyaW5nCQDMCAIJAQxCb29sZWFuRW50cnkCCQEVbG90dGVyeUlzRmluYWxpemVkS2V5AQUJbG90dGVyeUlkBgUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleYRqDA8=", "height": 3135921, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 6 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let SEP = "__"
5+
6+func join (array) = makeString(array, SEP)
7+
8+
9+func separate (string) = split(string, SEP)
10+
11+
12+let denominator = 1000
13+
14+let winnerShare = 700
15+
16+let adminShare = 200
17+
18+let creatorShare = 50
19+
20+let referrerShare = 50
21+
22+func lotteryCountKey () = join(["%s", "lotteryCount"])
23+
24+
25+func lotteryEndBlockHeightKey (lotteryId) = join(["%s", "lotteryEndBlockHeight", toString(lotteryId)])
26+
27+
28+func lotteryBetPriceKey (lotteryId) = join(["%s", "lotteryBetPrice", toString(lotteryId)])
29+
30+
31+func lotteryBetAssetKey (lotteryId) = join(["%s", "lotteryBetAsset", toString(lotteryId)])
32+
33+
34+func lotteryWinnerTicketIdKey (lotteryId) = join(["%s", "lotteryWinnerTicketId", toString(lotteryId)])
35+
36+
37+func lotteryCountTicketsKey (lotteryId) = join(["%s", "lotteryCountTickets", toString(lotteryId)])
38+
39+
40+func lotteryCreatorKey (lotteryId) = join(["%s", "lotteryCreator", toString(lotteryId)])
41+
42+
43+func lotteryIsFinalizedKey (lotteryId) = join(["%s", "lotteryIsFinalized", toString(lotteryId)])
44+
45+
46+func lotteryTicketOwnerKey (lotteryId,ticketId) = join(["%s", "lotteryTicketOwner", toString(lotteryId), toString(ticketId)])
47+
48+
49+let pieceOfShitArray90 = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89]
50+
51+func assetIdFromString (assetId) = if ((assetId == "WAVES"))
52+ then unit
53+ else fromBase58String(assetId)
54+
55+
56+func assetIdToString (assetId) = match assetId {
57+ case b: ByteVector =>
58+ toBase58String(b)
59+ case _ =>
60+ "WAVES"
61+}
62+
63+
64+func payOneAsset (i,assetString) = if ((size(i.payments) != 1))
65+ then throw("only 1 payment")
66+ else if ((assetIdToString(i.payments[0].assetId) == assetString))
67+ then i.payments[0].amount
68+ else throw("wrong asset")
69+
70+
71+func randomizer (blockHeight) = {
72+ let block = blockInfoByHeight(blockHeight)
73+ if (!(isDefined(block)))
74+ then throw("block not mined")
75+ else {
76+ let rand = value(lastBlock.vrf)
77+ sha256(rand)
78+ }
79+ }
80+
81+
82+func getWinner (lotteryId) = {
83+ let blockHeight = getIntegerValue(lotteryEndBlockHeightKey(lotteryId))
84+ let countTickets = getIntegerValue(lotteryCountTicketsKey(lotteryId))
85+ let rand = randomizer(blockHeight)
86+ let winNumber = (toInt(rand) % countTickets)
87+ getBinaryValue(lotteryTicketOwnerKey(lotteryId, winNumber))
88+ }
89+
90+
91+@Callable(i)
92+func create (endBlockHeight,betPrice,betToken,refferer) = if ((lastBlock.height >= endBlockHeight))
93+ then throw("incorrect endBlockHeight")
94+ else {
95+ let count = match getInteger(lotteryCountKey()) {
96+ case a: Int =>
97+ a
98+ case _ =>
99+ 0
100+ }
101+[IntegerEntry(lotteryCountKey(), (count + 1)), IntegerEntry(lotteryEndBlockHeightKey(count), endBlockHeight), IntegerEntry(lotteryBetPriceKey(count), betPrice), StringEntry(lotteryBetAssetKey(count), betToken), IntegerEntry(lotteryCountTicketsKey(count), 0), BinaryEntry(lotteryCreatorKey(count), refferer), BooleanEntry(lotteryIsFinalizedKey(count), false)]
102+ }
103+
104+
105+
106+@Callable(i)
107+func buy (lotteryId,referrer) = {
108+ let betAssetString = getStringValue(lotteryBetAssetKey(lotteryId))
109+ let betPrice = getIntegerValue(lotteryBetPriceKey(lotteryId))
110+ let totalCountTickets = getIntegerValue(lotteryCountTicketsKey(lotteryId))
111+ let endBlockHeight = getIntegerValue(lotteryEndBlockHeightKey(lotteryId))
112+ if ((lastBlock.height >= endBlockHeight))
113+ then throw("lottery alredy finished")
114+ else {
115+ let amount = payOneAsset(i, betAssetString)
116+ let purchasedTickets = (amount / betPrice)
117+ let return = (amount % betPrice)
118+ if ((return != 0))
119+ then throw("attach asset amount multiple of the bet")
120+ else {
121+ func f (accum,next) = if ((purchasedTickets > next))
122+ then (accum :+ BinaryEntry(lotteryTicketOwnerKey(lotteryId, (totalCountTickets + next)), i.caller.bytes))
123+ else accum
124+
125+ let creator = getBinaryValue(lotteryCreatorKey(lotteryId))
126+ ({
127+ let $l = pieceOfShitArray90
128+ let $s = size($l)
129+ let $acc0 = nil
130+ func $f0_1 ($a,$i) = if (($i >= $s))
131+ then $a
132+ else f($a, $l[$i])
133+
134+ func $f0_2 ($a,$i) = if (($i >= $s))
135+ then $a
136+ else throw("List size exceeds 90")
137+
138+ $f0_2($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($f0_1($acc0, 0), 1), 2), 3), 4), 5), 6), 7), 8), 9), 10), 11), 12), 13), 14), 15), 16), 17), 18), 19), 20), 21), 22), 23), 24), 25), 26), 27), 28), 29), 30), 31), 32), 33), 34), 35), 36), 37), 38), 39), 40), 41), 42), 43), 44), 45), 46), 47), 48), 49), 50), 51), 52), 53), 54), 55), 56), 57), 58), 59), 60), 61), 62), 63), 64), 65), 66), 67), 68), 69), 70), 71), 72), 73), 74), 75), 76), 77), 78), 79), 80), 81), 82), 83), 84), 85), 86), 87), 88), 89), 90)
139+ } ++ [IntegerEntry(lotteryCountTicketsKey(lotteryId), (totalCountTickets + purchasedTickets)), ScriptTransfer(Address(creator), fraction(amount, creatorShare, denominator), assetIdFromString(betAssetString)), ScriptTransfer(Address(referrer), fraction(amount, referrerShare, denominator), assetIdFromString(betAssetString))])
140+ }
141+ }
142+ }
143+
144+
145+
146+@Callable(i)
147+func claim (lotteryId,user) = {
148+ let winner = getWinner(lotteryId)
149+ if ((winner != user))
150+ then throw("not win")
151+ else {
152+ let isFinalized = getBooleanValue(lotteryIsFinalizedKey(lotteryId))
153+ if (isFinalized)
154+ then throw("already clamied")
155+ else {
156+ let betPrice = getIntegerValue(lotteryBetPriceKey(lotteryId))
157+ let totalCountTickets = getIntegerValue(lotteryCountTicketsKey(lotteryId))
158+ let betAssetString = getStringValue(lotteryBetAssetKey(lotteryId))
159+ let cap = (betPrice * totalCountTickets)
160+[ScriptTransfer(Address(user), fraction(cap, winnerShare, denominator), assetIdFromString(betAssetString)), BooleanEntry(lotteryIsFinalizedKey(lotteryId), true)]
161+ }
162+ }
163+ }
164+
165+
166+@Verifier(tx)
167+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
168+

github/deemru/w8io/026f985 
17.57 ms