tx · 59D6vUbiBShjZr4zXeidQagPCrjysL5gFqPTHD879ccm 3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw: -0.01000000 Waves 2023.01.24 12:32 [2418862] smart account 3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw > SELF 0.00000000 Waves
{ "type": 13, "id": "59D6vUbiBShjZr4zXeidQagPCrjysL5gFqPTHD879ccm", "fee": 1000000, "feeAssetId": null, "timestamp": 1674552855855, "version": 2, "chainId": 84, "sender": "3NBYw8rxLmTvyEdsvaYor8nHG6GJ4NjB2Aw", "senderPublicKey": "4NDsd3dGKXuKLCoSbYvcWCX276K9ShP75cs9HTBMLJEN", "proofs": [ "579AfbfCi1MHQvDTqpePxpjFwhZ4JRC7TcyyKkzVbkkmd2nSwkyRxxthqRfbPo4oBgxvWSqUQq99osJzb8oqaRZy" ], "script": "base64:BgIaCAISCwoJCAgICAgBCAgIEgMKAQgSBAoCCAgLAAlzZXBhcmF0b3ICAV8ABGtCdXkCA2J1eQAGa1ByaWNlAgVwcmljZQAFa1NlbGwCBHNlbGwABXRlYW1zASCFY5Wj84iOsN4MF44ITr+aP5K7Jts66HaOFtwUIipIfgAFd2F2ZXMBAAASbWF4QXVjdGlvbkR1cmF0aW9uAAcABGtCaWQCA2JpZAAMc3RhdHVzRm9yTkZUCQCWCgQCBE9QRU4CBkNMT1NFRAIIUkVXQVJERUQCCENBTkNFTEVEAAtkQXBwQWRkcmVzcwEaAVRKuE9s3sLak+30julKNvjVT3+V1VVbXaABBWlzTmZ0AQdhc3NldElkBAckbWF0Y2gwCQDsBwEFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIFQXNzZXQEBXRva2VuBQckbWF0Y2gwAwMDAwkAAAIIBQV0b2tlbghkZWNpbWFscwAACQAAAggFBXRva2VuCHF1YW50aXR5AAEHCQAAAggFBXRva2VuCnJlaXNzdWFibGUHBwkAAAIFB2Fzc2V0SWQFBXdhdmVzBwkAAAIFB2Fzc2V0SWQFB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1N0cmluZ0VudHJ5AgkArAICCQCsAgIFBW5mdElEBQlzZXBhcmF0b3ICBl9vd25lcgkApQgBCAUBaQZjYWxsZXIFA25pbAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIAAQUHYXNzZXRJZAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQEHQWRkcmVzcwEJANkEAQURY3VycmVudF9uZnRfb3duZXIFBmFtb3VudAUEdW5pdAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgkApQgBCAUBaQZjYWxsZXIFCXNlcGFyYXRvcgUEa0J1eQkArAICCQCsAgIFBW5mdElEBQlzZXBhcmF0b3IJAKQDAQUGYW1vdW50CQDMCAIJAQtEZWxldGVFbnRyeQEJAKwCAgkArAICAgRuZnRfBRFjdXJyZW50X25mdF9vd25lcgIGX293bmVyCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICAgRuZnRfBRFjdXJyZW50X25mdF9vd25lcgIGX293bmVyCQClCAEIBQFpBmNhbGxlcgkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUFbmZ0SUQFCXNlcGFyYXRvcgIGX293bmVyCQClCAEIBQFpBmNhbGxlcgUDbmlsAB4R/Zk=", "height": 2418862, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AJpmrTsqofbYiaHZYE7XZSi3gwjpNdkJERer5q4kaKd3 Next: AGNkfzZ5MUYGbFJGU14MSjWWRTS6HRXqxqyiHatrSDLE Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let kSell = "sell" | |
11 | 11 | ||
12 | + | let teams = base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq' | |
13 | + | ||
14 | + | let waves = base58'' | |
15 | + | ||
12 | 16 | let maxAuctionDuration = 7 | |
13 | 17 | ||
14 | 18 | let kBid = "bid" | |
19 | 23 | ||
20 | 24 | func isNft (assetId) = match assetInfo(assetId) { | |
21 | 25 | case token: Asset => | |
22 | - | if (if ((token.decimals == 0)) | |
26 | + | if (if (if (if ((token.decimals == 0)) | |
23 | 27 | then (token.quantity == 1) | |
24 | 28 | else false) | |
25 | 29 | then (token.reissuable == false) | |
30 | + | else false) | |
31 | + | then (assetId == waves) | |
32 | + | else false) | |
33 | + | then (assetId == teams) | |
26 | 34 | else false | |
27 | 35 | case _ => | |
28 | 36 | false | |
43 | 51 | func sellNFT (price) = { | |
44 | 52 | let txId = i.transactionId | |
45 | 53 | let seller = i.caller.bytes | |
46 | - | let $ | |
47 | - | let token0 = $ | |
48 | - | let amount0 = $ | |
54 | + | let $t019172002 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
55 | + | let token0 = $t019172002._1 | |
56 | + | let amount0 = $t019172002._2 | |
49 | 57 | if (!(isNft(token0))) | |
50 | 58 | then throw("Token is not NFT") | |
51 | 59 | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
63 | 71 | case _ => | |
64 | 72 | false | |
65 | 73 | } | |
74 | + | let $t026262711 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
75 | + | let token0 = $t026262711._1 | |
76 | + | let amount0 = $t026262711._2 | |
66 | 77 | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) | |
67 | - | if ((i.payments[0].assetId != unit)) | |
68 | - | then throw("Pay in waves") | |
69 | - | else if ((current_nft_owner == toString(i.caller))) | |
70 | - | then throw("current Owner of NFT not able to purchase") | |
71 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, unit), 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))] | |
78 | + | if ((current_nft_owner == toString(i.caller))) | |
79 | + | then throw("current Owner of NFT not able to purchase") | |
80 | + | else if (!(isNft(token0))) | |
81 | + | then throw("Token is not NFT") | |
82 | + | else if ((i.payments[0].assetId == teams)) | |
83 | + | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, teams), 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 [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, unit), 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))] | |
72 | 85 | } | |
73 | - | ||
74 | - | ||
75 | - | ||
76 | - | @Callable(i) | |
77 | - | func addAuction (start,end,startPrice,duration) = { | |
78 | - | let txId = toBase58String(i.transactionId) | |
79 | - | let nftId = value(i.payments[0].assetId) | |
80 | - | let price = value(startPrice) | |
81 | - | let endHeight = (lastBlock.height + duration) | |
82 | - | let caller = i.caller.bytes | |
83 | - | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { | |
84 | - | case a: String => | |
85 | - | true | |
86 | - | case _ => | |
87 | - | false | |
88 | - | } | |
89 | - | if ((i.payments[0].assetId == unit)) | |
90 | - | then throw("NFT not attached") | |
91 | - | else if ((checkNftAuctioned == true)) | |
92 | - | then throw("Already in auction list") | |
93 | - | else if ((duration > maxAuctionDuration)) | |
94 | - | then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration))) | |
95 | - | 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")] | |
96 | - | } | |
97 | - | ||
98 | - | ||
99 | - | ||
100 | - | @Callable(i) | |
101 | - | func placeBid (auctionId,nftId,nft_owner,bid_price) = { | |
102 | - | let txId = toBase58String(i.transactionId) | |
103 | - | let caller = i.caller.bytes | |
104 | - | let assetId = fromBase58String(nftId) | |
105 | - | let currentBidPrice = i.payments[0].amount | |
106 | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
107 | - | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) | |
108 | - | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) | |
109 | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) | |
110 | - | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) | |
111 | - | if ((i.payments[0].assetId != unit)) | |
112 | - | then throw("Pay in waves") | |
113 | - | else if ((checkNftAuctioned != "OPEN")) | |
114 | - | then throw("Not open for auction") | |
115 | - | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) | |
116 | - | then throw("Bid is less then starting/highest Bid") | |
117 | - | else if ((getLastWinnerBidPrice == "0")) | |
118 | - | 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)] | |
119 | - | else [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), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | ||
124 | - | @Callable(i) | |
125 | - | func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = { | |
126 | - | let txId = toBase58String(i.transactionId) | |
127 | - | let caller = i.caller.bytes | |
128 | - | let assetId = fromBase58String(nftId) | |
129 | - | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
130 | - | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
131 | - | [ScriptTransfer(Address(caller), parseIntValue(getNftWinningPrice), 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")] | |
132 | - | } | |
133 | - | ||
134 | - | ||
135 | - | ||
136 | - | @Callable(i) | |
137 | - | func cancelAuction (auctionId) = { | |
138 | - | let txId = toBase58String(i.transactionId) | |
139 | - | let caller = i.caller.bytes | |
140 | - | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) | |
141 | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
142 | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) | |
143 | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) | |
144 | - | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
145 | - | if ((biddingWinner == "0")) | |
146 | - | then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] | |
147 | - | else [StringEntry((auctionId + "_nft_status"), "CANCELED"), StringEntry((auctionId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((auctionId + "_prevoius_bid_amount_refund"), biddingPrice), StringEntry((txId + "_nft_status"), "CANCELED"), StringEntry((txId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((txId + "_prevoius_bid_amount_refund"), biddingPrice), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(biddingWinner)), parseIntValue(biddingPrice), unit)] | |
148 | - | } | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func withdrawBid (bidTxId) = { | |
154 | - | let caller = i.caller.bytes | |
155 | - | let bidPrice = getStringValue(this, (bidTxId + "_highest_bid")) | |
156 | - | let asBidder = getStringValue(this, (bidTxId + "_winner")) | |
157 | - | let bidForNFT = getStringValue(this, (bidTxId + "_nft_id")) | |
158 | - | if ((toBase58String(caller) != asBidder)) | |
159 | - | then throw("No bid") | |
160 | - | else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] | |
161 | - | } | |
162 | - | ||
163 | - | ||
164 | - | ||
165 | - | @Callable(i) | |
166 | - | func manualFundTransfer (recepientAddr,message) = { | |
167 | - | let caller = i.caller.bytes | |
168 | - | let reciver = fromBase58String(recepientAddr) | |
169 | - | let amount = i.payments[0].amount | |
170 | - | if ((toString(amount) == "")) | |
171 | - | then throw("Payment is not attached or empty") | |
172 | - | else [IntegerEntry((toBase58String(caller) + "_transfer"), amount), StringEntry((toBase58String(caller) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), amount, unit)] | |
173 | - | } | |
174 | - | ||
175 | - | ||
176 | - | ||
177 | - | @Callable(i) | |
178 | - | func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] | |
179 | 86 | ||
180 | 87 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | 6 | let kBuy = "buy" | |
7 | 7 | ||
8 | 8 | let kPrice = "price" | |
9 | 9 | ||
10 | 10 | let kSell = "sell" | |
11 | 11 | ||
12 | + | let teams = base58'9yhJDfWjPpv6tFjWRD1AJyBQwausJf2ZdxzLn86Uknnq' | |
13 | + | ||
14 | + | let waves = base58'' | |
15 | + | ||
12 | 16 | let maxAuctionDuration = 7 | |
13 | 17 | ||
14 | 18 | let kBid = "bid" | |
15 | 19 | ||
16 | 20 | let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED") | |
17 | 21 | ||
18 | 22 | let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq' | |
19 | 23 | ||
20 | 24 | func isNft (assetId) = match assetInfo(assetId) { | |
21 | 25 | case token: Asset => | |
22 | - | if (if ((token.decimals == 0)) | |
26 | + | if (if (if (if ((token.decimals == 0)) | |
23 | 27 | then (token.quantity == 1) | |
24 | 28 | else false) | |
25 | 29 | then (token.reissuable == false) | |
30 | + | else false) | |
31 | + | then (assetId == waves) | |
32 | + | else false) | |
33 | + | then (assetId == teams) | |
26 | 34 | else false | |
27 | 35 | case _ => | |
28 | 36 | false | |
29 | 37 | } | |
30 | 38 | ||
31 | 39 | ||
32 | 40 | @Callable(i) | |
33 | 41 | func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = { | |
34 | 42 | let newToken = Issue(nft_name, nft_description, 1, 0, false) | |
35 | 43 | let issueId = calculateAssetId(newToken) | |
36 | 44 | let txId = i.transactionId | |
37 | 45 | [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))] | |
38 | 46 | } | |
39 | 47 | ||
40 | 48 | ||
41 | 49 | ||
42 | 50 | @Callable(i) | |
43 | 51 | func sellNFT (price) = { | |
44 | 52 | let txId = i.transactionId | |
45 | 53 | let seller = i.caller.bytes | |
46 | - | let $ | |
47 | - | let token0 = $ | |
48 | - | let amount0 = $ | |
54 | + | let $t019172002 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
55 | + | let token0 = $t019172002._1 | |
56 | + | let amount0 = $t019172002._2 | |
49 | 57 | if (!(isNft(token0))) | |
50 | 58 | then throw("Token is not NFT") | |
51 | 59 | else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), price), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))] | |
52 | 60 | } | |
53 | 61 | ||
54 | 62 | ||
55 | 63 | ||
56 | 64 | @Callable(i) | |
57 | 65 | func buyNFT (nftID,current_nft_owner) = { | |
58 | 66 | let assetId = fromBase58String(nftID) | |
59 | 67 | let amount = value(i.payments[0].amount) | |
60 | 68 | let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) { | |
61 | 69 | case a: String => | |
62 | 70 | a | |
63 | 71 | case _ => | |
64 | 72 | false | |
65 | 73 | } | |
74 | + | let $t026262711 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount)) | |
75 | + | let token0 = $t026262711._1 | |
76 | + | let amount0 = $t026262711._2 | |
66 | 77 | let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner)) | |
67 | - | if ((i.payments[0].assetId != unit)) | |
68 | - | then throw("Pay in waves") | |
69 | - | else if ((current_nft_owner == toString(i.caller))) | |
70 | - | then throw("current Owner of NFT not able to purchase") | |
71 | - | else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, unit), 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))] | |
78 | + | if ((current_nft_owner == toString(i.caller))) | |
79 | + | then throw("current Owner of NFT not able to purchase") | |
80 | + | else if (!(isNft(token0))) | |
81 | + | then throw("Token is not NFT") | |
82 | + | else if ((i.payments[0].assetId == teams)) | |
83 | + | then [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, teams), 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 [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(current_nft_owner)), amount, unit), 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))] | |
72 | 85 | } | |
73 | - | ||
74 | - | ||
75 | - | ||
76 | - | @Callable(i) | |
77 | - | func addAuction (start,end,startPrice,duration) = { | |
78 | - | let txId = toBase58String(i.transactionId) | |
79 | - | let nftId = value(i.payments[0].assetId) | |
80 | - | let price = value(startPrice) | |
81 | - | let endHeight = (lastBlock.height + duration) | |
82 | - | let caller = i.caller.bytes | |
83 | - | let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) { | |
84 | - | case a: String => | |
85 | - | true | |
86 | - | case _ => | |
87 | - | false | |
88 | - | } | |
89 | - | if ((i.payments[0].assetId == unit)) | |
90 | - | then throw("NFT not attached") | |
91 | - | else if ((checkNftAuctioned == true)) | |
92 | - | then throw("Already in auction list") | |
93 | - | else if ((duration > maxAuctionDuration)) | |
94 | - | then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration))) | |
95 | - | 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")] | |
96 | - | } | |
97 | - | ||
98 | - | ||
99 | - | ||
100 | - | @Callable(i) | |
101 | - | func placeBid (auctionId,nftId,nft_owner,bid_price) = { | |
102 | - | let txId = toBase58String(i.transactionId) | |
103 | - | let caller = i.caller.bytes | |
104 | - | let assetId = fromBase58String(nftId) | |
105 | - | let currentBidPrice = i.payments[0].amount | |
106 | - | let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
107 | - | let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder")) | |
108 | - | let currentBidCount = getStringValue(this, (auctionId + "_bidder_count")) | |
109 | - | let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft")) | |
110 | - | let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status")) | |
111 | - | if ((i.payments[0].assetId != unit)) | |
112 | - | then throw("Pay in waves") | |
113 | - | else if ((checkNftAuctioned != "OPEN")) | |
114 | - | then throw("Not open for auction") | |
115 | - | else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice)) | |
116 | - | then throw("Bid is less then starting/highest Bid") | |
117 | - | else if ((getLastWinnerBidPrice == "0")) | |
118 | - | 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)] | |
119 | - | else [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), ScriptTransfer(Address(fromBase58String(getLastWinnerAddress)), parseIntValue(getLastWinnerBidPrice), unit)] | |
120 | - | } | |
121 | - | ||
122 | - | ||
123 | - | ||
124 | - | @Callable(i) | |
125 | - | func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = { | |
126 | - | let txId = toBase58String(i.transactionId) | |
127 | - | let caller = i.caller.bytes | |
128 | - | let assetId = fromBase58String(nftId) | |
129 | - | let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
130 | - | let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
131 | - | [ScriptTransfer(Address(caller), parseIntValue(getNftWinningPrice), 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")] | |
132 | - | } | |
133 | - | ||
134 | - | ||
135 | - | ||
136 | - | @Callable(i) | |
137 | - | func cancelAuction (auctionId) = { | |
138 | - | let txId = toBase58String(i.transactionId) | |
139 | - | let caller = i.caller.bytes | |
140 | - | let auctionStatus = getStringValue(this, (auctionId + "_nft_status")) | |
141 | - | let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft")) | |
142 | - | let nftOwner = getStringValue(this, (auctionId + "_nft_owner")) | |
143 | - | let nftId = getStringValue(this, (auctionId + "_nft_on_auction")) | |
144 | - | let biddingPrice = getStringValue(this, (auctionId + "_highest_bid")) | |
145 | - | if ((biddingWinner == "0")) | |
146 | - | then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))] | |
147 | - | else [StringEntry((auctionId + "_nft_status"), "CANCELED"), StringEntry((auctionId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((auctionId + "_prevoius_bid_amount_refund"), biddingPrice), StringEntry((txId + "_nft_status"), "CANCELED"), StringEntry((txId + "_previous_bid_amount_refund_to_address"), biddingWinner), StringEntry((txId + "_prevoius_bid_amount_refund"), biddingPrice), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId)), ScriptTransfer(Address(fromBase58String(biddingWinner)), parseIntValue(biddingPrice), unit)] | |
148 | - | } | |
149 | - | ||
150 | - | ||
151 | - | ||
152 | - | @Callable(i) | |
153 | - | func withdrawBid (bidTxId) = { | |
154 | - | let caller = i.caller.bytes | |
155 | - | let bidPrice = getStringValue(this, (bidTxId + "_highest_bid")) | |
156 | - | let asBidder = getStringValue(this, (bidTxId + "_winner")) | |
157 | - | let bidForNFT = getStringValue(this, (bidTxId + "_nft_id")) | |
158 | - | if ((toBase58String(caller) != asBidder)) | |
159 | - | then throw("No bid") | |
160 | - | else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)] | |
161 | - | } | |
162 | - | ||
163 | - | ||
164 | - | ||
165 | - | @Callable(i) | |
166 | - | func manualFundTransfer (recepientAddr,message) = { | |
167 | - | let caller = i.caller.bytes | |
168 | - | let reciver = fromBase58String(recepientAddr) | |
169 | - | let amount = i.payments[0].amount | |
170 | - | if ((toString(amount) == "")) | |
171 | - | then throw("Payment is not attached or empty") | |
172 | - | else [IntegerEntry((toBase58String(caller) + "_transfer"), amount), StringEntry((toBase58String(caller) + "_transfer_to"), recepientAddr), ScriptTransfer(Address(reciver), amount, unit)] | |
173 | - | } | |
174 | - | ||
175 | - | ||
176 | - | ||
177 | - | @Callable(i) | |
178 | - | func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")] | |
179 | 86 | ||
180 | 87 |
github/deemru/w8io/026f985 34.47 ms ◑