tx · 5TEsztvnFZqWVjjuXML6hJ5AeYet2SoXDJFz7EyXaifJ 3NAtXa4xfYy3teTxeJXWY4ZTD9KGpkyACHC: -0.01000000 Waves 2022.04.26 20:00 [2025727] smart account 3NAtXa4xfYy3teTxeJXWY4ZTD9KGpkyACHC > SELF 0.00000000 Waves
{ "type": 13, "id": "5TEsztvnFZqWVjjuXML6hJ5AeYet2SoXDJFz7EyXaifJ", "fee": 1000000, "feeAssetId": null, "timestamp": 1650992500133, "version": 2, "chainId": 84, "sender": "3NAtXa4xfYy3teTxeJXWY4ZTD9KGpkyACHC", "senderPublicKey": "CKnmMfPcdFm7C2Sy6TJPDKmAfFg31Dev2KLMojF9gWwp", "proofs": [ "2HkfwzGYrWg51Za3VnFBGC5nH4KNHgQLf64WxA89xP2kaHVgZn437P7z5BZB1xwfqr3Wn2eGdvGZojCG7vfRhXVs" ], "script": "base64:AAIFAAAAAAAAABQIAhIDCgEBEgUKAwgICBIAEgASAAAAABEAAAAAGG1heFRva2VuQW1vdW50Rm9yUHJlc2FsZQAAAAAAAJiWgAAAAAAHdG9rZW5JZAEAAAAgNYo72jcoRg/of7cVDwBC1pTiPWQ0w382jfiIIoYxtHMAAAAAA3d2cwAAAAAABfXhAAAAAAAOdG9rZW5Vbml0UHJpY2UAAAAAAAAAAAUAAAAAC2Rlbm9taW5hdG9yAAAAAAAAmJaAAAAAAA9kZWNpbWFsc0luVG9rZW4AAAAAAAAAAGQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADHRyeUdldFN0cmluZwAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACB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AAAAAFpAQAAAA1yZU9wZW5QcmVzYWxlAAAAAAMJAQAAAAIhPQAAAAIICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMIBQAAAAR0aGlzAAAABWJ5dGVzCQAAAgAAAAECAAAAIk9ubHkgT3duZXIgQ2FuIFJlLU9wZW4gdGhlIFByZXNhbGUJAARMAAAAAgkBAAAADEJvb2xlYW5FbnRyeQAAAAICAAAADXByZXNhbGVTdGF0dXMGBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlefpGVWc=", "height": 2025727, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: CDYXmg9TCXzPHJD2PVHbkA9miDTQm8eezhHv9yEbzBXN Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let maxTokenAmountForPresale = 10000000 | |
5 | + | ||
6 | + | let tokenId = base58'4bzs2y3QjBq4GEMrNcydRLMX1ReRrJ223fxNXyqyNUXL' | |
7 | + | ||
8 | + | let wvs = 100000000 | |
9 | + | ||
10 | + | let tokenUnitPrice = 5 | |
11 | + | ||
12 | + | let denominator = 10000000 | |
13 | + | ||
14 | + | let decimalsInToken = 100 | |
15 | + | ||
16 | + | func tryGetInteger (key) = { | |
17 | + | let val = match getInteger(this, key) { | |
18 | + | case b: Int => | |
19 | + | b | |
20 | + | case _ => | |
21 | + | 0 | |
22 | + | } | |
23 | + | val | |
24 | + | } | |
25 | + | ||
26 | + | ||
27 | + | func tryGetString (key) = { | |
28 | + | let val = match getString(this, key) { | |
29 | + | case b: String => | |
30 | + | b | |
31 | + | case _ => | |
32 | + | "" | |
33 | + | } | |
34 | + | val | |
35 | + | } | |
36 | + | ||
37 | + | ||
38 | + | func tryGetBoolean (key) = match getBoolean(this, key) { | |
39 | + | case b: Boolean => | |
40 | + | b | |
41 | + | case _ => | |
42 | + | false | |
43 | + | } | |
44 | + | ||
45 | + | ||
46 | + | func getCurrentTokenAmountBoughtFromPresale (addr) = { | |
47 | + | let val = tryGetInteger((addr + "_tokenPresale")) | |
48 | + | val | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | func getRemainingPresaleTokenAmount () = { | |
53 | + | let val = match getInteger(this, "remainingPresaleTokenAmount") { | |
54 | + | case b: Int => | |
55 | + | b | |
56 | + | case _ => | |
57 | + | maxTokenAmountForPresale | |
58 | + | } | |
59 | + | val | |
60 | + | } | |
61 | + | ||
62 | + | ||
63 | + | func getPresaleStatus () = match getBoolean(this, "presaleStatus") { | |
64 | + | case b: Boolean => | |
65 | + | b | |
66 | + | case _ => | |
67 | + | true | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | func getTotalNftCount () = { | |
72 | + | let val = match getInteger(this, "totalNftCount") { | |
73 | + | case b: Int => | |
74 | + | b | |
75 | + | case _ => | |
76 | + | 0 | |
77 | + | } | |
78 | + | val | |
79 | + | } | |
80 | + | ||
81 | + | ||
82 | + | func getRemainingNftCount () = { | |
83 | + | let val = match getInteger(this, "remainingNftCount") { | |
84 | + | case b: Int => | |
85 | + | b | |
86 | + | case _ => | |
87 | + | 0 | |
88 | + | } | |
89 | + | val | |
90 | + | } | |
91 | + | ||
92 | + | ||
93 | + | func getRemainingNfts () = { | |
94 | + | let val = match getString(this, "remainingNfts") { | |
95 | + | case b: String => | |
96 | + | b | |
97 | + | case _ => | |
98 | + | "" | |
99 | + | } | |
100 | + | val | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | func getNftSoldOutOrNot (nftId) = match getBoolean(this, (nftId + "_soldOut")) { | |
105 | + | case b: Boolean => | |
106 | + | b | |
107 | + | case _ => | |
108 | + | false | |
109 | + | } | |
110 | + | ||
111 | + | ||
112 | + | func getRandomNumber (i) = { | |
113 | + | let rand = ((((i.transactionId + i.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
114 | + | sha256(rand) | |
115 | + | } | |
116 | + | ||
117 | + | ||
118 | + | @Callable(i) | |
119 | + | func buyTokensFromPresale (buyAmount) = { | |
120 | + | let callerAddress = toBase58String(i.caller.bytes) | |
121 | + | let pmt = value(i.payments[0]) | |
122 | + | let amount = pmt.amount | |
123 | + | if (!(getPresaleStatus())) | |
124 | + | then throw("Presale Stopped by the Owner") | |
125 | + | else if ((buyAmount > getRemainingPresaleTokenAmount())) | |
126 | + | then throw("Exceeded Remaining Token Amount Dedicated for Presale") | |
127 | + | else if (((fraction(buyAmount, tokenUnitPrice, denominator) * wvs) > amount)) | |
128 | + | then throw("Not enough payments in waves") | |
129 | + | else [IntegerEntry((callerAddress + "_tokenPresale"), (buyAmount + getCurrentTokenAmountBoughtFromPresale(callerAddress))), IntegerEntry("remainingPresaleTokenAmount", (getRemainingPresaleTokenAmount() - buyAmount)), StringEntry((callerAddress + "_presaleAddresses"), callerAddress), ScriptTransfer(value(addressFromString(callerAddress)), (buyAmount * decimalsInToken), tokenId)] | |
130 | + | } | |
131 | + | ||
132 | + | ||
133 | + | ||
134 | + | @Callable(i) | |
135 | + | func mintNftByOwner (name,collectionId,metadata) = { | |
136 | + | let callerAddress = toBase58String(i.caller.bytes) | |
137 | + | if ((i.caller != this)) | |
138 | + | then throw("Only Dapp Owner Can Mint") | |
139 | + | else { | |
140 | + | let nft = Issue(name, metadata, 1, 0, false) | |
141 | + | let nftId = calculateAssetId(nft) | |
142 | + | let nftIdStr = toBase58String(nftId) | |
143 | + | [nft, StringEntry((nftIdStr + "_assetId"), nftIdStr), StringEntry((nftIdStr + "_ownerAddr"), callerAddress), StringEntry(((nftIdStr + "_collectionId_") + collectionId), nftIdStr), StringEntry("remainingNfts", ((getRemainingNfts() + nftIdStr) + "_")), IntegerEntry("totalNftCount", (getTotalNftCount() + 1)), IntegerEntry("remainingNftCount", (getRemainingNftCount() + 1)), BooleanEntry((nftIdStr + "_soldOut"), false)] | |
144 | + | } | |
145 | + | } | |
146 | + | ||
147 | + | ||
148 | + | ||
149 | + | @Callable(i) | |
150 | + | func buyNftsFromPresale () = { | |
151 | + | let callerAddress = toBase58String(i.caller.bytes) | |
152 | + | if (!(getPresaleStatus())) | |
153 | + | then throw("Presale Stopped by the Owner") | |
154 | + | else if ((getRemainingNftCount() == 0)) | |
155 | + | then throw("Nfts are not available for buying - all are sold") | |
156 | + | else { | |
157 | + | let remainingNftList = split(getRemainingNfts(), "_") | |
158 | + | let remainingNftListSize = getRemainingNftCount() | |
159 | + | let rand = toInt(getRandomNumber(i)) | |
160 | + | let position = (rand % remainingNftListSize) | |
161 | + | let selectedNftStr = remainingNftList[position] | |
162 | + | let updatedRemainingNftList = removeByIndex(remainingNftList, position) | |
163 | + | let updatedRemainingNftListAsString = makeString(updatedRemainingNftList, "_") | |
164 | + | [ScriptTransfer(value(addressFromString(callerAddress)), 1, fromBase58String(selectedNftStr)), StringEntry((selectedNftStr + "_ownerAddr"), callerAddress), IntegerEntry("remainingNftCount", (getRemainingNftCount() - 1)), StringEntry("remainingNfts", updatedRemainingNftListAsString), BooleanEntry((selectedNftStr + "_soldOut"), true)] | |
165 | + | } | |
166 | + | } | |
167 | + | ||
168 | + | ||
169 | + | ||
170 | + | @Callable(i) | |
171 | + | func stopPresale () = if ((i.caller.bytes != this.bytes)) | |
172 | + | then throw("Only Owner Can Stop the Presale") | |
173 | + | else [BooleanEntry("presaleStatus", false)] | |
174 | + | ||
175 | + | ||
176 | + | ||
177 | + | @Callable(i) | |
178 | + | func reOpenPresale () = if ((i.caller.bytes != this.bytes)) | |
179 | + | then throw("Only Owner Can Re-Open the Presale") | |
180 | + | else [BooleanEntry("presaleStatus", true)] | |
181 | + | ||
182 | + | ||
183 | + | @Verifier(tx) | |
184 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
185 | + |
github/deemru/w8io/026f985 47.42 ms ◑