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