tx · 3uGFYMZ21sooBbbmGgxRvMh1Sm9FCW7r7ZjZgR4oirfw 3N1izYBy9WyobbrP7bgrsDM66vbCdEV7oWt: -0.00600000 Waves 2024.06.04 14:15 [3135882] smart account 3N1izYBy9WyobbrP7bgrsDM66vbCdEV7oWt > SELF 0.00000000 Waves
{ "type": 13, "id": "3uGFYMZ21sooBbbmGgxRvMh1Sm9FCW7r7ZjZgR4oirfw", "fee": 600000, "feeAssetId": null, "timestamp": 1717499728831, "version": 2, "chainId": 84, "sender": "3N1izYBy9WyobbrP7bgrsDM66vbCdEV7oWt", "senderPublicKey": "HdsR78qWZ4PfD5V84Rvq4AHBXV2vqZirthUjhHLhgF9u", "proofs": [ "HKyCAS6jbhSq74n7mesxBm2ZdJvHriZGoX6WxQ6Zr2M7FqWhgojRBSdHhhr4asJA1uxkGNw4tvgxJTDeJVM8Zq9" ], "script": "base64:BgIWCAISBgoEAQEIAhIECgIBAhIECgIBAhcAA1NFUAICX18BBGpvaW4BBWFycmF5CQC5CQIFBWFycmF5BQNTRVABCHNlcGFyYXRlAQZzdHJpbmcJALUJAgUGc3RyaW5nBQNTRVAAC2Rlbm9taW5hdG9yAOgHAAt3aW5uZXJTaGFyZQC8BQAKYWRtaW5TaGFyZQDIAQAMY3JlYXRvclNoYXJlADIADXJlZmVycmVyU2hhcmUAMgEPbG90dGVyeUNvdW50S2V5AAkBBGpvaW4BCQDMCAICAiVzCQDMCAICDGxvdHRlcnlDb3VudAUDbmlsARhsb3R0ZXJ5RW5kQmxvY2tIZWlnaHRLZXkBCWxvdHRlcnlJZAkBBGpvaW4BCQDMCAICAiVzCQDMCAICFWxvdHRlcnlFbmRCbG9ja0hlaWdodAkAzAgCCQCkAwEFCWxvdHRlcnlJZAUDbmlsARJsb3R0ZXJ5QmV0UHJpY2VLZXkBCWxvdHRlcnlJZAkBBGpvaW4BCQDMCAICAiVzCQDMCAICD2xvdHRlcnlCZXRQcmljZQkAzAgCCQCkAwEFCWxvdHRlcnlJZAUDb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vcgUIYmV0VG9rZW4JAMwIAgkBDEJvb2xlYW5FbnRyeQIJARVsb3R0ZXJ5SXNGaW5hbGl6ZWRLZXkBBQlsb3R0ZXJ5SWQGBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5VuL4gA==", "height": 3135882, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
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", "lotteryBetToken", 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.callerPublicKey)) | |
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 betToken = getBinaryValue(lotteryBetAssetKey(lotteryId)) | |
159 | + | let cap = (betPrice * totalCountTickets) | |
160 | + | [ScriptTransfer(Address(user), fraction(cap, winnerShare, denominator), betToken), 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.49 ms ◑