tx · G148PL3j2GbrSs6go1b4RZfbopEtcDCx9D7KoBVppm65 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs: -0.01000000 Waves 2023.08.14 15:48 [2710253] smart account 3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs > SELF 0.00000000 Waves
{ "type": 13, "id": "G148PL3j2GbrSs6go1b4RZfbopEtcDCx9D7KoBVppm65", "fee": 1000000, "feeAssetId": null, "timestamp": 1692017330974, "version": 2, "chainId": 84, "sender": "3N4Kzbxu521DHPxcgrmZ4XUqN2kF6TqLTzs", "senderPublicKey": "8yQuxvQ2qLzXJrgbKZHbsfnNNjuU5wfHheyVujdALGsF", "proofs": [ "3awUKPXtmw2z2xgAV5TGsCwfn6hKj2LTkfcu2NH9ihHHdW4gfwVv7jURuTxYcuNha5tw6kxouzTqNrMeSxn69vCn" ], "script": "base64:BgIMCAISABIECgIIARIABQAObG90dGVyeUFzc2V0SUQJANkEAQIsM0x6MjNtU1V2VDFFc3djQm4yc1VSWUpHMmF0OHJHNWFGdVVyVEF3YVBNNlEACnRpY2tldFNpemUAgMLXLwECbWsBAXgJALkJAgUBeAIBXwECZ3MBA2tleQkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCdCAIFBHRoaXMFA2tleQkAuQkCCQDMCAICAScJAMwIAgUDa2V5CQDMCAICDycga2V5IG5vdCBmb3VuZAUDbmlsAgABAmdpAQNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAmggCBQR0aGlzBQNrZXkJALkJAgkAzAgCAgEnCQDMCAIFA2tleQkAzAgCAg8nIGtleSBub3QgZm91bmQFA25pbAIAAwFpAQVzdGFrZQADCQECIT0CCQELdmFsdWVPckVsc2UCCQCbCAIFBHRoaXMCEGxvdHRlcnlJc1N0YXJ0ZWQHBgkAAgECG0xvdHRlcnkgaGFzIG5vdCBzdGFydGVkIHlldAQLbG90dGVyeU5hbWUJAQJncwECEmN1cnJlbnRMb3R0ZXJ5TmFtZQQ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SW50ZWdlckVudHJ5AgkBAm1rAQkAzAgCBQtsb3R0ZXJ5TmFtZQkAzAgCAhJsb3R0ZXJ5RmluYWxIZWlnaHQFA25pbAUSbG90dGVyeUZpbmFsSGVpZ2h0CQDMCAIJAQxJbnRlZ2VyRW50cnkCCQECbWsBCQDMCAIFC2xvdHRlcnlOYW1lCQDMCAICB3BvaW50ZXIFA25pbAAABQNuaWwBaQEEY2FsbAAEBWFzc2V0CQDDCAcCBUFzc2V0AgAAAQAABgUEdW5pdAAABAdhc3NldElkCQC4CAEFBWFzc2V0CQDMCAIJAQtCaW5hcnlFbnRyeQICA2JpbgEACQDMCAIJAQxCb29sZWFuRW50cnkCAgRib29sBgkAzAgCCQEMSW50ZWdlckVudHJ5AgIDaW50AAEJAMwIAgkBC1N0cmluZ0VudHJ5AgIDc3RyAgAJAMwIAgkBC0RlbGV0ZUVudHJ5AQIDc3RyCQDMCAIFBWFzc2V0CQDMCAIJAQdSZWlzc3VlAwUHYXNzZXRJZAABBwkAzAgCCQEEQnVybgIFB2Fzc2V0SWQAAQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIAAQUHYXNzZXRJZAUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleX2kaXc=", "height": 2710253, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Boa9G9QRNyvkj2WqMT1sgLHrN1RM4u6WnJYS4Xm576fD Next: C19BQ5MzffCJG4HmoE3h3waLdqBJooZeSFpj6EJfekKR Diff:
Old | New | Differences | |
---|---|---|---|
31 | 31 | else { | |
32 | 32 | let amount = i.payments[0].amount | |
33 | 33 | let ticketAmount = (amount / ticketSize) | |
34 | + | if ((amount == 0)) | |
35 | + | then throw("Not enough to buy at least one ticket") | |
36 | + | else { | |
37 | + | let pointerKey = mk([lotteryName, "pointer"]) | |
34 | 38 | [ScriptTransfer(i.caller, (amount - (ticketAmount * ticketSize)), lotteryAssetID)] | |
39 | + | } | |
35 | 40 | } | |
36 | 41 | } | |
37 | 42 | ||
40 | 45 | @Callable(i) | |
41 | 46 | func initLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this)) | |
42 | 47 | then throw("admin only") | |
43 | - | else [BooleanEntry("lotteryIsStarted", true), StringEntry("currentLotteryName", lotteryName), IntegerEntry( | |
48 | + | else [BooleanEntry("lotteryIsStarted", true), StringEntry("currentLotteryName", lotteryName), IntegerEntry(mk([lotteryName, "lotteryFinalHeight"]), lotteryFinalHeight), IntegerEntry(mk([lotteryName, "pointer"]), 0)] | |
44 | 49 | ||
45 | 50 | ||
46 | 51 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let lotteryAssetID = fromBase58String("3Lz23mSUvT1EswcBn2sURYJG2at8rG5aFuUrTAwaPM6Q") | |
5 | 5 | ||
6 | 6 | let ticketSize = 100000000 | |
7 | 7 | ||
8 | 8 | func mk (x) = makeString(x, "_") | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func gs (key) = valueOrErrorMessage(getString(this, key), makeString(["'", key, "' key not found"], "")) | |
12 | 12 | ||
13 | 13 | ||
14 | 14 | func gi (key) = valueOrErrorMessage(getInteger(this, key), makeString(["'", key, "' key not found"], "")) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | @Callable(i) | |
18 | 18 | func stake () = if ((valueOrElse(getBoolean(this, "lotteryIsStarted"), false) != true)) | |
19 | 19 | then throw("Lottery has not started yet") | |
20 | 20 | else { | |
21 | 21 | let lotteryName = gs("currentLotteryName") | |
22 | 22 | let lotteryFinalHeight = gi(mk([lotteryName, "lotteryFinalHeight"])) | |
23 | 23 | if (((height - 1) >= lotteryFinalHeight)) | |
24 | 24 | then throw("Lottery has not started yet") | |
25 | 25 | else if ((size(i.payments) == 0)) | |
26 | 26 | then throw("No payment added") | |
27 | 27 | else if ((size(i.payments) != 1)) | |
28 | 28 | then throw("Too many payments added") | |
29 | 29 | else if ((i.payments[0].assetId != lotteryAssetID)) | |
30 | 30 | then throw("Wrong payment assetId") | |
31 | 31 | else { | |
32 | 32 | let amount = i.payments[0].amount | |
33 | 33 | let ticketAmount = (amount / ticketSize) | |
34 | + | if ((amount == 0)) | |
35 | + | then throw("Not enough to buy at least one ticket") | |
36 | + | else { | |
37 | + | let pointerKey = mk([lotteryName, "pointer"]) | |
34 | 38 | [ScriptTransfer(i.caller, (amount - (ticketAmount * ticketSize)), lotteryAssetID)] | |
39 | + | } | |
35 | 40 | } | |
36 | 41 | } | |
37 | 42 | ||
38 | 43 | ||
39 | 44 | ||
40 | 45 | @Callable(i) | |
41 | 46 | func initLottery (lotteryName,lotteryFinalHeight) = if ((i.caller != this)) | |
42 | 47 | then throw("admin only") | |
43 | - | else [BooleanEntry("lotteryIsStarted", true), StringEntry("currentLotteryName", lotteryName), IntegerEntry( | |
48 | + | else [BooleanEntry("lotteryIsStarted", true), StringEntry("currentLotteryName", lotteryName), IntegerEntry(mk([lotteryName, "lotteryFinalHeight"]), lotteryFinalHeight), IntegerEntry(mk([lotteryName, "pointer"]), 0)] | |
44 | 49 | ||
45 | 50 | ||
46 | 51 | ||
47 | 52 | @Callable(i) | |
48 | 53 | func call () = { | |
49 | 54 | let asset = Issue("Asset", "", 1, 0, true, unit, 0) | |
50 | 55 | let assetId = calculateAssetId(asset) | |
51 | 56 | [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)] | |
52 | 57 | } | |
53 | 58 | ||
54 | 59 | ||
55 | 60 | @Verifier(tx) | |
56 | 61 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
57 | 62 |
github/deemru/w8io/169f3d6 24.29 ms ◑