tx · F9yC7kS5MPVahzRAQ1RdhVfCNfKasdiLdt8Mh4GZ75e4

3NCL8mJ7Bz1WhsfXSQvudfkdANqsj3PHoWX:  -0.00300000 Waves

2022.07.12 09:51 [2136176] smart account 3NCL8mJ7Bz1WhsfXSQvudfkdANqsj3PHoWX > SELF 0.00000000 Waves

{ "type": 13, "id": "F9yC7kS5MPVahzRAQ1RdhVfCNfKasdiLdt8Mh4GZ75e4", "fee": 300000, "feeAssetId": null, "timestamp": 1657608664099, "version": 2, "chainId": 84, "sender": "3NCL8mJ7Bz1WhsfXSQvudfkdANqsj3PHoWX", "senderPublicKey": "5pM26kLto6pmF7RYfyxha15pmBXCxZ485PDWvdT6HGHN", "proofs": [ "4uubUW3yyqp9Nuo64dqaZ9WsRf9TdWX9VbbATsuhJZck1Ld63igBYjQnwktVnWdM1TLjKyVVmqN6XfQ5UJussDjh" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAACQAAAAAJbWF4U3VwcGx5AAAAAAAAAAPoAAAAAAV3YXZlcwAAAAAABfXhAAEAAAAMZ2V0UHVua0lES2V5AAAAAQAAAAJpZAkAASwAAAACAgAAAAVwdW5rXwUAAAACaWQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADHRyeUdldFN0cmluZwAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWICAAAAAAUAAAADdmFsAQAAAAtnZXRUeXBlUHVuawAAAAEAAAACaWQEAAAABWlkSU5UBAAAAAckbWF0Y2gw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AAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlefuxTrQ=", "height": 2136176, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 7mY4XvT3mR83v7oZSE8BJRn759QajMRo1dV7pd7jqZfD Full:
OldNewDifferences
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 getTypePunk (id) = {
34+ let idINT = match parseInt(id) {
35+ case i: Int =>
36+ i
37+ case i: Unit =>
38+ 0
39+ case _ =>
40+ throw("Match error")
41+ }
42+ if ((idINT == 0))
43+ then "ultra-rare"
44+ else if ((40 >= idINT))
45+ then "rare"
46+ else "unique"
47+ }
48+
49+
50+func getURL (id) = (("https://mypunks.wavespunks.com/mad/m" + id) + ".png")
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 * 5)
61+
62+
63+@Callable(i)
64+func mint () = {
65+ let totalPunksSupply = tryGetInteger("punks_supply")
66+ let availablePunks = tryGetString("available_punks")
67+ let wavesNeeded = calcWavesNeeded()
68+ let firstPayment = value(i.payments[0])
69+ let firstPaymentBool = match firstPayment.assetId {
70+ case t: ByteVector =>
71+ true
72+ case w: Unit =>
73+ false
74+ case _ =>
75+ throw("Match error")
76+ }
77+ if ((totalPunksSupply == maxSupply))
78+ then throw("All punks are minted")
79+ else if ((availablePunks == ""))
80+ then throw("No punks available")
81+ else if (firstPaymentBool)
82+ then throw("Payment must be in Waves tokens only")
83+ else if ((wavesNeeded > firstPayment.amount))
84+ then throw("Insufficient funds")
85+ else {
86+ let listAvailablePunks = split(availablePunks, ",")
87+ let rand = getRandomNumber((maxSupply - totalPunksSupply), i.transactionId, height, 0)
88+ let punkId = listAvailablePunks[rand]
89+ let name = ("MadPunk #" + punkId)
90+ let meta = (((((("{\"id\": " + punkId) + ", \"type\": \"") + getTypePunk(punkId)) + "\", \"url\": \"") + getURL(punkId)) + "\"}")
91+ let asset = Issue(name, meta, 1, 0, false, unit, height)
92+ let assetId = calculateAssetId(asset)
93+[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)]
94+ }
95+ }
96+
97+
98+@Verifier(tx)
99+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
100+

github/deemru/w8io/026f985 
17.78 ms