tx · 2jgZgg5SmxTVjhHVWbU9ofWSDxn1Ys7buzbGkK2pURAi

3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo:  -0.01000000 Waves

2022.12.06 17:38 [2348617] smart account 3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo > SELF 0.00000000 Waves

{ "type": 13, "id": "2jgZgg5SmxTVjhHVWbU9ofWSDxn1Ys7buzbGkK2pURAi", "fee": 1000000, "feeAssetId": null, "timestamp": 1670337449041, "version": 2, "chainId": 84, "sender": "3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo", "senderPublicKey": "Kwu4LYBMntApXv8t7csxV23Kvc3tvak26wMKK56tA4V", "proofs": [ "4yfQGi4z4HvvNxphf93S83czcYstXNsv1aV7trc8Atpoadf2Wf5zdFN36VRwoQVYrjyQrPEKVpsaCguLvuRnGhZ4" ], "script": "base64:BgIKCAISBgoECAgIAQEAEm1heEF1Y3Rpb25EdXJhdGlvbgAHAQFpAQphZGRBdWN0aW9uBAVzdGFydANlbmQKc3RhcnRQcmljZQhkdXJhdGlvbgQEdHhJZAkA2AQBCAUBaQ10cmFuc2FjdGlvbklkBAVuZnRJZAkBBXZhbHVlAQgJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkBAVwcmljZQkBBXZhbHVlAQUKc3RhcnRQcmljZQQJZW5kSGVpZ2h0CQBkAggFCWxhc3RCbG9jawZoZWlnaHQFCGR1cmF0aW9uBAZjYWxsZXIICAUBaQZjYWxsZXIFYnl0ZXMEEWNoZWNrTmZ0QXVjdGlvbmVkBAckbWF0Y2gwCQCdCAIFBHRoaXMJAKwCAgkArAICCQDYBAEFBW5mdElkAgtuZnRfc3RhdHVzXwkA2AQBBQZjYWxsZXIDCQABAgUHJG1hdGNoMAIGU3RyaW5nBAFhBQckbWF0Y2gwBgcDCQAAAggJAJEDAggFAWkIcGF5bWVudHMAAAdhc3NldElkBQR1bml0CQACAQIQTkZUIG5vdCBhdHRhY2hlZAMJAAACBRFjaGVja05mdEF1Y3Rpb25lZAYJAAIBAhdBbHJlYWR5IGluIGF1Y3Rpb24gbGlzdAMJAGYCBQhkdXJhdGlvbgUSbWF4QXVjdGlvbkR1cmF0aW9uCQACAQkArAICAjZEdXJhdGlvbiBpcyB0b28gbG9uZy4gTXVzdCBiZSBsZXNzIHRoYW4gb3IgZXF1YWwgdG8gNyAJAKQDAQUSbWF4QXVjdGlvbkR1cmF0aW9uCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICBQR0eElkAhhfbmZ0X3N0YXJ0X2F1Y3Rpb25fZGF0ZV8JANgEAQUGY2FsbGVyBQVzdGFydAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUEdHhJZAIWX25mdF9lbmRfYXVjdGlvbl9kYXRlXwkA2AQBBQZjYWxsZXIFA2VuZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBHR4SWQCEF9uZnRfc3RhcnRfcHJpY2UFCnN0YXJ0UHJpY2UJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQR0eElkAgpfbmZ0X293bmVyCQClCAEIBQFpBmNhbGxlcgkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBHR4SWQCD19uZnRfb25fYXVjdGlvbgkA2AQBBQVuZnRJZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBHR4SWQCEF9wcmV2aW91c19iaWRkZXICBG5vbmUJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQR0eElkAgxfaGlnaGVzdF9iaWQCATAJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQR0eElkAg5fd2lubmVyX29mX25mdAIBMAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBHR4SWQCDV9iaWRkZXJfY291bnQCATAJAMwIAgkBC1N0cmluZ0VudHJ5AgkArAICBQR0eElkAgtfbmZ0X3N0YXR1cwIET1BFTgUDbmlsAC9/3Bk=", "height": 2348617, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4sQD51tUVf6UUb2zLJozZTGucZzPYPRVFzZviQXwFDUo Next: CHsvREfCBsemVaShopucsz5AHmprXPsaxSabXs7fDaf Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let separator = "_"
5-
6-let kBuy = "buy"
7-
8-let kPrice = "price"
9-
10-let kSell = "sell"
11-
12-let kBid = "bid"
13-
14-let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED")
15-
16-let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq'
17-
18-func isNft (assetId) = match assetInfo(assetId) {
19- case token: Asset =>
20- if (if ((token.decimals == 0))
21- then (token.quantity == 1)
22- else false)
23- then (token.reissuable == false)
24- else false
25- case _ =>
26- false
27-}
28-
29-
30-@Callable(i)
31-func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = {
32- let newToken = Issue(nft_name, nft_description, 1, 0, false)
33- let issueId = calculateAssetId(newToken)
34- let txId = i.transactionId
35-[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))]
36- }
37-
38-
39-
40-@Callable(i)
41-func sellNFT (price) = {
42- let txId = i.transactionId
43- let seller = i.caller.bytes
44- let $t017611846 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
45- let token0 = $t017611846._1
46- let amount0 = $t017611846._2
47- if (!(isNft(token0)))
48- then throw("Token is not NFT")
49- else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))]
50- }
51-
52-
53-
54-@Callable(i)
55-func buyNFT (nftID,current_nft_owner) = {
56- let assetId = fromBase58String(nftID)
57- let amount = value(i.payments[0].amount)
58- let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) {
59- case a: String =>
60- a
61- case _ =>
62- false
63- }
64- let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner))
65- let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner")
66- if ((i.payments[0].assetId != unit))
67- then throw("Pay in waves")
68- else if ((checkOwnerIsSame == toString(i.caller)))
69- then throw("Owner of NFT not able to purchase")
70- else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner"))]
71- }
72-
73-
4+let maxAuctionDuration = 7
745
756 @Callable(i)
767 func addAuction (start,end,startPrice,duration) = {
778 let txId = toBase58String(i.transactionId)
789 let nftId = value(i.payments[0].assetId)
7910 let price = value(startPrice)
11+ let endHeight = (lastBlock.height + duration)
8012 let caller = i.caller.bytes
81- let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) {
13+ let checkNftAuctioned = match getString(this, ((toBase58String(nftId) + "nft_status_") + toBase58String(caller))) {
8214 case a: String =>
8315 true
8416 case _ =>
8820 then throw("NFT not attached")
8921 else if ((checkNftAuctioned == true))
9022 then throw("Already in auction list")
91- 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 + "duration_of_auction"), duration), 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")]
23+ else if ((duration > maxAuctionDuration))
24+ then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration)))
25+ 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")]
9226 }
93-
94-
95-
96-@Callable(i)
97-func placeBid (auctionId,nftId,nft_owner,bid_price) = {
98- let txId = toBase58String(i.transactionId)
99- let caller = i.caller.bytes
100- let assetId = fromBase58String(nftId)
101- let currentBidPrice = i.payments[0].amount
102- let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid"))
103- let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder"))
104- let currentBidCount = getStringValue(this, (auctionId + "_bidder_count"))
105- let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft"))
106- let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status"))
107- if ((i.payments[0].assetId != unit))
108- then throw("Pay in waves")
109- else if ((checkNftAuctioned != "OPEN"))
110- then throw("Not open for auction")
111- else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice))
112- then throw("Bid is less then starting/highest Bid")
113- else if ((getLastWinnerBidPrice == "0"))
114- 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)]
115- 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)]
116- }
117-
118-
119-
120-@Callable(i)
121-func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = {
122- let txId = toBase58String(i.transactionId)
123- let caller = i.caller.bytes
124- let assetId = fromBase58String(nftId)
125- let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid"))
126- let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
127-[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")]
128- }
129-
130-
131-
132-@Callable(i)
133-func cancelAuction (auctionId) = {
134- let txId = toBase58String(i.transactionId)
135- let caller = i.caller.bytes
136- let auctionStatus = getStringValue(this, (auctionId + "_nft_status"))
137- let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
138- let nftOwner = getStringValue(this, (auctionId + "_nft_owner"))
139- let nftId = getStringValue(this, (auctionId + "_nft_on_auction"))
140- let biddingPrice = getStringValue(this, (auctionId + "_highest_bid"))
141- if ((biddingWinner == "0"))
142- then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))]
143- 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)]
144- }
145-
146-
147-
148-@Callable(i)
149-func withdrawBid (bidTxId) = {
150- let caller = i.caller.bytes
151- let bidPrice = getStringValue(this, (bidTxId + "_highest_bid"))
152- let asBidder = getStringValue(this, (bidTxId + "_winner"))
153- let bidForNFT = getStringValue(this, (bidTxId + "_nft_id"))
154- if ((toBase58String(caller) != asBidder))
155- then throw("No bid")
156- else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)]
157- }
158-
159-
160-
161-@Callable(i)
162-func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")]
16327
16428
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let separator = "_"
5-
6-let kBuy = "buy"
7-
8-let kPrice = "price"
9-
10-let kSell = "sell"
11-
12-let kBid = "bid"
13-
14-let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED")
15-
16-let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq'
17-
18-func isNft (assetId) = match assetInfo(assetId) {
19- case token: Asset =>
20- if (if ((token.decimals == 0))
21- then (token.quantity == 1)
22- else false)
23- then (token.reissuable == false)
24- else false
25- case _ =>
26- false
27-}
28-
29-
30-@Callable(i)
31-func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = {
32- let newToken = Issue(nft_name, nft_description, 1, 0, false)
33- let issueId = calculateAssetId(newToken)
34- let txId = i.transactionId
35-[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))]
36- }
37-
38-
39-
40-@Callable(i)
41-func sellNFT (price) = {
42- let txId = i.transactionId
43- let seller = i.caller.bytes
44- let $t017611846 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
45- let token0 = $t017611846._1
46- let amount0 = $t017611846._2
47- if (!(isNft(token0)))
48- then throw("Token is not NFT")
49- else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))]
50- }
51-
52-
53-
54-@Callable(i)
55-func buyNFT (nftID,current_nft_owner) = {
56- let assetId = fromBase58String(nftID)
57- let amount = value(i.payments[0].amount)
58- let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) {
59- case a: String =>
60- a
61- case _ =>
62- false
63- }
64- let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner))
65- let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner")
66- if ((i.payments[0].assetId != unit))
67- then throw("Pay in waves")
68- else if ((checkOwnerIsSame == toString(i.caller)))
69- then throw("Owner of NFT not able to purchase")
70- else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + current_nft_owner) + "_owner"))]
71- }
72-
73-
4+let maxAuctionDuration = 7
745
756 @Callable(i)
767 func addAuction (start,end,startPrice,duration) = {
778 let txId = toBase58String(i.transactionId)
789 let nftId = value(i.payments[0].assetId)
7910 let price = value(startPrice)
11+ let endHeight = (lastBlock.height + duration)
8012 let caller = i.caller.bytes
81- let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) {
13+ let checkNftAuctioned = match getString(this, ((toBase58String(nftId) + "nft_status_") + toBase58String(caller))) {
8214 case a: String =>
8315 true
8416 case _ =>
8517 false
8618 }
8719 if ((i.payments[0].assetId == unit))
8820 then throw("NFT not attached")
8921 else if ((checkNftAuctioned == true))
9022 then throw("Already in auction list")
91- 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 + "duration_of_auction"), duration), 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")]
23+ else if ((duration > maxAuctionDuration))
24+ then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration)))
25+ 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")]
9226 }
93-
94-
95-
96-@Callable(i)
97-func placeBid (auctionId,nftId,nft_owner,bid_price) = {
98- let txId = toBase58String(i.transactionId)
99- let caller = i.caller.bytes
100- let assetId = fromBase58String(nftId)
101- let currentBidPrice = i.payments[0].amount
102- let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid"))
103- let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder"))
104- let currentBidCount = getStringValue(this, (auctionId + "_bidder_count"))
105- let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft"))
106- let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status"))
107- if ((i.payments[0].assetId != unit))
108- then throw("Pay in waves")
109- else if ((checkNftAuctioned != "OPEN"))
110- then throw("Not open for auction")
111- else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice))
112- then throw("Bid is less then starting/highest Bid")
113- else if ((getLastWinnerBidPrice == "0"))
114- 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)]
115- 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)]
116- }
117-
118-
119-
120-@Callable(i)
121-func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = {
122- let txId = toBase58String(i.transactionId)
123- let caller = i.caller.bytes
124- let assetId = fromBase58String(nftId)
125- let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid"))
126- let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
127-[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")]
128- }
129-
130-
131-
132-@Callable(i)
133-func cancelAuction (auctionId) = {
134- let txId = toBase58String(i.transactionId)
135- let caller = i.caller.bytes
136- let auctionStatus = getStringValue(this, (auctionId + "_nft_status"))
137- let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
138- let nftOwner = getStringValue(this, (auctionId + "_nft_owner"))
139- let nftId = getStringValue(this, (auctionId + "_nft_on_auction"))
140- let biddingPrice = getStringValue(this, (auctionId + "_highest_bid"))
141- if ((biddingWinner == "0"))
142- then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))]
143- 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)]
144- }
145-
146-
147-
148-@Callable(i)
149-func withdrawBid (bidTxId) = {
150- let caller = i.caller.bytes
151- let bidPrice = getStringValue(this, (bidTxId + "_highest_bid"))
152- let asBidder = getStringValue(this, (bidTxId + "_winner"))
153- let bidForNFT = getStringValue(this, (bidTxId + "_nft_id"))
154- if ((toBase58String(caller) != asBidder))
155- then throw("No bid")
156- else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)]
157- }
158-
159-
160-
161-@Callable(i)
162-func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")]
16327
16428

github/deemru/w8io/026f985 
29.52 ms