tx · 3cJoW2DCyC8FA2cnPNw97txofMx188vqdkHWrEgK1oLs

3N9cKCHp6ZLMgz7rRgF8Q8DEt8zbtd1Ht7F:  -0.01000000 Waves

2022.12.13 12:36 [2358375] smart account 3N9cKCHp6ZLMgz7rRgF8Q8DEt8zbtd1Ht7F > SELF 0.00000000 Waves

{ "type": 13, "id": "3cJoW2DCyC8FA2cnPNw97txofMx188vqdkHWrEgK1oLs", "fee": 1000000, "feeAssetId": null, "timestamp": 1670924286072, "version": 2, "chainId": 84, "sender": "3N9cKCHp6ZLMgz7rRgF8Q8DEt8zbtd1Ht7F", "senderPublicKey": "3V22YUj3GF4AeBxdWx8rgGdG4groE4W6P2s4sAkshe7R", "proofs": [ "4Aahrh6fsksG7JQBsSFRqsomTAwNptpmeeCf3axkxCNaoJyYo4e1G8odeHMceoMYt9pGtaovD2d9Vm5KhtQLPm1U" ], "script": "base64:BgIZCAISCwoJCAgICAgBCAgIEgMKAQESAwoBCAkACXNlcGFyYXRvcgIBXwAEa0J1eQIDYnV5AAZrUHJpY2UCBXByaWNlAAVrU2VsbAIEc2VsbAASbWF4QXVjdGlvbkR1cmF0aW9uAAcABGtCaWQCA2JpZAAMc3RhdHVzRm9yTkZUCQCWCgQCBE9QRU4CBkNMT1NFRAIIUkVXQVJERUQCCENBTkNFTEVEAAtkQXBwQWRkcmVzcwEaAVRKuE9s3sLak+30julKNvjVT3+V1VVbXaABBWlzTmZ0AQdhc3NldElkBAckbWF0Y2gwCQDsBwEFB2Fzc2V0SWQDCQABAgUHJG1hdGNoMAIFQXNzZXQEBXRva2VuBQckbWF0Y2gwAwMJAAACCAUFdG9rZW4IZGVjaW1hbHMAAAkAAAIIBQV0b2tlbghxdWFudGl0eQABBwkAAAIIBQV0b2tlbgpyZWlzc3VhYmxlBwcHAwFpAQljcmVhdGVOZnQJCG5mdF9uYW1lCW5mdF9vd25lcg9uZnRfZEFwcEFkZHJlc3MIbmZ0X3R5cGUIbmZ0X3RhZ3MRbmZ0X3Nlb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RpdmUoMTA1OCkBCQCsAgIJAKwCAgkArAICCQCsAgIFBmtQcmljZQUJc2VwYXJhdG9yBQVuZnRJRAIBXwUFb3duZXIEDWN1cnJlbnRfb3duZXIJARFAZXh0ck5hdGl2ZSgxMDU4KQEJAKwCAgkArAICBQVuZnRJRAUJc2VwYXJhdG9yAgVPd25lcgMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdW5pdAkAAgECDFBheSBpbiB3YXZlcwMJAAACBRBjaGVja093bmVySXNTYW1lCQClCAEIBQFpBmNhbGxlcgkAAgECIU93bmVyIG9mIE5GVCBub3QgYWJsZSB0byBwdXJjaGFzZQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIAAQUHYXNzZXRJZAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQEHQWRkcmVzcwEJANkEAQUFb3duZXIFBmFtb3VudAUEdW5pdAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgkApQgBCAUBaQZjYWxsZXIFCXNlcGFyYXRvcgUEa0J1eQkArAICCQCsAgIFBW5mdElEBQlzZXBhcmF0b3IJAKQDAQUGYW1vdW50CQDMCAIJAQtEZWxldGVFbnRyeQEJAKwCAgkArAICAgRuZnRfBQVvd25lcgIGX293bmVyBQNuaWwApa8dLg==", "height": 2358375, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AuQwCUh6gu1EZfFDGtCb29Kd8P79YTWmWcebcYgpPb1f Next: 84UjADZjRJRewB83SCYu1bSzcG5GYU3WbA3Zpc37ZPxg Diff:
OldNewDifferences
5454
5555
5656 @Callable(i)
57-func buyNFT (nftID,current_nft_owner) = {
57+func buyNFT (nftID) = {
5858 let assetId = fromBase58String(nftID)
59+ let owner = getStringValue(((nftID + separator) + "Owner"))
5960 let amount = value(i.payments[0].amount)
60- let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) {
61+ let checkOwnerIsSame = match getString(this, (("nft_" + owner) + "_owner")) {
6162 case a: String =>
6263 a
6364 case _ =>
6465 false
6566 }
66- let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner))
67- let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner")
67+ let price = getStringValue(((((kPrice + separator) + nftID) + "_") + owner))
68+ let current_owner = getStringValue(((nftID + separator) + "Owner"))
6869 if ((i.payments[0].assetId != unit))
6970 then throw("Pay in waves")
7071 else if ((checkOwnerIsSame == toString(i.caller)))
7172 then throw("Owner of NFT not able to purchase")
72- 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"))]
73+ else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + owner) + "_owner"))]
7374 }
74-
75-
76-
77-@Callable(i)
78-func addAuction (start,end,startPrice,duration) = {
79- let txId = toBase58String(i.transactionId)
80- let nftId = value(i.payments[0].assetId)
81- let price = value(startPrice)
82- let endHeight = (lastBlock.height + duration)
83- let caller = i.caller.bytes
84- let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) {
85- case a: String =>
86- true
87- case _ =>
88- false
89- }
90- if ((i.payments[0].assetId == unit))
91- then throw("NFT not attached")
92- else if ((checkNftAuctioned == true))
93- then throw("Already in auction list")
94- else if ((duration > maxAuctionDuration))
95- then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration)))
96- 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")]
97- }
98-
99-
100-
101-@Callable(i)
102-func placeBid (auctionId,nftId,nft_owner,bid_price) = {
103- let txId = toBase58String(i.transactionId)
104- let caller = i.caller.bytes
105- let assetId = fromBase58String(nftId)
106- let currentBidPrice = i.payments[0].amount
107- let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid"))
108- let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder"))
109- let currentBidCount = getStringValue(this, (auctionId + "_bidder_count"))
110- let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft"))
111- let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status"))
112- if ((i.payments[0].assetId != unit))
113- then throw("Pay in waves")
114- else if ((checkNftAuctioned != "OPEN"))
115- then throw("Not open for auction")
116- else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice))
117- then throw("Bid is less then starting/highest Bid")
118- else if ((getLastWinnerBidPrice == "0"))
119- 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)]
120- 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)]
121- }
122-
123-
124-
125-@Callable(i)
126-func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = {
127- let txId = toBase58String(i.transactionId)
128- let caller = i.caller.bytes
129- let assetId = fromBase58String(nftId)
130- let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid"))
131- let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
132-[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")]
133- }
134-
135-
136-
137-@Callable(i)
138-func cancelAuction (auctionId) = {
139- let txId = toBase58String(i.transactionId)
140- let caller = i.caller.bytes
141- let auctionStatus = getStringValue(this, (auctionId + "_nft_status"))
142- let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
143- let nftOwner = getStringValue(this, (auctionId + "_nft_owner"))
144- let nftId = getStringValue(this, (auctionId + "_nft_on_auction"))
145- let biddingPrice = getStringValue(this, (auctionId + "_highest_bid"))
146- if ((biddingWinner == "0"))
147- then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))]
148- 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)]
149- }
150-
151-
152-
153-@Callable(i)
154-func withdrawBid (bidTxId) = {
155- let caller = i.caller.bytes
156- let bidPrice = getStringValue(this, (bidTxId + "_highest_bid"))
157- let asBidder = getStringValue(this, (bidTxId + "_winner"))
158- let bidForNFT = getStringValue(this, (bidTxId + "_nft_id"))
159- if ((toBase58String(caller) != asBidder))
160- then throw("No bid")
161- else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)]
162- }
163-
164-
165-
166-@Callable(i)
167-func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")]
16875
16976
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "_"
55
66 let kBuy = "buy"
77
88 let kPrice = "price"
99
1010 let kSell = "sell"
1111
1212 let maxAuctionDuration = 7
1313
1414 let kBid = "bid"
1515
1616 let statusForNFT = $Tuple4("OPEN", "CLOSED", "REWARDED", "CANCELED")
1717
1818 let dAppAddress = base58'3MvjAaDYHpS4A5K4CV3kZMMEH9m9JdBSvbq'
1919
2020 func isNft (assetId) = match assetInfo(assetId) {
2121 case token: Asset =>
2222 if (if ((token.decimals == 0))
2323 then (token.quantity == 1)
2424 else false)
2525 then (token.reissuable == false)
2626 else false
2727 case _ =>
2828 false
2929 }
3030
3131
3232 @Callable(i)
3333 func createNft (nft_name,nft_owner,nft_dAppAddress,nft_type,nft_tags,nft_selling_price,nft_description,nft_onSell,nft_data) = {
3434 let newToken = Issue(nft_name, nft_description, 1, 0, false)
3535 let issueId = calculateAssetId(newToken)
3636 let txId = i.transactionId
3737 [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))]
3838 }
3939
4040
4141
4242 @Callable(i)
4343 func sellNFT (price) = {
4444 let txId = i.transactionId
4545 let seller = i.caller.bytes
4646 let $t017891874 = $Tuple2(value(i.payments[0].assetId), value(i.payments[0].amount))
4747 let token0 = $t017891874._1
4848 let amount0 = $t017891874._2
4949 if (!(isNft(token0)))
5050 then throw("Token is not NFT")
5151 else [StringEntry(((kPrice + separator) + toBase58String(value(i.payments[0].assetId))), toString(price)), StringEntry(((toString(i.caller) + separator) + kSell), ((toBase58String(token0) + separator) + toString(amount0)))]
5252 }
5353
5454
5555
5656 @Callable(i)
57-func buyNFT (nftID,current_nft_owner) = {
57+func buyNFT (nftID) = {
5858 let assetId = fromBase58String(nftID)
59+ let owner = getStringValue(((nftID + separator) + "Owner"))
5960 let amount = value(i.payments[0].amount)
60- let checkOwnerIsSame = match getString(this, (("nft_" + current_nft_owner) + "_owner")) {
61+ let checkOwnerIsSame = match getString(this, (("nft_" + owner) + "_owner")) {
6162 case a: String =>
6263 a
6364 case _ =>
6465 false
6566 }
66- let price = getStringValue(((((kPrice + separator) + nftID) + "_") + current_nft_owner))
67- let owner = valueOrErrorMessage(getStringValue(((nftID + separator) + "Owner")), "No owner")
67+ let price = getStringValue(((((kPrice + separator) + nftID) + "_") + owner))
68+ let current_owner = getStringValue(((nftID + separator) + "Owner"))
6869 if ((i.payments[0].assetId != unit))
6970 then throw("Pay in waves")
7071 else if ((checkOwnerIsSame == toString(i.caller)))
7172 then throw("Owner of NFT not able to purchase")
72- 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"))]
73+ else [ScriptTransfer(i.caller, 1, assetId), ScriptTransfer(Address(fromBase58String(owner)), amount, unit), StringEntry(((toString(i.caller) + separator) + kBuy), ((nftID + separator) + toString(amount))), DeleteEntry((("nft_" + owner) + "_owner"))]
7374 }
74-
75-
76-
77-@Callable(i)
78-func addAuction (start,end,startPrice,duration) = {
79- let txId = toBase58String(i.transactionId)
80- let nftId = value(i.payments[0].assetId)
81- let price = value(startPrice)
82- let endHeight = (lastBlock.height + duration)
83- let caller = i.caller.bytes
84- let checkNftAuctioned = match getString(this, (((toBase58String(nftId) + separator) + "nft_status_") + toBase58String(caller))) {
85- case a: String =>
86- true
87- case _ =>
88- false
89- }
90- if ((i.payments[0].assetId == unit))
91- then throw("NFT not attached")
92- else if ((checkNftAuctioned == true))
93- then throw("Already in auction list")
94- else if ((duration > maxAuctionDuration))
95- then throw(("Duration is too long. Must be less than or equal to 7 " + toString(maxAuctionDuration)))
96- 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")]
97- }
98-
99-
100-
101-@Callable(i)
102-func placeBid (auctionId,nftId,nft_owner,bid_price) = {
103- let txId = toBase58String(i.transactionId)
104- let caller = i.caller.bytes
105- let assetId = fromBase58String(nftId)
106- let currentBidPrice = i.payments[0].amount
107- let getLastWinnerBidPrice = getStringValue(this, (auctionId + "_highest_bid"))
108- let getPreviousBidderAddress = getString(this, (auctionId + "_previous_bidder"))
109- let currentBidCount = getStringValue(this, (auctionId + "_bidder_count"))
110- let getLastWinnerAddress = getStringValue(this, (auctionId + "_winner_of_nft"))
111- let checkNftAuctioned = getStringValue(this, (auctionId + "_nft_status"))
112- if ((i.payments[0].assetId != unit))
113- then throw("Pay in waves")
114- else if ((checkNftAuctioned != "OPEN"))
115- then throw("Not open for auction")
116- else if ((parseIntValue(getLastWinnerBidPrice) >= currentBidPrice))
117- then throw("Bid is less then starting/highest Bid")
118- else if ((getLastWinnerBidPrice == "0"))
119- 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)]
120- 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)]
121- }
122-
123-
124-
125-@Callable(i)
126-func acceptBidOffer (auctionId,nftId,bid_amount_from_user) = {
127- let txId = toBase58String(i.transactionId)
128- let caller = i.caller.bytes
129- let assetId = fromBase58String(nftId)
130- let getNftWinningPrice = getStringValue(this, (auctionId + "_highest_bid"))
131- let getAuctionWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
132-[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")]
133- }
134-
135-
136-
137-@Callable(i)
138-func cancelAuction (auctionId) = {
139- let txId = toBase58String(i.transactionId)
140- let caller = i.caller.bytes
141- let auctionStatus = getStringValue(this, (auctionId + "_nft_status"))
142- let biddingWinner = getStringValue(this, (auctionId + "_winner_of_nft"))
143- let nftOwner = getStringValue(this, (auctionId + "_nft_owner"))
144- let nftId = getStringValue(this, (auctionId + "_nft_on_auction"))
145- let biddingPrice = getStringValue(this, (auctionId + "_highest_bid"))
146- if ((biddingWinner == "0"))
147- then [StringEntry(((txId + auctionId) + "_nft_status"), "CANCELED"), ScriptTransfer(Address(fromBase58String(nftOwner)), 1, fromBase58String(nftId))]
148- 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)]
149- }
150-
151-
152-
153-@Callable(i)
154-func withdrawBid (bidTxId) = {
155- let caller = i.caller.bytes
156- let bidPrice = getStringValue(this, (bidTxId + "_highest_bid"))
157- let asBidder = getStringValue(this, (bidTxId + "_winner"))
158- let bidForNFT = getStringValue(this, (bidTxId + "_nft_id"))
159- if ((toBase58String(caller) != asBidder))
160- then throw("No bid")
161- else [StringEntry((bidTxId + "_nft_bid"), "WITHDRAW"), StringEntry((bidTxId + "_nft_id"), bidForNFT), StringEntry((bidTxId + "_bidding_price_refund_amount"), bidPrice), ScriptTransfer(i.caller, parseIntValue(bidPrice), unit)]
162- }
163-
164-
165-
166-@Callable(i)
167-func testBid (data) = [StringEntry("E8kkFBYCy44JJaq6pAZ6KizsuResi5UKNhbD1WNZwhhY_highest_bid", "0")]
16875
16976

github/deemru/w8io/169f3d6 
44.65 ms