tx · 4tkabmMuPbXRwGxZceEPc2cPGyNNRAwHuuruvaQCQBMt 3Muey1cqNaBjjcxXfKHF8qqTZeyGPAsvCpP: -0.00800000 Waves 2022.08.18 20:14 [2190205] smart account 3Muey1cqNaBjjcxXfKHF8qqTZeyGPAsvCpP > SELF 0.00000000 Waves
{ "type": 13, "id": "4tkabmMuPbXRwGxZceEPc2cPGyNNRAwHuuruvaQCQBMt", "fee": 800000, "feeAssetId": null, "timestamp": 1660842850692, "version": 2, "chainId": 84, "sender": "3Muey1cqNaBjjcxXfKHF8qqTZeyGPAsvCpP", "senderPublicKey": "3bPATHM3GnqSGjJb8saHmYMvsaioqu2etEGkZDiuRCcn", "proofs": [ "4h1YzGLgtWS1gMHSk5hGK2hGTBb5LKHvSV6R7vbbQLtNEkCu5Lh5Sh7hisDsfQCbZ1FUbgEeY92XmsYdeSFx986x" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAACwAAAAAJbWF4U3VwcGx5AAAAAAAAAAPoAAAAAAV3YXZlcwAAAAAABfXhAAEAAAAMZ2V0UHVua0lES2V5AAAAAQAAAAJpZAkAASwAAAACAgAAAAVwdW5rXwUAAAACaWQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADXRyeUdldEJvb2xlYW4AAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGwAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAHQm9vbGVhbgQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgcFAAAAA3ZhbAEAAAAMdHJ5R2V0U3RyaW5nAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAk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heW1lbnRCb29sCQAAAgAAAAECAAAAJFBheW1lbnQgbXVzdCBiZSBpbiBXYXZlcyB0b2tlbnMgb25seQMJAABmAAAAAgUAAAALd2F2ZXNOZWVkZWQIBQAAAAxmaXJzdFBheW1lbnQAAAAGYW1vdW50CQAAAgAAAAECAAAAEkluc3VmZmljaWVudCBmdW5kcwkBAAAABV9taW50AAAAAwUAAAABaQUAAAAQdG90YWxQdW5rc1N1cHBseQUAAAAOYXZhaWxhYmxlUHVua3MAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQEIFXw=", "height": 2190205, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4zErmhgTQAwzcg5BXwwQMWWVnkhKUX5vhBbU3fJKqCM5 Next: none Diff:
Old | New | Differences | |
---|---|---|---|
14 | 14 | b | |
15 | 15 | case _ => | |
16 | 16 | 0 | |
17 | + | } | |
18 | + | val | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func tryGetBoolean (key) = { | |
23 | + | let val = match getBoolean(this, key) { | |
24 | + | case b: Boolean => | |
25 | + | b | |
26 | + | case _ => | |
27 | + | false | |
17 | 28 | } | |
18 | 29 | val | |
19 | 30 | } | |
95 | 106 | then throw("All punks are minted") | |
96 | 107 | else if ((availablePunks == "")) | |
97 | 108 | then throw("No punks available") | |
98 | - | else if ( | |
109 | + | else if (tryGetBoolean(toString(i.caller))) | |
99 | 110 | then { | |
100 | - | let index = match indexOf(preMintAddress, toString(i.caller)) { | |
101 | - | case b: Int => | |
102 | - | b | |
103 | - | case b: Unit => | |
104 | - | 0 | |
105 | - | case _ => | |
106 | - | throw("Match error") | |
107 | - | } | |
108 | - | let temp = (_mint(i, totalPunksSupply, availablePunks) ++ [StringEntry("premint_address", makeString(removeByIndex(preMintAddress, index), ","))]) | |
111 | + | let temp = _mint(i, totalPunksSupply, availablePunks) | |
109 | 112 | temp | |
110 | 113 | } | |
111 | 114 | else if ((startMint > lastBlock.timestamp)) |
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 | + | } | |
18 | + | val | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func tryGetBoolean (key) = { | |
23 | + | let val = match getBoolean(this, key) { | |
24 | + | case b: Boolean => | |
25 | + | b | |
26 | + | case _ => | |
27 | + | false | |
17 | 28 | } | |
18 | 29 | val | |
19 | 30 | } | |
20 | 31 | ||
21 | 32 | ||
22 | 33 | func tryGetString (key) = { | |
23 | 34 | let val = match getString(this, key) { | |
24 | 35 | case b: String => | |
25 | 36 | b | |
26 | 37 | case _ => | |
27 | 38 | "" | |
28 | 39 | } | |
29 | 40 | val | |
30 | 41 | } | |
31 | 42 | ||
32 | 43 | ||
33 | 44 | func getURL (id) = if (containsElement(split(tryGetString("gif_punk"), ","), id)) | |
34 | 45 | then (("https://mypunks.wavespunks.com/mad/m" + id) + ".gif") | |
35 | 46 | else (("https://mypunks.wavespunks.com/mad/m" + id) + ".png") | |
36 | 47 | ||
37 | 48 | ||
38 | 49 | func getTypePunk (id) = { | |
39 | 50 | let idINT = match parseInt(id) { | |
40 | 51 | case i: Int => | |
41 | 52 | i | |
42 | 53 | case i: Unit => | |
43 | 54 | 0 | |
44 | 55 | case _ => | |
45 | 56 | throw("Match error") | |
46 | 57 | } | |
47 | 58 | if (containsElement(split(tryGetString("gif_punk"), ","), toString(idINT))) | |
48 | 59 | then "ultra-rare" | |
49 | 60 | else if ((29 >= idINT)) | |
50 | 61 | then "rare" | |
51 | 62 | else "unique" | |
52 | 63 | } | |
53 | 64 | ||
54 | 65 | ||
55 | 66 | func getRandomNumber (variants,txId,heightBlock,offset) = { | |
56 | 67 | let randomSeedBlock = value(blockInfoByHeight((heightBlock - 1))) | |
57 | 68 | let randomHash = sha256_16Kb((txId + value(randomSeedBlock.vrf))) | |
58 | 69 | (toInt(randomHash, offset) % variants) | |
59 | 70 | } | |
60 | 71 | ||
61 | 72 | ||
62 | 73 | func calcWavesNeeded () = (waves * 6) | |
63 | 74 | ||
64 | 75 | ||
65 | 76 | func _mint (i,totalPunksSupply,availablePunks) = { | |
66 | 77 | let listAvailablePunks = split(availablePunks, ",") | |
67 | 78 | let rand = getRandomNumber((maxSupply - totalPunksSupply), i.transactionId, height, 0) | |
68 | 79 | let punkId = listAvailablePunks[rand] | |
69 | 80 | let name = ("MadPunk #" + punkId) | |
70 | 81 | let meta = tryGetString("collection_description") | |
71 | 82 | let asset = Issue(name, meta, 1, 0, false, unit, height) | |
72 | 83 | let assetId = calculateAssetId(asset) | |
73 | 84 | let tx = [IntegerEntry("punks_supply", (totalPunksSupply + 1)), StringEntry("available_punks", makeString(removeByIndex(listAvailablePunks, rand), ",")), asset, StringEntry(getPunkIDKey(punkId), toBase58String(assetId)), StringEntry((toBase58String(assetId) + "_id"), getPunkIDKey(punkId)), StringEntry((toBase58String(assetId) + "_type"), getTypePunk(punkId)), StringEntry((toBase58String(assetId) + "_url"), getURL(punkId)), StringEntry((toBase58String(assetId) + "_fraction"), tryGetString("fraction")), ScriptTransfer(i.caller, 1, assetId)] | |
74 | 85 | tx | |
75 | 86 | } | |
76 | 87 | ||
77 | 88 | ||
78 | 89 | @Callable(i) | |
79 | 90 | func mint () = { | |
80 | 91 | let totalPunksSupply = tryGetInteger("punks_supply") | |
81 | 92 | let availablePunks = tryGetString("available_punks") | |
82 | 93 | let preMintAddress = split(tryGetString("premint_address"), ",") | |
83 | 94 | let startMint = tryGetInteger("start_mint") | |
84 | 95 | let wavesNeeded = calcWavesNeeded() | |
85 | 96 | let firstPayment = value(i.payments[0]) | |
86 | 97 | let firstPaymentBool = match firstPayment.assetId { | |
87 | 98 | case t: ByteVector => | |
88 | 99 | true | |
89 | 100 | case w: Unit => | |
90 | 101 | false | |
91 | 102 | case _ => | |
92 | 103 | throw("Match error") | |
93 | 104 | } | |
94 | 105 | if ((totalPunksSupply == maxSupply)) | |
95 | 106 | then throw("All punks are minted") | |
96 | 107 | else if ((availablePunks == "")) | |
97 | 108 | then throw("No punks available") | |
98 | - | else if ( | |
109 | + | else if (tryGetBoolean(toString(i.caller))) | |
99 | 110 | then { | |
100 | - | let index = match indexOf(preMintAddress, toString(i.caller)) { | |
101 | - | case b: Int => | |
102 | - | b | |
103 | - | case b: Unit => | |
104 | - | 0 | |
105 | - | case _ => | |
106 | - | throw("Match error") | |
107 | - | } | |
108 | - | let temp = (_mint(i, totalPunksSupply, availablePunks) ++ [StringEntry("premint_address", makeString(removeByIndex(preMintAddress, index), ","))]) | |
111 | + | let temp = _mint(i, totalPunksSupply, availablePunks) | |
109 | 112 | temp | |
110 | 113 | } | |
111 | 114 | else if ((startMint > lastBlock.timestamp)) | |
112 | 115 | then throw("Mint hasn`t yet begun") | |
113 | 116 | else if (firstPaymentBool) | |
114 | 117 | then throw("Payment must be in Waves tokens only") | |
115 | 118 | else if ((wavesNeeded > firstPayment.amount)) | |
116 | 119 | then throw("Insufficient funds") | |
117 | 120 | else _mint(i, totalPunksSupply, availablePunks) | |
118 | 121 | } | |
119 | 122 | ||
120 | 123 | ||
121 | 124 | @Verifier(tx) | |
122 | 125 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
123 | 126 |
github/deemru/w8io/169f3d6 47.92 ms ◑