tx · FHCbrQ9aFy2exrNF76P2XbdFFCAniBt5XCACDP9sQyte 3NBPnEADc6KRTGyLYu277UVBVpATKuLStoo: -0.00500000 Waves 2022.12.01 20:49 [2341594] smart account 3NBPnEADc6KRTGyLYu277UVBVpATKuLStoo > SELF 0.00000000 Waves
{ "type": 13, "id": "FHCbrQ9aFy2exrNF76P2XbdFFCAniBt5XCACDP9sQyte", "fee": 500000, "feeAssetId": null, "timestamp": 1669916953823, "version": 2, "chainId": 84, "sender": "3NBPnEADc6KRTGyLYu277UVBVpATKuLStoo", "senderPublicKey": "aYCXwWE5HwK514PYuUxDBtXjyL3M32iEF6ria6Uh1iV", "proofs": [ "3EP6gfKsPgvjx3F8TGMgERVX1xNmsBT5finU5Tz6iQKZXKVMeBX9RnWeokTUUBior2QFSWd3g2JyowkN4YQXCWhi" ], "script": "base64:BgIMCAISBgoECAgICBIAAAIBaQEJY3JlYXRlTkZUBAduZnROYW1lB25mdERlc2MFaW1hZ2UOY29sbGVjdGlvbk5hbWUEBWlzc3VlCQDDCAcFB25mdE5hbWUFB25mdERlc2MAAQAABwUEdW5pdAAABAhhc3NldF9pZAkAuAgBBQVpc3N1ZQkAlAoCCQDMCAIFBWlzc3VlCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgABBQhhc3NldF9pZAUDbmlsCQDYBAEFCGFzc2V0X2lkAWkBB2J1cm5ORlQABAhhc3NldF9pZAkBBXZhbHVlAQgJAQV2YWx1ZQEJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkBAVhc3NldAkBBXZhbHVlAQkA7AcBBQhhc3NldF9pZAkAlAoCCQDMCAIJAQRCdXJuAgUIYXNzZXRfaWQAAQUDbmlsBQR1bml0AKsTU0w=", "height": 2341594, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9nRW1gbRLEhAyztEGAEh3EA3EFvarUzAiV5NSqxZa4tE Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let nft_creation_address = Address(base58'3N9bHBAZKai5SwrywMPLQpKmNePRQiHhW9S') | |
5 | - | ||
6 | - | let price_increase_period = 10 | |
7 | - | ||
8 | - | let mint_collection = "Clef genesis songs" | |
9 | - | ||
10 | - | let mint_description = "Genesis Clef song. This melody is crafted to become your electronic jam. Use it on clef.one 💚🤍" | |
11 | - | ||
12 | - | let hybrid_collection = "Clef mixes" | |
13 | - | ||
14 | - | let hybrid_description = "Clef mix. This melody was created by an algorithm. Enjoy this jam or use it on clef.one" | |
15 | - | ||
16 | - | func to_key (n) = toBase58String(toBytes(n)) | |
17 | - | ||
18 | - | ||
19 | - | func unique_bytes (i) = ((((i.transactionId + i.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
20 | - | ||
21 | - | ||
22 | - | func random_uint (bytes,nonce) = { | |
23 | - | let n = toInt(sha256_16Kb((bytes + toBytes(nonce)))) | |
24 | - | if ((0 > n)) | |
25 | - | then -(n) | |
26 | - | else n | |
27 | - | } | |
28 | - | ||
29 | - | ||
30 | - | func pick_one (key_0,key_1,rand_int,bit_power) = if ((((rand_int / bit_power) % 2) == 0)) | |
31 | - | then key_0 | |
32 | - | else key_1 | |
33 | - | ||
34 | - | ||
35 | - | func hybrid_calculate_change (i,token,amount) = if ((size(i.payments) != 1)) | |
36 | - | then -1 | |
37 | - | else { | |
38 | - | let p = i.payments[0] | |
39 | - | let p_token = match p.assetId { | |
40 | - | case id: ByteVector => | |
41 | - | toBase58String(id) | |
42 | - | case _ => | |
43 | - | "" | |
44 | - | } | |
45 | - | if ((p_token != token)) | |
46 | - | then -1 | |
47 | - | else (p.amount - amount) | |
48 | - | } | |
49 | - | ||
50 | - | ||
51 | - | func make_hybrid_tx (i,song_0,song_1) = { | |
52 | - | let n = match getInteger("count") { | |
53 | - | case j: Int => | |
54 | - | j | |
55 | - | case _ => | |
56 | - | 0 | |
57 | - | } | |
58 | - | let name_short = take(("Clef " + toString(n)), 16) | |
59 | - | let description = hybrid_description | |
60 | - | let collection = hybrid_collection | |
61 | - | let id = match invoke(nft_creation_address, "createNFT", [name_short, description, getStringValue("market_image_link"), collection], nil) { | |
62 | - | case x: String => | |
63 | - | x | |
64 | - | case _ => | |
65 | - | throw("NFT creation failed") | |
66 | - | } | |
67 | - | if ((id == id)) | |
68 | - | then { | |
69 | - | let id_b = fromBase58String(id) | |
70 | - | let key = to_key(n) | |
71 | - | let bytes = unique_bytes(i) | |
72 | - | let rand_0 = random_uint(bytes, 0) | |
73 | - | let rand_1 = random_uint(bytes, 1) | |
74 | - | [IntegerEntry("count", (n + 1)), StringEntry(id, key), StringEntry(key, id), IntegerEntry((key + "_G"), (max([getIntegerValue((song_0 + "_G")), getIntegerValue((song_1 + "_G"))]) + 1)), StringEntry((key + "_SL"), ""), IntegerEntry((key + "_SN"), rand_0), StringEntry((key + "_SP0"), song_0), StringEntry((key + "_SP1"), song_1), IntegerEntry((key + "_SB0"), getIntegerValue((pick_one(song_0, song_1, rand_0, 1) + "_SB0"))), IntegerEntry((key + "_SB1"), getIntegerValue((pick_one(song_0, song_1, rand_0, 2) + "_SB1"))), IntegerEntry((key + "_SB2"), getIntegerValue((pick_one(song_0, song_1, rand_0, 4) + "_SB2"))), IntegerEntry((key + "_ST"), getIntegerValue((pick_one(song_0, song_1, rand_0, 8) + "_ST"))), StringEntry((key + "_SC0"), getStringValue((pick_one(song_0, song_1, rand_0, 16) + "_SC0"))), StringEntry((key + "_SC1"), getStringValue((pick_one(song_0, song_1, rand_0, 32) + "_SC1"))), StringEntry((key + "_SC2"), getStringValue((pick_one(song_0, song_1, rand_0, 64) + "_SC2"))), StringEntry((key + "_SC3"), getStringValue((pick_one(song_0, song_1, rand_0, 128) + "_SC3"))), StringEntry((key + "_SC4"), getStringValue((pick_one(song_0, song_1, rand_0, 512) + "_SC4"))), StringEntry((key + "_SC5"), getStringValue((pick_one(song_0, song_1, rand_0, 1024) + "_SC5"))), StringEntry((key + "_SC6"), getStringValue((pick_one(song_0, song_1, rand_0, 2048) + "_SC6"))), StringEntry((key + "_SC7"), getStringValue((pick_one(song_0, song_1, rand_0, 4096) + "_SC7"))), StringEntry((key + "_SA"), getStringValue((pick_one(song_0, song_1, rand_0, 8192) + "_SA"))), StringEntry((key + "_SI0"), getStringValue((pick_one(song_0, song_1, rand_0, 16384) + "_SI0"))), StringEntry((key + "_SI1"), getStringValue((pick_one(song_0, song_1, rand_0, 32768) + "_SI1"))), StringEntry((key + "_SI2"), getStringValue((pick_one(song_0, song_1, rand_0, 65536) + "_SI2"))), StringEntry((key + "_SI3"), getStringValue((pick_one(song_0, song_1, rand_0, 131072) + "_SI3"))), StringEntry((key + "_SI4"), getStringValue((pick_one(song_0, song_1, rand_0, 262144) + "_SI4"))), StringEntry((key + "_SI5"), getStringValue((pick_one(song_0, song_1, rand_0, 524288) + "_SI5"))), StringEntry((key + "_SI50"), getStringValue((pick_one(song_0, song_1, rand_0, 1048576) + "_SI50"))), StringEntry((key + "_SI51"), getStringValue((pick_one(song_0, song_1, rand_0, 2097152) + "_SI51"))), StringEntry((key + "_SI52"), getStringValue((pick_one(song_0, song_1, rand_0, 4194304) + "_SI52"))), StringEntry((key + "_SI53"), getStringValue((pick_one(song_0, song_1, rand_0, 8388608) + "_SI53"))), StringEntry((key + "_SI54"), getStringValue((pick_one(song_0, song_1, rand_0, 16777216) + "_SI54"))), StringEntry((key + "_SI55"), getStringValue((pick_one(song_0, song_1, rand_0, 33554432) + "_SI55"))), StringEntry((key + "_SI56"), getStringValue((pick_one(song_0, song_1, rand_0, 67108864) + "_SI56"))), StringEntry((key + "_SI57"), getStringValue((pick_one(song_0, song_1, rand_0, 134217728) + "_SI57"))), StringEntry((key + "_SI00"), getStringValue((pick_one(song_0, song_1, rand_0, 268435456) + "_SI00"))), StringEntry((key + "_SI01"), getStringValue((pick_one(song_0, song_1, rand_0, 536870912) + "_SI01"))), StringEntry((key + "_SI02"), getStringValue((pick_one(song_0, song_1, rand_0, 1073741824) + "_SI02"))), StringEntry((key + "_SI03"), getStringValue((pick_one(song_0, song_1, rand_0, 2147483648) + "_SI03"))), StringEntry((key + "_SI04"), getStringValue((pick_one(song_0, song_1, rand_0, 4294967296) + "_SI04"))), StringEntry((key + "_SI05"), getStringValue((pick_one(song_0, song_1, rand_0, 8589934592) + "_SI05"))), StringEntry((key + "_SI06"), getStringValue((pick_one(song_0, song_1, rand_1, 1) + "_SI06"))), StringEntry((key + "_SI07"), getStringValue((pick_one(song_0, song_1, rand_1, 2) + "_SI07"))), StringEntry((key + "_SI10"), getStringValue((pick_one(song_0, song_1, rand_1, 4) + "_SI10"))), StringEntry((key + "_SI11"), getStringValue((pick_one(song_0, song_1, rand_1, 8) + "_SI11"))), StringEntry((key + "_SI12"), getStringValue((pick_one(song_0, song_1, rand_1, 16) + "_SI12"))), StringEntry((key + "_SI13"), getStringValue((pick_one(song_0, song_1, rand_1, 32) + "_SI13"))), StringEntry((key + "_SI14"), getStringValue((pick_one(song_0, song_1, rand_1, 64) + "_SI14"))), StringEntry((key + "_SI15"), getStringValue((pick_one(song_0, song_1, rand_1, 128) + "_SI15"))), StringEntry((key + "_SI16"), getStringValue((pick_one(song_0, song_1, rand_1, 256) + "_SI16"))), StringEntry((key + "_SI17"), getStringValue((pick_one(song_0, song_1, rand_1, 512) + "_SI17"))), StringEntry((key + "_SI20"), getStringValue((pick_one(song_0, song_1, rand_1, 1024) + "_SI20"))), StringEntry((key + "_SI21"), getStringValue((pick_one(song_0, song_1, rand_1, 2048) + "_SI21"))), StringEntry((key + "_SI22"), getStringValue((pick_one(song_0, song_1, rand_1, 4096) + "_SI22"))), StringEntry((key + "_SI23"), getStringValue((pick_one(song_0, song_1, rand_1, 8192) + "_SI23"))), StringEntry((key + "_SI24"), getStringValue((pick_one(song_0, song_1, rand_1, 16384) + "_SI24"))), StringEntry((key + "_SI25"), getStringValue((pick_one(song_0, song_1, rand_1, 32768) + "_SI25"))), StringEntry((key + "_SI26"), getStringValue((pick_one(song_0, song_1, rand_1, 65536) + "_SI26"))), StringEntry((key + "_SI27"), getStringValue((pick_one(song_0, song_1, rand_1, 131072) + "_SI27"))), StringEntry((key + "_SI30"), getStringValue((pick_one(song_0, song_1, rand_1, 262144) + "_SI30"))), StringEntry((key + "_SI31"), getStringValue((pick_one(song_0, song_1, rand_1, 524288) + "_SI31"))), StringEntry((key + "_SI32"), getStringValue((pick_one(song_0, song_1, rand_1, 1048576) + "_SI32"))), StringEntry((key + "_SI33"), getStringValue((pick_one(song_0, song_1, rand_1, 2097152) + "_SI33"))), StringEntry((key + "_SI34"), getStringValue((pick_one(song_0, song_1, rand_1, 4194304) + "_SI34"))), StringEntry((key + "_SI35"), getStringValue((pick_one(song_0, song_1, rand_1, 8388608) + "_SI35"))), StringEntry((key + "_SI36"), getStringValue((pick_one(song_0, song_1, rand_1, 16777216) + "_SI36"))), StringEntry((key + "_SI37"), getStringValue((pick_one(song_0, song_1, rand_1, 33554432) + "_SI37"))), StringEntry((key + "_SI40"), getStringValue((pick_one(song_0, song_1, rand_1, 67108864) + "_SI40"))), StringEntry((key + "_SI41"), getStringValue((pick_one(song_0, song_1, rand_1, 134217728) + "_SI41"))), StringEntry((key + "_SI42"), getStringValue((pick_one(song_0, song_1, rand_1, 268435456) + "_SI42"))), StringEntry((key + "_SI43"), getStringValue((pick_one(song_0, song_1, rand_1, 536870912) + "_SI43"))), StringEntry((key + "_SI44"), getStringValue((pick_one(song_0, song_1, rand_1, 1073741824) + "_SI44"))), StringEntry((key + "_SI45"), getStringValue((pick_one(song_0, song_1, rand_1, 2147483648) + "_SI45"))), StringEntry((key + "_SI46"), getStringValue((pick_one(song_0, song_1, rand_1, 4294967296) + "_SI46"))), StringEntry((key + "_SI47"), getStringValue((pick_one(song_0, song_1, rand_1, 8589934592) + "_SI47"))), ScriptTransfer(Address(i.caller.bytes), 1, id_b)] | |
75 | - | } | |
76 | - | else throw("Strict value is not equal to itself.") | |
77 | - | } | |
78 | - | ||
79 | - | ||
80 | - | func check_whitelist (caller) = if ((this == caller)) | |
81 | - | then true | |
82 | - | else match getBoolean(("W_" + toBase58String(caller.bytes))) { | |
83 | - | case x: Boolean => | |
84 | - | x | |
85 | - | case _ => | |
86 | - | false | |
87 | - | } | |
88 | 4 | ||
89 | 5 | ||
90 | 6 | @Callable(i) | |
91 | - | func whitelist_add (user) = if ((this != i.caller)) | |
92 | - | then throw("Caller is not dApp owner") | |
93 | - | else $Tuple2([BooleanEntry(("W_" + user), true)], unit) | |
94 | - | ||
95 | - | ||
96 | - | ||
97 | - | @Callable(i) | |
98 | - | func whitelist_remove (user) = if ((this != i.caller)) | |
99 | - | then throw("Caller is not dApp owner") | |
100 | - | else $Tuple2([DeleteEntry(("W_" + user))], unit) | |
101 | - | ||
102 | - | ||
103 | - | ||
104 | - | @Callable(i) | |
105 | - | func set_market_image (url) = if (!(check_whitelist(i.caller))) | |
106 | - | then throw("Caller not in whitelist") | |
107 | - | else $Tuple2([StringEntry("market_image_link", url)], unit) | |
108 | - | ||
109 | - | ||
110 | - | ||
111 | - | @Callable(i) | |
112 | - | func set_price_hybrid (token,amount,increment) = if (!(check_whitelist(i.caller))) | |
113 | - | then throw("Caller not in whitelist") | |
114 | - | else $Tuple2([StringEntry("price_hybrid_token", token), IntegerEntry("price_hybrid_amount", amount), IntegerEntry("price_hybrid_increment", increment)], unit) | |
115 | - | ||
116 | - | ||
117 | - | ||
118 | - | @Callable(i) | |
119 | - | func mint_chord (index,name,notes) = if (!(check_whitelist(i.caller))) | |
120 | - | then throw("Caller not in whitelist") | |
121 | - | else if ((size(notes) != 5)) | |
122 | - | then throw("Wrong notes size") | |
123 | - | else { | |
124 | - | let n = match getInteger("count") { | |
125 | - | case j: Int => | |
126 | - | j | |
127 | - | case _ => | |
128 | - | 0 | |
129 | - | } | |
130 | - | let key = to_key(index) | |
131 | - | $Tuple2([IntegerEntry("count", max([(index + 1), n])), StringEntry((key + "_CL"), name), IntegerEntry((key + "_C0"), notes[0]), IntegerEntry((key + "_C1"), notes[1]), IntegerEntry((key + "_C2"), notes[2]), IntegerEntry((key + "_C3"), notes[3]), IntegerEntry((key + "_C4"), notes[4])], unit) | |
132 | - | } | |
133 | - | ||
134 | - | ||
135 | - | ||
136 | - | @Callable(i) | |
137 | - | func mint_arpeggio (index,name,notes) = if (!(check_whitelist(i.caller))) | |
138 | - | then throw("Caller not in whitelist") | |
139 | - | else if ((size(notes) != 16)) | |
140 | - | then throw("Wrong notes size") | |
141 | - | else { | |
142 | - | let n = match getInteger("count") { | |
143 | - | case j: Int => | |
144 | - | j | |
145 | - | case _ => | |
146 | - | 0 | |
147 | - | } | |
148 | - | let key = to_key(index) | |
149 | - | $Tuple2([IntegerEntry("count", max([(index + 1), n])), StringEntry((key + "_AL"), name), IntegerEntry((key + "_A00"), notes[0]), IntegerEntry((key + "_A01"), notes[1]), IntegerEntry((key + "_A02"), notes[2]), IntegerEntry((key + "_A03"), notes[3]), IntegerEntry((key + "_A04"), notes[4]), IntegerEntry((key + "_A05"), notes[5]), IntegerEntry((key + "_A06"), notes[6]), IntegerEntry((key + "_A07"), notes[7]), IntegerEntry((key + "_A08"), notes[8]), IntegerEntry((key + "_A09"), notes[9]), IntegerEntry((key + "_A10"), notes[10]), IntegerEntry((key + "_A11"), notes[11]), IntegerEntry((key + "_A12"), notes[12]), IntegerEntry((key + "_A13"), notes[13]), IntegerEntry((key + "_A14"), notes[14]), IntegerEntry((key + "_A15"), notes[15])], unit) | |
150 | - | } | |
151 | - | ||
152 | - | ||
153 | - | ||
154 | - | @Callable(i) | |
155 | - | func mint_rhythm (index,name,scale,notes) = if (!(check_whitelist(i.caller))) | |
156 | - | then throw("Caller not in whitelist") | |
157 | - | else if ((size(notes) != 16)) | |
158 | - | then throw("Wrong notes size") | |
159 | - | else { | |
160 | - | let n = match getInteger("count") { | |
161 | - | case j: Int => | |
162 | - | j | |
163 | - | case _ => | |
164 | - | 0 | |
165 | - | } | |
166 | - | let key = to_key(index) | |
167 | - | $Tuple2([IntegerEntry("count", max([(index + 1), n])), StringEntry((key + "_RL"), name), IntegerEntry((key + "_RS"), scale), IntegerEntry((key + "_R00"), notes[0]), IntegerEntry((key + "_R01"), notes[1]), IntegerEntry((key + "_R02"), notes[2]), IntegerEntry((key + "_R03"), notes[3]), IntegerEntry((key + "_R04"), notes[4]), IntegerEntry((key + "_R05"), notes[5]), IntegerEntry((key + "_R06"), notes[6]), IntegerEntry((key + "_R07"), notes[7]), IntegerEntry((key + "_R08"), notes[8]), IntegerEntry((key + "_R09"), notes[9]), IntegerEntry((key + "_R10"), notes[10]), IntegerEntry((key + "_R11"), notes[11]), IntegerEntry((key + "_R12"), notes[12]), IntegerEntry((key + "_R13"), notes[13]), IntegerEntry((key + "_R14"), notes[14]), IntegerEntry((key + "_R15"), notes[15])], unit) | |
168 | - | } | |
169 | - | ||
170 | - | ||
171 | - | ||
172 | - | @Callable(i) | |
173 | - | func burn_internal (asset_id) = if (!(check_whitelist(i.caller))) | |
174 | - | then throw("Caller not in whitelist") | |
175 | - | else { | |
176 | - | let burn0 = invoke(nft_creation_address, "burnNFT", nil, [AttachedPayment(fromBase58String(asset_id), 1)]) | |
177 | - | if ((burn0 == burn0)) | |
178 | - | then $Tuple2(nil, unit) | |
179 | - | else throw("Strict value is not equal to itself.") | |
180 | - | } | |
181 | - | ||
182 | - | ||
183 | - | ||
184 | - | @Callable(i) | |
185 | - | func burn () = if (!(check_whitelist(i.caller))) | |
186 | - | then throw("Caller not in whitelist") | |
187 | - | else { | |
188 | - | let burn0 = invoke(nft_creation_address, "burnNFT", nil, [i.payments[0]]) | |
189 | - | if ((burn0 == burn0)) | |
190 | - | then $Tuple2(nil, unit) | |
191 | - | else throw("Strict value is not equal to itself.") | |
192 | - | } | |
193 | - | ||
194 | - | ||
195 | - | ||
196 | - | @Callable(i) | |
197 | - | func mint_song (name,parent_0,parent_1,bpm,bar_size,beat_size,tonality,chords,arpeggio,kick_instrument,snare_instrument,hihat_instrument,bass_instrument,back_instrument,lead_instrument,kick_rhythms,snare_rhythms,hihat_rhythms,bass_rhythms,back_rhythms,lead_rhythms) = if (!(check_whitelist(i.caller))) | |
198 | - | then throw("Caller not in whitelist") | |
199 | - | else if ((size(chords) != 8)) | |
200 | - | then throw("Wrong chords size") | |
201 | - | else if ((size(kick_rhythms) != 8)) | |
202 | - | then throw("Wrong kick rhythms size") | |
203 | - | else if ((size(snare_rhythms) != 8)) | |
204 | - | then throw("Wrong snare rhythms size") | |
205 | - | else if ((size(hihat_rhythms) != 8)) | |
206 | - | then throw("Wrong hihat rhythms size") | |
207 | - | else if ((size(bass_rhythms) != 8)) | |
208 | - | then throw("Wrong bass rhythms size") | |
209 | - | else if ((size(back_rhythms) != 8)) | |
210 | - | then throw("Wrong back rhythms size") | |
211 | - | else if ((size(lead_rhythms) != 8)) | |
212 | - | then throw("Wrong lead rhythms size") | |
213 | - | else { | |
214 | - | let n = match getInteger("count") { | |
215 | - | case j: Int => | |
216 | - | j | |
217 | - | case _ => | |
218 | - | 0 | |
219 | - | } | |
220 | - | let name_short = take(name, 16) | |
221 | - | let description = mint_description | |
222 | - | let collection = mint_collection | |
223 | - | let id = match invoke(nft_creation_address, "createNFT", [name_short, description, getStringValue("market_image_link"), collection], nil) { | |
224 | - | case x: String => | |
225 | - | x | |
226 | - | case _ => | |
227 | - | throw("NFT creation failed") | |
228 | - | } | |
229 | - | if ((id == id)) | |
230 | - | then { | |
231 | - | let key = to_key(n) | |
232 | - | let tx_transfer = if ((this != i.caller)) | |
233 | - | then [ScriptTransfer(Address(i.caller.bytes), 1, fromBase58String(id))] | |
234 | - | else nil | |
235 | - | $Tuple2(([IntegerEntry("count", (n + 1)), StringEntry(id, key), StringEntry(key, id), IntegerEntry((key + "_G"), 1), StringEntry((key + "_SL"), name), IntegerEntry((key + "_SN"), 0), StringEntry((key + "_SP0"), parent_0), StringEntry((key + "_SP1"), parent_1), IntegerEntry((key + "_SB0"), bpm), IntegerEntry((key + "_SB1"), bar_size), IntegerEntry((key + "_SB2"), beat_size), IntegerEntry((key + "_ST"), tonality), StringEntry((key + "_SC0"), chords[0]), StringEntry((key + "_SC1"), chords[1]), StringEntry((key + "_SC2"), chords[2]), StringEntry((key + "_SC3"), chords[3]), StringEntry((key + "_SC4"), chords[4]), StringEntry((key + "_SC5"), chords[5]), StringEntry((key + "_SC6"), chords[6]), StringEntry((key + "_SC7"), chords[7]), StringEntry((key + "_SA"), arpeggio), StringEntry((key + "_SI0"), kick_instrument), StringEntry((key + "_SI1"), snare_instrument), StringEntry((key + "_SI2"), hihat_instrument), StringEntry((key + "_SI3"), bass_instrument), StringEntry((key + "_SI4"), back_instrument), StringEntry((key + "_SI5"), lead_instrument), StringEntry((key + "_SI00"), kick_rhythms[0]), StringEntry((key + "_SI01"), kick_rhythms[1]), StringEntry((key + "_SI02"), kick_rhythms[2]), StringEntry((key + "_SI03"), kick_rhythms[3]), StringEntry((key + "_SI04"), kick_rhythms[4]), StringEntry((key + "_SI05"), kick_rhythms[5]), StringEntry((key + "_SI06"), kick_rhythms[6]), StringEntry((key + "_SI07"), kick_rhythms[7]), StringEntry((key + "_SI10"), snare_rhythms[0]), StringEntry((key + "_SI11"), snare_rhythms[1]), StringEntry((key + "_SI12"), snare_rhythms[2]), StringEntry((key + "_SI13"), snare_rhythms[3]), StringEntry((key + "_SI14"), snare_rhythms[4]), StringEntry((key + "_SI15"), snare_rhythms[5]), StringEntry((key + "_SI16"), snare_rhythms[6]), StringEntry((key + "_SI17"), snare_rhythms[7]), StringEntry((key + "_SI20"), hihat_rhythms[0]), StringEntry((key + "_SI21"), hihat_rhythms[1]), StringEntry((key + "_SI22"), hihat_rhythms[2]), StringEntry((key + "_SI23"), hihat_rhythms[3]), StringEntry((key + "_SI24"), hihat_rhythms[4]), StringEntry((key + "_SI25"), hihat_rhythms[5]), StringEntry((key + "_SI26"), hihat_rhythms[6]), StringEntry((key + "_SI27"), hihat_rhythms[7]), StringEntry((key + "_SI30"), bass_rhythms[0]), StringEntry((key + "_SI31"), bass_rhythms[1]), StringEntry((key + "_SI32"), bass_rhythms[2]), StringEntry((key + "_SI33"), bass_rhythms[3]), StringEntry((key + "_SI34"), bass_rhythms[4]), StringEntry((key + "_SI35"), bass_rhythms[5]), StringEntry((key + "_SI36"), bass_rhythms[6]), StringEntry((key + "_SI37"), bass_rhythms[7]), StringEntry((key + "_SI40"), back_rhythms[0]), StringEntry((key + "_SI41"), back_rhythms[1]), StringEntry((key + "_SI42"), back_rhythms[2]), StringEntry((key + "_SI43"), back_rhythms[3]), StringEntry((key + "_SI44"), back_rhythms[4]), StringEntry((key + "_SI45"), back_rhythms[5]), StringEntry((key + "_SI46"), back_rhythms[6]), StringEntry((key + "_SI47"), back_rhythms[7]), StringEntry((key + "_SI50"), lead_rhythms[0]), StringEntry((key + "_SI51"), lead_rhythms[1]), StringEntry((key + "_SI52"), lead_rhythms[2]), StringEntry((key + "_SI53"), lead_rhythms[3]), StringEntry((key + "_SI54"), lead_rhythms[4]), StringEntry((key + "_SI55"), lead_rhythms[5]), StringEntry((key + "_SI56"), lead_rhythms[6]), StringEntry((key + "_SI57"), lead_rhythms[7])] ++ tx_transfer), unit) | |
236 | - | } | |
237 | - | else throw("Strict value is not equal to itself.") | |
238 | - | } | |
239 | - | ||
240 | - | ||
241 | - | ||
242 | - | @Callable(i) | |
243 | - | func mint_hybrid (song_0,song_1) = { | |
244 | - | let caller_addr = Address(i.caller.bytes) | |
245 | - | let song_0_id = fromBase58String(getStringValue(song_0)) | |
246 | - | let song_1_id = fromBase58String(getStringValue(song_1)) | |
247 | - | let price_amount = getIntegerValue("price_hybrid_amount") | |
248 | - | let price_token = getStringValue("price_hybrid_token") | |
249 | - | let price_change = hybrid_calculate_change(i, price_token, price_amount) | |
250 | - | if ((0 > price_change)) | |
251 | - | then throw("Wrong payment") | |
252 | - | else if ((song_0_id == song_1_id)) | |
253 | - | then throw("Songs should be different") | |
254 | - | else if ((1 > assetBalance(caller_addr, song_0_id))) | |
255 | - | then throw("Caller do not own first song") | |
256 | - | else if ((1 > assetBalance(caller_addr, song_1_id))) | |
257 | - | then throw("Caller do not own second song") | |
258 | - | else { | |
259 | - | let mint_count = match getInteger("mint_count") { | |
260 | - | case j: Int => | |
261 | - | j | |
262 | - | case _ => | |
263 | - | 0 | |
264 | - | } | |
265 | - | let price_count_inc = IntegerEntry("mint_count", (mint_count + 1)) | |
266 | - | let price_increase = if (((mint_count % price_increase_period) == (price_increase_period - 1))) | |
267 | - | then [price_count_inc, IntegerEntry("price_hybrid_amount", (price_amount + getIntegerValue("price_hybrid_increment")))] | |
268 | - | else [price_count_inc] | |
269 | - | if ((price_change > 0)) | |
270 | - | then $Tuple2(((make_hybrid_tx(i, song_0, song_1) ++ price_increase) ++ [ScriptTransfer(Address(i.caller.bytes), price_change, if ((price_token == "")) | |
271 | - | then unit | |
272 | - | else fromBase58String(price_token))]), unit) | |
273 | - | else $Tuple2((make_hybrid_tx(i, song_0, song_1) ++ price_increase), unit) | |
274 | - | } | |
7 | + | func createNFT (nftName,nftDesc,image,collectionName) = { | |
8 | + | let issue = Issue(nftName, nftDesc, 1, 0, false, unit, 0) | |
9 | + | let asset_id = calculateAssetId(issue) | |
10 | + | $Tuple2([issue, ScriptTransfer(i.caller, 1, asset_id)], toBase58String(asset_id)) | |
275 | 11 | } | |
276 | 12 | ||
277 | 13 | ||
278 | 14 | ||
279 | 15 | @Callable(i) | |
280 | - | func mint_hybrid_and_burn () = if (if (if ((size(i.payments) != 2)) | |
281 | - | then true | |
282 | - | else (i.payments[0].amount != 1)) | |
283 | - | then true | |
284 | - | else (i.payments[1].amount != 1)) | |
285 | - | then throw("Wrong payment") | |
286 | - | else { | |
287 | - | let song_0_id = match i.payments[0].assetId { | |
288 | - | case b: ByteVector => | |
289 | - | b | |
290 | - | case _ => | |
291 | - | throw("Wrong payment") | |
292 | - | } | |
293 | - | let song_1_id = match i.payments[1].assetId { | |
294 | - | case b: ByteVector => | |
295 | - | b | |
296 | - | case _ => | |
297 | - | throw("Wrong payment") | |
298 | - | } | |
299 | - | if ((song_0_id == song_1_id)) | |
300 | - | then throw("Songs should be different") | |
301 | - | else { | |
302 | - | let song_0 = getStringValue(toBase58String(song_0_id)) | |
303 | - | let song_1 = getStringValue(toBase58String(song_1_id)) | |
304 | - | let burn0 = invoke(nft_creation_address, "burnNFT", nil, [i.payments[0]]) | |
305 | - | if ((burn0 == burn0)) | |
306 | - | then { | |
307 | - | let burn1 = invoke(nft_creation_address, "burnNFT", nil, [i.payments[1]]) | |
308 | - | if ((burn1 == burn1)) | |
309 | - | then $Tuple2(make_hybrid_tx(i, song_0, song_1), unit) | |
310 | - | else throw("Strict value is not equal to itself.") | |
311 | - | } | |
312 | - | else throw("Strict value is not equal to itself.") | |
313 | - | } | |
314 | - | } | |
16 | + | func burnNFT () = { | |
17 | + | let asset_id = value(value(i.payments[0]).assetId) | |
18 | + | let asset = value(assetInfo(asset_id)) | |
19 | + | $Tuple2([Burn(asset_id, 1)], unit) | |
20 | + | } | |
315 | 21 | ||
316 | 22 |
github/deemru/w8io/169f3d6 65.02 ms ◑