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