39 | | - | func setPaused (pause) = { |
---|
40 | | - | let caller = i.caller.bytes |
---|
41 | | - | if ((pause == "true")) |
---|
42 | | - | then [StringEntry(pause, ("true" + pause))] |
---|
43 | | - | else if ((paused == false)) |
---|
44 | | - | then [StringEntry(pause, ("false" + pause))] |
---|
45 | | - | else nil |
---|
46 | | - | } |
---|
47 | | - | |
---|
48 | | - | |
---|
49 | | - | |
---|
50 | | - | @Callable(i) |
---|
51 | | - | func createNft (pause,nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { |
---|
52 | | - | let newToken = Issue(nft_name, nft_description, 1, 0, false) |
---|
53 | | - | let issueId = calculateAssetId(newToken) |
---|
54 | | - | let txId = i.transactionId |
---|
55 | | - | if ((pause == "true")) |
---|
56 | | - | then throw("function is paused for sometimes") |
---|
57 | | - | else [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), 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))] |
---|
58 | | - | } |
---|
59 | | - | |
---|
60 | | - | |
---|
61 | | - | |
---|
62 | | - | @Callable(i) |
---|
63 | | - | func sellNFT (price,payment_currency) = { |
---|
64 | | - | let txId = i.transactionId |
---|
65 | | - | let seller = i.caller.bytes |
---|
66 | | - | let $t023562441 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) |
---|
67 | | - | let token0 = $t023562441._1 |
---|
68 | | - | let amount0 = $t023562441._2 |
---|
69 | | - | if (!(isNft(token0))) |
---|
70 | | - | then throw("Token is not NFT") |
---|
71 | | - | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), (((toBase58String(token0) + separator) + toString(amount0)) + payment_currency))] |
---|
72 | | - | } |
---|
73 | | - | |
---|
74 | | - | |
---|
75 | | - | |
---|
76 | | - | @Callable(i) |
---|
77 | | - | func buyNFT (nftID,current_nft_owner) = { |
---|
78 | | - | let assetId = fromBase58String(nftID) |
---|
79 | | - | let amount = value(i.payments[0].amount) |
---|
80 | | - | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { |
---|
81 | | - | case a: String => |
---|
82 | | - | a |
---|
83 | | - | case _ => |
---|
84 | | - | false |
---|
85 | | - | } |
---|
86 | | - | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) |
---|
87 | | - | let seller_amount = ((amount / 1000) * 975) |
---|
88 | | - | let platform_fee = ((amount / 1000) * 25) |
---|
89 | | - | if ((current_nft_owner == toString(i.caller))) |
---|
90 | | - | then throw("current Owner of NFT not able to purchase") |
---|
91 | | - | else if ((i.payments[0].assetId == teams)) |
---|
92 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), seller_amount, 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))] |
---|
93 | | - | else if ((i.payments[0].assetId == unit)) |
---|
94 | | - | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), seller_amount, 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))] |
---|
95 | | - | else nil |
---|
96 | | - | } |
---|
97 | | - | |
---|
98 | | - | |
---|
99 | | - | |
---|
100 | | - | @Callable(i) |
---|
101 | | - | func cancelSell (nftId) = { |
---|
102 | | - | let txId = toBase58String(i.transactionId) |
---|
103 | | - | let seller = i.caller.bytes |
---|
104 | | - | [StringEntry(((txId + nftId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(seller), 1, fromBase58String(nftId))] |
---|
105 | | - | } |
---|
106 | | - | |
---|
107 | | - | |
---|
108 | | - | |
---|
109 | | - | @Callable(i) |
---|
110 | | - | func addAuction (start,end,startPrice,duration,payment_currency) = { |
---|
111 | | - | let txId = toBase58String(i.transactionId) |
---|
112 | | - | let nftId = value(i.payments[0].assetId) |
---|
113 | | - | let price = value(startPrice) |
---|
114 | | - | let endHeight = (lastBlock.height + duration) |
---|
115 | | - | let caller = i.caller.bytes |
---|
116 | | - | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { |
---|
117 | | - | case a: String => |
---|
118 | | - | true |
---|
119 | | - | case _ => |
---|
120 | | - | false |
---|
121 | | - | } |
---|
122 | | - | if ((checkNftAuctioned == true)) |
---|
123 | | - | then throw("Already in auction list") |
---|
124 | | - | else if ((duration > maxAuctionDuration)) |
---|
125 | | - | then throw(("Duration is too long. Must be less than or equal to 30 " + toString(maxAuctionDuration))) |
---|
126 | | - | else if ((i.payments[0].assetId == unit)) |
---|
127 | | - | then throw("NFT not attached") |
---|
128 | | - | else if ((i.payments[0].assetId == teams)) |
---|
129 | | - | then throw("NFT not attached") |
---|
130 | | - | 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")] |
---|
131 | | - | } |
---|
132 | | - | |
---|
133 | | - | |
---|
134 | | - | |
---|
135 | | - | @Callable(i) |
---|
136 | | - | func placeBid (auctionId,nftId,nft_owner,bid_price,current_currency) = { |
---|
137 | | - | let txId = toBase58String(i.transactionId) |
---|
138 | | - | let caller = i.caller.bytes |
---|
139 | | - | let assetId = fromBase58String(nftId) |
---|
140 | | - | let tokenType = i.payments[0].assetId |
---|
141 | | - | let currentBidPrice = i.payments[0].amount |
---|
142 | | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
143 | | - | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) |
---|
144 | | - | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) |
---|
145 | | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
146 | | - | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) |
---|
147 | | - | if ((checkNftAuctioned != "OPEN")) |
---|
148 | | - | then throw("Not open for auction") |
---|
149 | | - | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) |
---|
150 | | - | then throw("Bid is less then starting/highest Bid") |
---|
151 | | - | else if ((getLastWinnerBidPrice == "0")) |
---|
152 | | - | 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)] |
---|
153 | | - | else if ((getLastWinnerBidPrice != "0")) |
---|
154 | | - | 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)] |
---|
155 | | - | else nil |
---|
156 | | - | } |
---|
157 | | - | |
---|
158 | | - | |
---|
159 | | - | |
---|
160 | | - | @Callable(i) |
---|
161 | | - | func acceptBidOffer (auctionId,nftId,bid_amount_from_user,current_currency) = { |
---|
162 | | - | let asimiString = "9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq" |
---|
163 | | - | let txId = toBase58String(i.transactionId) |
---|
164 | | - | let amountUnit = fromBase58String(current_currency) |
---|
165 | | - | let caller = i.caller.bytes |
---|
166 | | - | let assetId = fromBase58String(nftId) |
---|
167 | | - | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
168 | | - | let getNftWinningamount = ((parseIntValue(getNftWinningPrice) / 1000) * 975) |
---|
169 | | - | let platform_fee = ((parseIntValue(getNftWinningPrice) / 1000) * 25) |
---|
170 | | - | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
171 | | - | if ((current_currency == asimiString)) |
---|
172 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, amountUnit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry("platform_fee", toString(platform_fee)), 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")] |
---|
173 | | - | else if ((current_currency == "WAVES")) |
---|
174 | | - | then [ScriptTransfer(Address(caller), getNftWinningamount, unit), ScriptTransfer(Address(fromBase58String(getAuctionWinner)), 1, assetId), StringEntry("platform_fee", toString(platform_fee)), 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")] |
---|
175 | | - | else nil |
---|
176 | | - | } |
---|
177 | | - | |
---|
178 | | - | |
---|
179 | | - | |
---|
180 | | - | @Callable(i) |
---|
181 | | - | func cancelAuction (auctionId,current_currency) = { |
---|
182 | | - | let txId = toBase58String(i.transactionId) |
---|
183 | | - | let caller = i.caller.bytes |
---|
184 | | - | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) |
---|
185 | | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
186 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
187 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
188 | | - | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
189 | | - | if ((biddingWinner == "0")) |
---|
190 | | - | then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
191 | | - | else if ((biddingWinner != "0")) |
---|
192 | | - | then throw("soory you can't cancel it because already auction placed by someone") |
---|
193 | | - | else nil |
---|
194 | | - | } |
---|
195 | | - | |
---|
196 | | - | |
---|
197 | | - | |
---|
198 | | - | @Callable(i) |
---|
199 | | - | func manualFundTransfer (recepientAddr,message) = { |
---|
200 | | - | let caller = i.caller.bytes |
---|
201 | | - | let reciver = fromBase58String(recepientAddr) |
---|
202 | | - | let amount = i.payments[0].amount |
---|
203 | | - | let recepient_payment = ((amount / 1000) * 975) |
---|
204 | | - | let platform_fee = ((amount / 1000) * 25) |
---|
205 | | - | if ((i.payments[0].assetId == unit)) |
---|
206 | | - | then [IntegerEntry((toBase58String(caller) + "_transfer"), amount), StringEntry("platform_fee", toString(platform_fee)), StringEntry((toBase58String(caller) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), recepient_payment, unit)] |
---|
207 | | - | else if ((i.payments[0].assetId == teams)) |
---|
208 | | - | then [IntegerEntry((toBase58String(caller) + "_transfer"), amount), StringEntry("platform_fee", toString(platform_fee)), StringEntry((toBase58String(caller) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), recepient_payment, teams)] |
---|
209 | | - | else nil |
---|
210 | | - | } |
---|
211 | | - | |
---|
212 | | - | |
---|
213 | | - | |
---|
214 | | - | @Callable(i) |
---|
215 | | - | func backValue (auctionId) = { |
---|
216 | | - | let caller = i.caller.bytes |
---|
217 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
218 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
219 | | - | [StringEntry((auctionId + "_nft_status"), "Auction_time over"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
220 | | - | } |
---|
221 | | - | |
---|
222 | | - | |
---|
223 | | - | |
---|
224 | | - | @Callable(i) |
---|
225 | | - | func withdrawBid (bidTxId,current_currency) = { |
---|
226 | | - | let caller = i.caller.bytes |
---|
227 | | - | let asimiString = "9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq" |
---|
228 | | - | let txId = toBase58String(i.transactionId) |
---|
229 | | - | let amountUnit = fromBase58String(current_currency) |
---|
230 | | - | let bidPrice = getStringValue(this, (bidTxId + "_highest_bid")) |
---|
231 | | - | let asBidder = getStringValue(this, (bidTxId + "_winner")) |
---|
232 | | - | let bidForNFT = getStringValue(this, (bidTxId + "_nft_id")) |
---|
233 | | - | if ((current_currency == asimiString)) |
---|
234 | | - | then [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), amountUnit)] |
---|
235 | | - | else if ((current_currency == "WAVES")) |
---|
236 | | - | then [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] |
---|
237 | | - | else nil |
---|
238 | | - | } |
---|
239 | | - | |
---|
240 | | - | |
---|
241 | | - | |
---|
242 | | - | @Callable(i) |
---|
243 | | - | func automateFunction (auctionId,current_currency) = { |
---|
244 | | - | let caller = i.caller.bytes |
---|
245 | | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) |
---|
246 | | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) |
---|
247 | | - | let asimiString = "9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq" |
---|
248 | | - | let amountUnit = fromBase58String(current_currency) |
---|
249 | | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) |
---|
250 | | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
251 | | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) |
---|
252 | | - | if ((biddingWinner == "0")) |
---|
253 | | - | then [ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] |
---|
254 | | - | else if (if ((biddingWinner != "0")) |
---|
255 | | - | then (current_currency == asimiString) |
---|
256 | | - | else false) |
---|
257 | | - | then [ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), amountUnit)] |
---|
258 | | - | else if (if ((biddingWinner != "0")) |
---|
259 | | - | then (current_currency == "WAVES") |
---|
260 | | - | else false) |
---|
261 | | - | then [ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] |
---|
262 | | - | else nil |
---|
| 7 | + | func mintNft (ipfs_id,nft_name,nft_description) = { |
---|
| 8 | + | let recipient = i.caller |
---|
| 9 | + | let asset1 = Issue(nft_name, nft_description, 1, 0, false) |
---|
| 10 | + | let assetId1 = calculateAssetId(asset1) |
---|
| 11 | + | let asset2 = Issue(nft_name, nft_description, 1, 0, false) |
---|
| 12 | + | let assetId2 = calculateAssetId(asset2) |
---|
| 13 | + | [asset1, asset2, ScriptTransfer(recipient, 1, assetId1), ScriptTransfer(recipient, 1, assetId2)] |
---|