39 | | - | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,royaltyPercentage,nft_description,nft_onSell,nft_data) = { |
---|
40 | | - | let newToken = Issue(nft_name, nft_description, 1, 0, false) |
---|
41 | | - | let issueId = calculateAssetId(newToken) |
---|
42 | | - | let txId = i.transactionId |
---|
43 | | - | [newToken, ScriptTransfer(i.caller, 1, issueId), StringEntry(((toBase58String(issueId) + separator) + "Owner"), toString(i.caller)), StringEntry(((toBase58String(issueId) + separator) + "nft_type"), nft_type), StringEntry(((toBase58String(issueId) + separator) + "nft_tags"), nft_tags), StringEntry(((toBase58String(issueId) + separator) + "nft_dAppAddress"), nft_dAppAddress), StringEntry(((toBase58String(txId) + separator) + "royaltyPercentage"), royaltyPercentage), IntegerEntry(((toBase58String(issueId) + separator) + "nft_selling_price"), nft_selling_price), StringEntry(((toBase58String(issueId) + separator) + "nft_onSell"), nft_onSell), StringEntry(((toBase58String(issueId) + separator) + "nft_data"), nft_data), StringEntry(((toBase58String(txId) + separator) + "issue_nft"), toBase58String(issueId))] |
---|
44 | | - | } |
---|
45 | | - | |
---|
46 | | - | |
---|
47 | | - | |
---|
48 | | - | @Callable(i) |
---|
49 | | - | func sellNFT (price,payment_currency) = { |
---|
50 | | - | let txId = i.transactionId |
---|
51 | | - | let seller = i.caller.bytes |
---|
52 | | - | let $t024992584 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
53 | | - | let token0 = $t024992584._1 |
---|
54 | | - | let amount0 = $t024992584._2 |
---|
55 | | - | if (!(isNft(token0))) |
---|
56 | | - | then throw("Token is not NFT") |
---|
57 | | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), (((toBase58String(token0) + separator) + toString(amount0)) + payment_currency))] |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | @Callable(i) |
---|
63 | | - | func buyNFT (nftID,current_nft_owner,creator,royaltyPercentage) = { |
---|
64 | | - | let assetId = fromBase58String(nftID) |
---|
65 | | - | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { |
---|
66 | | - | case a: String => |
---|
67 | | - | a |
---|
68 | | - | case _ => |
---|
69 | | - | false |
---|
70 | | - | } |
---|
71 | | - | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) |
---|
72 | | - | let amount = value(i.payments[0].amount) |
---|
73 | | - | let sellerAmount = (amount - ((amount / 1000) * 25)) |
---|
74 | | - | let platform_fee = (amount - sellerAmount) |
---|
75 | | - | let royaltyPercentage1 = royaltyPercentage |
---|
76 | | - | let royalityAmount = ((amount * parseIntValue(royaltyPercentage1)) / 100) |
---|
77 | | - | let sellerCost = (amount - (royalityAmount + platform_fee)) |
---|
78 | | - | if ((current_nft_owner == toString(i.caller))) |
---|
79 | | - | then throw("current Owner of NFT not able to purchase") |
---|
80 | | - | else if (if ((i.payments[0].assetId == teams)) |
---|
81 | | - | then (creator != current_nft_owner) |
---|
82 | | - | else false) |
---|
83 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), sellerCost, teams), ScriptTransfer(Address(fromBase58String(creator)), royalityAmount, teams), IntegerEntry((("nft_" + nftID) + "platform_fee"), platform_fee), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
84 | | - | else if (if ((i.payments[0].assetId == teams)) |
---|
85 | | - | then (creator == current_nft_owner) |
---|
86 | | - | else false) |
---|
87 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), sellerAmount, teams), StringEntry((("nft_" + nftID) + "platform_fee"), toString(platform_fee)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
88 | | - | else if (if ((i.payments[0].assetId == unit)) |
---|
89 | | - | then (creator != current_nft_owner) |
---|
90 | | - | else false) |
---|
91 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), sellerCost, unit), ScriptTransfer(Address(fromBase58String(creator)), royalityAmount, unit), StringEntry((("nft_" + nftID) + "platform_fee"), toString(platform_fee)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
92 | | - | else if (if ((i.payments[0].assetId == unit)) |
---|
93 | | - | then (creator == current_nft_owner) |
---|
94 | | - | else false) |
---|
95 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), sellerAmount, unit), StringEntry((("nft_" + nftID) + "platform_fee"), toString(platform_fee)), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner")), StringEntry((("nft_" + current_nft_owner) + "_owner"), toString(i.caller)), StringEntry(((nftID + separator) + "_owner"), toString(i.caller))] |
---|
96 | | - | else nil |
---|
97 | | - | } |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | |
---|
101 | | - | @Callable(i) |
---|
102 | | - | func cancelSell (nftId) = { |
---|
103 | | - | let txId = toBase58String(i.transactionId) |
---|
104 | | - | let seller = i.caller.bytes |
---|
105 | | - | [StringEntry(((txId + nftId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(seller), 1, fromBase58String(nftId))] |
---|
106 | | - | } |
---|
107 | | - | |
---|
108 | | - | |
---|
109 | | - | |
---|
110 | | - | @Callable(i) |
---|
111 | | - | func addAuction (start,end,startPrice,duration,payment_currency) = { |
---|
112 | | - | let txId = toBase58String(i.transactionId) |
---|
113 | | - | let nftId = value(i.payments[0].assetId) |
---|
114 | | - | let price = value(startPrice) |
---|
115 | | - | let endHeight = (lastBlock.height + duration) |
---|
| 9 | + | func asimiTransfer (recepientAddr) = { |
---|
117 | | - | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { |
---|
118 | | - | case a: String => |
---|
119 | | - | true |
---|
120 | | - | case _ => |
---|
121 | | - | false |
---|
122 | | - | } |
---|
123 | | - | if ((checkNftAuctioned == true)) |
---|
124 | | - | then throw("Already in auction list") |
---|
125 | | - | else if ((duration > maxAuctionDuration)) |
---|
126 | | - | then throw(("Duration is too long. Must be less than or equal to 30 " + toString(maxAuctionDuration))) |
---|
127 | | - | else if ((i.payments[0].assetId == unit)) |
---|
128 | | - | then throw("NFT not attached") |
---|
129 | | - | else if ((i.payments[0].assetId == teams)) |
---|
130 | | - | then throw("NFT not attached") |
---|
131 | | - | else [StringEntry(((txId + "nft_start_auction_date") + toBase58String(caller)), start), StringEntry(((txId + "nft_end_auction_date") + toBase58String(caller)), end), StringEntry((txId + "_nft_start_price"), startPrice), StringEntry((txId + "_nft_owner"), toString(i.caller)), StringEntry((txId + "_nft_on_auction"), toBase58String(nftId)), StringEntry((txId + "_previous_bidder"), "none"), StringEntry((txId + "_highest_bid"), "0"), StringEntry((txId + "_winner_of_nft"), "0"), StringEntry((txId + "_bidder_count"), "0"), StringEntry((txId + "_nft_status"), "OPEN")] |
---|
132 | | - | } |
---|
133 | | - | |
---|
134 | | - | |
---|
135 | | - | |
---|
136 | | - | @Callable(i) |
---|
137 | | - | func placeBid (auctionId,nftId,nft_owner,bid_price,current_currency) = { |
---|
138 | | - | let txId = toBase58String(i.transactionId) |
---|
139 | | - | let caller = i.caller.bytes |
---|
140 | | - | let assetId = fromBase58String(nftId) |
---|
141 | | - | let tokenType = i.payments[0].assetId |
---|
142 | | - | let currentBidPrice = i.payments[0].amount |
---|
143 | | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
144 | | - | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) |
---|
145 | | - | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) |
---|
146 | | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
147 | | - | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) |
---|
148 | | - | if ((checkNftAuctioned != "OPEN")) |
---|
149 | | - | then throw("Not open for auction") |
---|
150 | | - | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) |
---|
151 | | - | then throw("Bid is less then starting/highest Bid") |
---|
152 | | - | else if ((getLastWinnerBidPrice == "0")) |
---|
153 | | - | then [StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice)] |
---|
154 | | - | else if ((getLastWinnerBidPrice != "0")) |
---|
155 | | - | then [ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), tokenType), StringEntry((txId + "_previous_bid_amount_refund_to_address"), getLastWinnerAddress), StringEntry((txId + "_prevoius_bid_amount_refund"), getLastWinnerBidPrice), StringEntry((auctionId + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((auctionId + "_highest_bid"), toString(currentBidPrice)), StringEntry((auctionId + "_winner_of_nft"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_nft_id"), toBase58String(assetId)), StringEntry((auctionId + "_nft_owner"), nft_owner), StringEntry((((txId + "_") + auctionId) + "_highest_bid"), toString(currentBidPrice)), StringEntry((((txId + "_") + auctionId) + "_winner"), toBase58String(i.caller.bytes)), StringEntry((((txId + "_") + auctionId) + "_bidder_count"), toString((parseIntValue(currentBidCount) + 1))), StringEntry((((txId + "_") + auctionId) + "_nft_id"), toBase58String(assetId)), StringEntry((((txId + "_") + auctionId) + "_nft_owner"), nft_owner), StringEntry((txId + "_bid_for_nft_by"), toBase58String(caller)), StringEntry((txId + "_bid_price_place"), bid_price)] |
---|
156 | | - | else nil |
---|
157 | | - | } |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | |
---|
161 | | - | @Callable(i) |
---|
162 | | - | func acceptBidOffer (auctionId,nftId,bid_amount_from_user,creator,royaltyPercentage,current_currency) = { |
---|
163 | | - | let asimiString = "9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq" |
---|
164 | | - | let txId = toBase58String(i.transactionId) |
---|
165 | | - | let amountUnit = fromBase58String(current_currency) |
---|
166 | | - | let caller = i.caller.bytes |
---|
167 | | - | let assetId = fromBase58String(nftId) |
---|
168 | | - | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
169 | | - | let getNftWinningamount = ((parseIntValue(getNftWinningPrice) / 1000) * 975) |
---|
170 | | - | let platform_fee = ((parseIntValue(getNftWinningPrice) / 1000) * 25) |
---|
171 | | - | let royalityAmount = ((parseIntValue(getNftWinningPrice) / 100) * parseIntValue(royaltyPercentage)) |
---|
172 | | - | let auctionerCost = (parseIntValue(getNftWinningPrice) - (royalityAmount + platform_fee)) |
---|
173 | | - | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
174 | | - | if (if ((current_currency == asimiString)) |
---|
175 | | - | then (toUtf8String(caller) == creator) |
---|
176 | | - | else false) |
---|
177 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, amountUnit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] |
---|
178 | | - | else if (if ((current_currency == asimiString)) |
---|
179 | | - | then (toUtf8String(caller) != creator) |
---|
180 | | - | else false) |
---|
181 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, amountUnit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), ScriptTransfer(Address(fromBase58String(creator)), auctionerCost, amountUnit), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] |
---|
182 | | - | else if (if ((current_currency == "WAVES")) |
---|
183 | | - | then (toUtf8String(caller) == creator) |
---|
184 | | - | else false) |
---|
185 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] |
---|
186 | | - | else if (if ((current_currency == "WAVES")) |
---|
187 | | - | then (toUtf8String(caller) != creator) |
---|
188 | | - | else false) |
---|
189 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), ScriptTransfer(Address(fromBase58String(creator)), auctionerCost, unit), StringEntry((txId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((txId + "_nft_transfer_to"), getAuctionWinner), StringEntry((txId + "_nft_status"), "REWARDED"), StringEntry((auctionId + "_amount_paid_to_owner"), getNftWinningPrice), StringEntry((auctionId + "_nft_transfer_to"), getAuctionWinner), StringEntry((auctionId + "_nft_status"), "REWARDED")] |
---|
190 | | - | else nil |
---|
191 | | - | } |
---|
192 | | - | |
---|
193 | | - | |
---|
194 | | - | |
---|
195 | | - | @Callable(i) |
---|
196 | | - | func cancelAuction (auctionId) = { |
---|
197 | | - | let txId = toBase58String(i.transactionId) |
---|
198 | | - | let caller = i.caller.bytes |
---|
199 | | - | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) |
---|
200 | | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
201 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
202 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
203 | | - | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
204 | | - | if ((biddingWinner == "0")) |
---|
205 | | - | then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
206 | | - | else if ((biddingWinner != "0")) |
---|
207 | | - | then throw("soory you can't cancel it because already auction placed by someone") |
---|
208 | | - | else nil |
---|
209 | | - | } |
---|
210 | | - | |
---|
211 | | - | |
---|
212 | | - | |
---|
213 | | - | @Callable(i) |
---|
214 | | - | func manualFundTransfer (recepientAddr,message) = { |
---|
215 | | - | let sender = i.caller.bytes |
---|
218 | | - | let platform_fee = ((amount / 1000) * 25) |
---|
219 | | - | let recepient_payment = (amount - platform_fee) |
---|
220 | | - | if ((i.payments[0].assetId == unit)) |
---|
221 | | - | then [IntegerEntry((toBase58String(sender) + "_transfer"), amount), StringEntry("platform_fee", toString(platform_fee)), StringEntry((toBase58String(sender) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), recepient_payment, unit)] |
---|
222 | | - | else if ((i.payments[0].assetId == teams)) |
---|
223 | | - | then [IntegerEntry((toBase58String(sender) + "_transfer"), amount), IntegerEntry("platform_fee", platform_fee), StringEntry((toBase58String(sender) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), recepient_payment, teams)] |
---|
224 | | - | else nil |
---|
225 | | - | } |
---|
226 | | - | |
---|
227 | | - | |
---|
228 | | - | |
---|
229 | | - | @Callable(i) |
---|
230 | | - | func nftback (auctionId) = { |
---|
231 | | - | let caller = i.caller.bytes |
---|
232 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
233 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
234 | | - | [StringEntry((auctionId + "_nft_status"), "Auction_time over"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
235 | | - | } |
---|
236 | | - | |
---|
237 | | - | |
---|
238 | | - | |
---|
239 | | - | @Callable(i) |
---|
240 | | - | func withdrawMoney (auctionId,current_currency) = { |
---|
241 | | - | let caller = i.caller.bytes |
---|
242 | | - | let asimiString = "9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq" |
---|
243 | | - | let txId = toBase58String(i.transactionId) |
---|
244 | | - | let amountUnit = fromBase58String(current_currency) |
---|
245 | | - | let bidPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
246 | | - | let asBidder = getStringValue(this, (auctionId + "_winner")) |
---|
247 | | - | let bidForNFT = getStringValue(this, (auctionId + "_nft_id")) |
---|
248 | | - | if ((current_currency == asimiString)) |
---|
249 | | - | then [StringEntry((auctionId + "_nft_bid"), "WITHDRAW"), StringEntry((auctionId + "_nft_id"), bidForNFT), StringEntry((auctionId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), amountUnit)] |
---|
250 | | - | else if ((current_currency == "WAVES")) |
---|
251 | | - | then [StringEntry((auctionId + "_nft_bid"), "WITHDRAW"), StringEntry((auctionId + "_nft_id"), bidForNFT), StringEntry((auctionId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] |
---|
252 | | - | else nil |
---|
253 | | - | } |
---|
254 | | - | |
---|
255 | | - | |
---|
256 | | - | |
---|
257 | | - | @Callable(i) |
---|
258 | | - | func buyAllProducts_asimi (nftInfo) = { |
---|
259 | | - | let buyer = i.caller |
---|
260 | | - | let buyerBalance = assetBalance(buyer, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq') |
---|
261 | | - | let nfT1 = split(nftInfo[0], "_") |
---|
262 | | - | let nfT2 = split(nftInfo[1], "_") |
---|
263 | | - | let nfT3 = split(nftInfo[2], "_") |
---|
264 | | - | let nfT4 = split(nftInfo[3], "_") |
---|
265 | | - | let nfT5 = split(nftInfo[4], "_") |
---|
266 | | - | let amount = value(i.payments[0].amount) |
---|
267 | | - | let realcost = (amount - ((amount / 1000) * 25)) |
---|
268 | | - | let platformfee = (amount - realcost) |
---|
269 | | - | let royalityAmount = ((amount / 100) * parseIntValue(nfT1[3])) |
---|
270 | | - | let lastCost = (amount - (royalityAmount + platformfee)) |
---|
271 | | - | let amount1 = value(i.payments[1].amount) |
---|
272 | | - | let realcost1 = (amount1 - ((amount1 / 1000) * 25)) |
---|
273 | | - | let platformfee1 = (amount1 - realcost1) |
---|
274 | | - | let royalityAmount1 = ((amount1 / 100) * parseIntValue(nfT2[3])) |
---|
275 | | - | let lastCost1 = (amount1 - (royalityAmount1 + platformfee1)) |
---|
276 | | - | let amount2 = value(i.payments[2].amount) |
---|
277 | | - | let realcost2 = (amount2 - ((amount2 / 1000) * 25)) |
---|
278 | | - | let platformfee2 = (amount2 - realcost2) |
---|
279 | | - | let royalityAmount2 = ((amount2 / 100) * parseIntValue(nfT3[3])) |
---|
280 | | - | let lastCost2 = (amount2 - (royalityAmount2 + platformfee2)) |
---|
281 | | - | let amount3 = value(i.payments[3].amount) |
---|
282 | | - | let realcost3 = (amount3 - ((amount3 / 1000) * 25)) |
---|
283 | | - | let platformfee3 = (amount3 - realcost3) |
---|
284 | | - | let royalityAmount3 = ((amount3 / 100) * parseIntValue(nfT4[3])) |
---|
285 | | - | let lastCost3 = (amount3 - (royalityAmount3 + platformfee3)) |
---|
286 | | - | let amount4 = value(i.payments[4].amount) |
---|
287 | | - | let realcost4 = (amount4 - ((amount4 / 1000) * 25)) |
---|
288 | | - | let platformfee4 = (amount4 - realcost4) |
---|
289 | | - | let royalityAmount4 = ((amount4 / 100) * parseIntValue(nfT5[3])) |
---|
290 | | - | let lastCost4 = (amount4 - (royalityAmount4 + platformfee4)) |
---|
291 | | - | if ((amount > buyerBalance)) |
---|
292 | | - | then throw("Buyer does not have enough funds to complete the purchase.") |
---|
293 | | - | else if ((size(nftInfo) == 1)) |
---|
294 | | - | then [StringEntry((((("first_nft_Info=" + "nftId") + nfT1[0]) + "creator") + nfT1[4]), ("buyer" + toString(buyer))), StringEntry((("first_nft_Info=" + "seller_address") + nfT1[1]), ("price" + nfT1[2])), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq')] |
---|
295 | | - | else if ((size(nftInfo) == 2)) |
---|
296 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq')] |
---|
297 | | - | else if ((size(nftInfo) == 3)) |
---|
298 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq')] |
---|
299 | | - | else if ((size(nftInfo) == 4)) |
---|
300 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT4[1])), lastCost3, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT4[4])), royalityAmount3, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq')] |
---|
301 | | - | else if ((size(nftInfo) == 5)) |
---|
302 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), StringEntry((((((("fifth_nft_Info=" + "nftId") + nfT5[0]) + "seller_address") + nfT5[1]) + "price") + nfT5[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT5[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT4[1])), lastCost3, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT4[4])), royalityAmount3, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT5[1])), lastCost4, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq'), ScriptTransfer(Address(fromBase58String(nfT5[4])), royalityAmount4, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq')] |
---|
303 | | - | else if ((size(nftInfo) > 5)) |
---|
304 | | - | then throw("sorry! maximum limit of your cart is 5 items") |
---|
305 | | - | else nil |
---|
306 | | - | } |
---|
307 | | - | |
---|
308 | | - | |
---|
309 | | - | |
---|
310 | | - | @Callable(i) |
---|
311 | | - | func buyAllProducts_waves (nftInfo) = { |
---|
312 | | - | let buyer = i.caller |
---|
313 | | - | let buyerBalance = assetBalance(buyer, WAVES) |
---|
314 | | - | let nfT1 = split(nftInfo[0], "_") |
---|
315 | | - | let nfT2 = split(nftInfo[1], "_") |
---|
316 | | - | let nfT3 = split(nftInfo[2], "_") |
---|
317 | | - | let nfT4 = split(nftInfo[3], "_") |
---|
318 | | - | let nfT5 = split(nftInfo[4], "_") |
---|
319 | | - | let amount = value(i.payments[0].amount) |
---|
320 | | - | let realcost = (amount - ((amount / 1000) * 25)) |
---|
321 | | - | let platformfee = (amount - realcost) |
---|
322 | | - | let royalityAmount = ((amount / 100) * parseIntValue(nfT1[3])) |
---|
323 | | - | let lastCost = (amount - (royalityAmount + platformfee)) |
---|
324 | | - | let amount1 = value(i.payments[1].amount) |
---|
325 | | - | let realcost1 = (amount1 - ((amount1 / 1000) * 25)) |
---|
326 | | - | let platformfee1 = (amount1 - realcost1) |
---|
327 | | - | let royalityAmount1 = ((amount1 / 100) * parseIntValue(nfT2[3])) |
---|
328 | | - | let lastCost1 = (amount1 - (royalityAmount1 + platformfee1)) |
---|
329 | | - | let amount2 = value(i.payments[2].amount) |
---|
330 | | - | let realcost2 = (amount2 - ((amount2 / 1000) * 25)) |
---|
331 | | - | let platformfee2 = (amount2 - realcost2) |
---|
332 | | - | let royalityAmount2 = ((amount2 / 100) * parseIntValue(nfT3[3])) |
---|
333 | | - | let lastCost2 = (amount2 - (royalityAmount2 + platformfee2)) |
---|
334 | | - | let amount3 = value(i.payments[3].amount) |
---|
335 | | - | let realcost3 = (amount3 - ((amount3 / 1000) * 25)) |
---|
336 | | - | let platformfee3 = (amount3 - realcost3) |
---|
337 | | - | let royalityAmount3 = ((amount3 / 100) * parseIntValue(nfT4[3])) |
---|
338 | | - | let lastCost3 = (amount3 - (royalityAmount3 + platformfee3)) |
---|
339 | | - | let amount4 = value(i.payments[4].amount) |
---|
340 | | - | let realcost4 = (amount4 - ((amount4 / 1000) * 25)) |
---|
341 | | - | let platformfee4 = (amount4 - realcost4) |
---|
342 | | - | let royalityAmount4 = ((amount4 / 100) * parseIntValue(nfT5[3])) |
---|
343 | | - | let lastCost4 = (amount4 - (royalityAmount4 + platformfee4)) |
---|
344 | | - | if ((amount > buyerBalance)) |
---|
345 | | - | then throw("Buyer does not have enough funds to complete the purchase.") |
---|
346 | | - | else if ((size(nftInfo) == 1)) |
---|
347 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, unit), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, unit)] |
---|
348 | | - | else if ((size(nftInfo) == 2)) |
---|
349 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, unit), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, unit), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, unit), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, unit)] |
---|
350 | | - | else if ((size(nftInfo) == 3)) |
---|
351 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, unit), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, unit), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, unit), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, unit), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, unit), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, unit)] |
---|
352 | | - | else if ((size(nftInfo) == 4)) |
---|
353 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, unit), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, unit), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, unit), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, unit), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, unit), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, unit), ScriptTransfer(Address(fromBase58String(nfT4[1])), lastCost3, unit), ScriptTransfer(Address(fromBase58String(nfT4[4])), royalityAmount3, unit)] |
---|
354 | | - | else if ((size(nftInfo) == 5)) |
---|
355 | | - | then [StringEntry((((((("first_nft_Info=" + "nftId") + nfT1[0]) + "seller_address") + nfT1[1]) + "price") + nfT1[2]), ("buyer" + toString(buyer))), StringEntry((((((("second_nft_Info=" + "nftId") + nfT2[0]) + "seller_address") + nfT2[1]) + "price") + nfT2[2]), ("buyer" + toString(buyer))), StringEntry((((((("third_nft_Info=" + "nftId") + nfT3[0]) + "seller_address") + nfT3[1]) + "price") + nfT3[2]), ("buyer" + toString(buyer))), StringEntry((((((("fourth_nft_Info=" + "nftId") + nfT4[0]) + "seller_address") + nfT4[1]) + "price") + nfT4[2]), ("buyer" + toString(buyer))), StringEntry((((((("fifth_nft_Info=" + "nftId") + nfT5[0]) + "seller_address") + nfT5[1]) + "price") + nfT5[2]), ("buyer" + toString(buyer))), ScriptTransfer(buyer, 1, fromBase58String(nfT1[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT2[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT3[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT4[0])), ScriptTransfer(buyer, 1, fromBase58String(nfT5[0])), ScriptTransfer(Address(fromBase58String(nfT1[1])), lastCost, unit), ScriptTransfer(Address(fromBase58String(nfT1[4])), royalityAmount, unit), ScriptTransfer(Address(fromBase58String(nfT2[1])), lastCost1, unit), ScriptTransfer(Address(fromBase58String(nfT2[4])), royalityAmount1, unit), ScriptTransfer(Address(fromBase58String(nfT3[1])), lastCost2, unit), ScriptTransfer(Address(fromBase58String(nfT3[4])), royalityAmount2, unit), ScriptTransfer(Address(fromBase58String(nfT4[1])), lastCost3, unit), ScriptTransfer(Address(fromBase58String(nfT4[4])), royalityAmount3, unit), ScriptTransfer(Address(fromBase58String(nfT5[1])), lastCost4, unit), ScriptTransfer(Address(fromBase58String(nfT5[4])), royalityAmount4, unit)] |
---|
356 | | - | else if ((size(nftInfo) > 5)) |
---|
357 | | - | then throw("sorry! maximum limit of your cart is 5 items") |
---|
358 | | - | else nil |
---|
| 13 | + | let senderBalance = assetBalance(i.caller, base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq') |
---|
| 14 | + | if ((i.payments[0].assetId == teams)) |
---|
| 15 | + | then [ScriptTransfer(Address(reciver), amount, teams), IntegerEntry((toBase58String(caller) + "_transfer"), amount), StringEntry((toBase58String(caller) + "_transfer_to"), recepientAddr)] |
---|
| 16 | + | else nil |
---|