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