tx · 8S69Em8547xCcoVMHqgqTrpHAHPtsQtiv1tn8UAuoJcr 3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo: -0.01400000 Waves 2021.10.07 11:12 [1735555] smart account 3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo > SELF 0.00000000 Waves
{ "type": 13, "id": "8S69Em8547xCcoVMHqgqTrpHAHPtsQtiv1tn8UAuoJcr", "fee": 1400000, "feeAssetId": null, "timestamp": 1633594419019, "version": 2, "chainId": 84, "sender": "3Mx1vNMiWzJ2NgY1t8bqsj8vvpxjaTLJWyo", "senderPublicKey": "5fUyPtPgB9o1mWXPYifKATuZc8PG2ErT5CGABbC7pu3", "proofs": [ "55RrVeTuky61BJFUREHjFatYbe3171tY8oL3ZyjTJtoNgXTBUWHJoCo2ADd1CvmDasZPEYjLt1GEVU68aNS8eUWM" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACAAAAAAJbWF4U3VwcGx5AAAAAAAAAAPoAAAAAAV3YXZlcwAAAAAABfXhAAEAAAAMZ2V0UHVua0lES2V5AAAAAQAAAAJpZAkAASwAAAACAgAAAAVwdW5rXwUAAAACaWQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADHRyeUdldFN0cmluZwAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWICAAAAAAUAAAADdmFsAQAAAA10cnlHZXRBZGRyZXNzAAAAAQAAAARhZGRyBAAAAAN2YWwEAAAAByRtY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atus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3o4QYBJZFHejgb4wf4uv8xH7WEmdWnBWfkGEFWdPb467 Next: bLLaqqkXHUgKA3gSYMfBk9tDPG98G7jTockmUpPVF15 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let maxSupply = | |
4 | + | let maxSupply = 1000 | |
5 | 5 | ||
6 | 6 | let waves = 100000000 | |
7 | 7 | ||
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | - | func calcWavesNeeded (totalPunksSupply) = if ((totalPunksSupply >= 1300)) | |
54 | - | then (waves * 20) | |
55 | - | else (((totalPunksSupply / 100) + 1) * waves) | |
53 | + | func calcWavesNeeded (totalPunksSupply) = (((totalPunksSupply / 100) + 1) * waves) | |
56 | 54 | ||
57 | 55 | ||
58 | 56 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let maxSupply = | |
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) = if ((totalPunksSupply >= 1300)) | |
54 | - | then (waves * 20) | |
55 | - | else (((totalPunksSupply / 100) + 1) * waves) | |
53 | + | func calcWavesNeeded (totalPunksSupply) = (((totalPunksSupply / 100) + 1) * waves) | |
56 | 54 | ||
57 | 55 | ||
58 | 56 | @Callable(i) | |
59 | 57 | func mint (ref) = { | |
60 | 58 | let totalPunksSupply = tryGetInteger("punks_supply") | |
61 | 59 | let availablePunks = tryGetString("available_punks") | |
62 | 60 | let wavesNeeded = calcWavesNeeded(totalPunksSupply) | |
63 | 61 | let firstPayment = value(i.payments[0]) | |
64 | 62 | let firstPaymentBool = match firstPayment.assetId { | |
65 | 63 | case t: ByteVector => | |
66 | 64 | true | |
67 | 65 | case w: Unit => | |
68 | 66 | false | |
69 | 67 | case _ => | |
70 | 68 | throw("Match error") | |
71 | 69 | } | |
72 | 70 | if ((totalPunksSupply == maxSupply)) | |
73 | 71 | then throw("All punks are minted") | |
74 | 72 | else if ((availablePunks == "")) | |
75 | 73 | then throw("No punks available") | |
76 | 74 | else if (firstPaymentBool) | |
77 | 75 | then throw("Payment must be in Waves tokens only") | |
78 | 76 | else if ((wavesNeeded > firstPayment.amount)) | |
79 | 77 | then throw("Insufficient funds") | |
80 | 78 | else { | |
81 | 79 | let listAvailablePunks = split(availablePunks, ",") | |
82 | 80 | let rand = getRandomNumber(totalPunksSupply, i.transactionId, height, 0) | |
83 | 81 | let punkId = listAvailablePunks[rand] | |
84 | 82 | let name = ("WavesPunk #" + punkId) | |
85 | 83 | let asset = Issue(name, name, 1, 0, false, unit, height) | |
86 | 84 | let assetId = calculateAssetId(asset) | |
87 | 85 | let referalAddress = tryGetAddress(ref) | |
88 | 86 | [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)] | |
89 | 87 | } | |
90 | 88 | } | |
91 | 89 | ||
92 | 90 | ||
93 | 91 | @Verifier(tx) | |
94 | 92 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
95 | 93 |
github/deemru/w8io/026f985 44.65 ms ◑