tx · bLLaqqkXHUgKA3gSYMfBk9tDPG98G7jTockmUpPVF15 3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo: -0.01400000 Waves 2021.10.07 11:15 [1735558] smart account 3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo > SELF 0.00000000 Waves
{ "type": 13, "id": "bLLaqqkXHUgKA3gSYMfBk9tDPG98G7jTockmUpPVF15", "fee": 1400000, "feeAssetId": null, "timestamp": 1633594529998, "version": 2, "chainId": 84, "sender": "3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo", "senderPublicKey": "5fUyPtPgB9o1mWXPYifKATuZc8PG2ErT5CGABbC7pu3", "proofs": [ "4c7oRMR11N1CWLhmkBkiirSi6UM5Q4yXwmfrqjBk2pic2unJzvfviTnyofxp473iHqpQhaSHUjhrokj8ksfvzZep" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACAAAAAAJbWF4U3VwcGx5AAAAAAAAAAPoAAAAAAV3YXZlcwAAAAAABfXhAAEAAAAMZ2V0UHVua0lES2V5AAAAAQAAAAJpZAkAASwAAAACAgAAAAVwdW5rXwUAAAACaWQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADHRyeUdldFN0cmluZwAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWICAAAAAAUAAAADdmFsAQAAAA10cnlHZXRBZGRyZXNzAAAAAQAAAARhZGRyBAAAAAN2YWwEAAAAByRtYXRjaDA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AAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleUSknQg=", "height": 1735558, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8S69Em8547xCcoVMHqgqTrpHAHPtsQtiv1tn8UAuoJcr Next: Dyr5GBcCravRzvjcGrtJX4gPR5wznhPvHEZKgmYv9jNQ Diff:
Old | New | Differences | |
---|---|---|---|
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | - | func calcWavesNeeded (totalPunksSupply) = (((totalPunksSupply / 100) + 1) * waves) | |
53 | + | func calcWavesNeeded (totalPunksSupply) = if ((totalPunksSupply == 0)) | |
54 | + | then waves | |
55 | + | else (((totalPunksSupply / 100) + 1) * waves) | |
54 | 56 | ||
55 | 57 | ||
56 | 58 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let maxSupply = 1000 | |
5 | 5 | ||
6 | 6 | let waves = 100000000 | |
7 | 7 | ||
8 | 8 | func getPunkIDKey (id) = ("punk_" + id) | |
9 | 9 | ||
10 | 10 | ||
11 | 11 | func tryGetInteger (key) = { | |
12 | 12 | let val = match getInteger(this, key) { | |
13 | 13 | case b: Int => | |
14 | 14 | b | |
15 | 15 | case _ => | |
16 | 16 | 0 | |
17 | 17 | } | |
18 | 18 | val | |
19 | 19 | } | |
20 | 20 | ||
21 | 21 | ||
22 | 22 | func tryGetString (key) = { | |
23 | 23 | let val = match getString(this, key) { | |
24 | 24 | case b: String => | |
25 | 25 | b | |
26 | 26 | case _ => | |
27 | 27 | "" | |
28 | 28 | } | |
29 | 29 | val | |
30 | 30 | } | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func tryGetAddress (addr) = { | |
34 | 34 | let val = match addressFromString(addr) { | |
35 | 35 | case a: Address => | |
36 | 36 | a | |
37 | 37 | case a: Unit => | |
38 | 38 | this | |
39 | 39 | case _ => | |
40 | 40 | throw("Match error") | |
41 | 41 | } | |
42 | 42 | val | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getRandomNumber (variants,txId,heightBlock,offset) = { | |
47 | 47 | let randomSeedBlock = value(blockInfoByHeight((heightBlock - 1))) | |
48 | 48 | let randomHash = sha256_16Kb((txId + value(randomSeedBlock.vrf))) | |
49 | 49 | (toInt(randomHash, offset) % variants) | |
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | - | func calcWavesNeeded (totalPunksSupply) = (((totalPunksSupply / 100) + 1) * waves) | |
53 | + | func calcWavesNeeded (totalPunksSupply) = if ((totalPunksSupply == 0)) | |
54 | + | then waves | |
55 | + | else (((totalPunksSupply / 100) + 1) * waves) | |
54 | 56 | ||
55 | 57 | ||
56 | 58 | @Callable(i) | |
57 | 59 | func mint (ref) = { | |
58 | 60 | let totalPunksSupply = tryGetInteger("punks_supply") | |
59 | 61 | let availablePunks = tryGetString("available_punks") | |
60 | 62 | let wavesNeeded = calcWavesNeeded(totalPunksSupply) | |
61 | 63 | let firstPayment = value(i.payments[0]) | |
62 | 64 | let firstPaymentBool = match firstPayment.assetId { | |
63 | 65 | case t: ByteVector => | |
64 | 66 | true | |
65 | 67 | case w: Unit => | |
66 | 68 | false | |
67 | 69 | case _ => | |
68 | 70 | throw("Match error") | |
69 | 71 | } | |
70 | 72 | if ((totalPunksSupply == maxSupply)) | |
71 | 73 | then throw("All punks are minted") | |
72 | 74 | else if ((availablePunks == "")) | |
73 | 75 | then throw("No punks available") | |
74 | 76 | else if (firstPaymentBool) | |
75 | 77 | then throw("Payment must be in Waves tokens only") | |
76 | 78 | else if ((wavesNeeded > firstPayment.amount)) | |
77 | 79 | then throw("Insufficient funds") | |
78 | 80 | else { | |
79 | 81 | let listAvailablePunks = split(availablePunks, ",") | |
80 | 82 | let rand = getRandomNumber(totalPunksSupply, i.transactionId, height, 0) | |
81 | 83 | let punkId = listAvailablePunks[rand] | |
82 | 84 | let name = ("WavesPunk #" + punkId) | |
83 | 85 | let asset = Issue(name, name, 1, 0, false, unit, height) | |
84 | 86 | let assetId = calculateAssetId(asset) | |
85 | 87 | let referalAddress = tryGetAddress(ref) | |
86 | 88 | [IntegerEntry("punks_supply", (totalPunksSupply + 1)), StringEntry("available_punks", makeString(removeByIndex(listAvailablePunks, rand), ",")), asset, StringEntry(getPunkIDKey(punkId), toBase58String(assetId)), StringEntry(toBase58String(assetId), getPunkIDKey(punkId)), ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(referalAddress, (firstPayment.amount / 10), unit)] | |
87 | 89 | } | |
88 | 90 | } | |
89 | 91 | ||
90 | 92 | ||
91 | 93 | @Verifier(tx) | |
92 | 94 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
93 | 95 |
github/deemru/w8io/169f3d6 38.96 ms ◑