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