tx · HNVsJpMfWYk3acCdf2pwS2KmPRToAcAE1QSJwpWztbyR

3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn:  -0.01000000 Waves

2022.11.02 13:52 [2299394] smart account 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn > SELF 0.00000000 Waves

{ "type": 13, "id": "HNVsJpMfWYk3acCdf2pwS2KmPRToAcAE1QSJwpWztbyR", "fee": 1000000, "feeAssetId": null, "timestamp": 1667386402003, "version": 2, "chainId": 84, "sender": "3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn", "senderPublicKey": "Cq4RbcVcQJpCWyHiACDqUf2PbU8PaX949Dun9wRSeDzE", "proofs": [ "5bDUqHsUUYWYJDTMn7uZ2ZniJpmgE1TeXi9wQYcmbPD8uG7dyrg4qK4F8hHoKvd6H4ERywNc4CqF1bv4f8bzoTEi" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAACwAAAAAMb3duZXJBZGRyZXNzAQAAAAAAAAAACm5mdEFkZHJlc3MBAAAAAAAAAAAKbmZ0QXNzZXRJZAEAAAAAAAAAAA5rR2xvYmFsQ291bnRlcgIAAAAOR0xPQkFMX0NPVU5URVIAAAAACmZlZVBlcmNlbnQAAAAAAAAAAAUAAAAAE2FydGVmYWN0c0ZlZVBlcmNlbnQAAAAAAAAAABQBAAAADXRyeUdldEludGVnZXIAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFiBQAAAAckbWF0Y2gwBQAAAAFiAAAAAAAAAAAABQAAAAN2YWwBAAAADHRyeUdldFN0cmluZwAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWIFAAAAByRtYXR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succeeded", "spentComplexity": 0 } View: original | compacted Prev: Dc7hwifkqJQ2xBTXJjtst192sDTjz5RQ9kZJWQmHbp7p Next: 2E89vURoTYtZFPzrTjFVQzsKL4k96PmNh3gVDtzbJXZL Full:
OldNewDifferences
1-{-# STDLIB_VERSION 3 #-}
1+{-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let maxAuctionDuration = (1440 * 30)
4+let ownerAddress = base58''
55
6-@Callable(i)
7-func startAuction (duration,startPrice,priceAssetId) = {
8- let auctionId = toBase58String(i.transactionId)
9- let endHeight = (lastBlock.height + duration)
10- let pmt = extract(i.payment)
11- if ((duration > maxAuctionDuration))
12- then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration)))
13- else WriteSet([DataEntry(auctionId, endHeight), DataEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), DataEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId))
14- then toBase58String(value(pmt.assetId))
15- else "WAVES"), DataEntry((auctionId + "_lot_amount"), pmt.amount), DataEntry((auctionId + "_startPrice"), startPrice), DataEntry((auctionId + "_priceAssetId"), priceAssetId)])
6+let nftAddress = base58''
7+
8+let nftAssetId = base58''
9+
10+let kGlobalCounter = "GLOBAL_COUNTER"
11+
12+let feePercent = 5
13+
14+let artefactsFeePercent = 20
15+
16+func tryGetInteger (key) = {
17+ let val = match getInteger(this, key) {
18+ case b: Int =>
19+ b
20+ case _ =>
21+ 0
22+ }
23+ val
1624 }
1725
1826
19-
20-@Callable(i)
21-func bid (auctionId) = {
22- let pmt = extract(i.payment)
23- let pmtAssetIdStr = if (isDefined(pmt.assetId))
24- then toBase58String(value(pmt.assetId))
25- else "WAVES"
26- let callerAddressStr = toBase58String(i.caller.bytes)
27- let endHeight = getIntegerValue(this, auctionId)
28- let startPrice = getIntegerValue(this, (auctionId + "_startPrice"))
29- let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId"))
30- let winAmount = getInteger(this, (auctionId + "_winAmount"))
31- let winner = getString(this, (auctionId + "_winner"))
32- let bidFromTheSameUser = if (isDefined(winner))
33- then (value(winner) == callerAddressStr)
34- else false
35- let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser)
36- then value(winAmount)
37- else 0))
38- if ((lastBlock.height >= endHeight))
39- then throw("Auction already finished")
40- else if ((priceAssetId != pmtAssetIdStr))
41- then throw((("Bid must be in asset '" + priceAssetId) + "'"))
42- else if (if (if (isDefined(winAmount))
43- then (value(winAmount) >= totalBidAmount)
44- else false)
45- then true
46- else if (!(isDefined(winAmount)))
47- then (startPrice >= totalBidAmount)
48- else false)
49- then throw(("Bid must be more then " + toString(if (isDefined(winAmount))
50- then value(winAmount)
51- else startPrice)))
52- else if (if (bidFromTheSameUser)
53- then true
54- else !(isDefined(winner)))
55- then WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)])
56- else {
57- let previousBidderAddr = addressFromStringValue(value(winner))
58- let priceAsset = if (if ((priceAssetId == "WAVES"))
59- then true
60- else (priceAssetId == ""))
61- then unit
62- else fromBase58String(priceAssetId)
63- ScriptResult(WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)]))
64- }
27+func tryGetString (key) = {
28+ let val = match getString(this, key) {
29+ case b: String =>
30+ b
31+ case _ =>
32+ ""
33+ }
34+ val
6535 }
6636
6737
38+func tryGetBoolean (key) = match getBoolean(this, key) {
39+ case b: Boolean =>
40+ b
41+ case _ =>
42+ false
43+}
44+
45+
46+func getGlobalCounter () = tryGetInteger(kGlobalCounter)
47+
48+
49+func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(ownerAddress)))
50+ then "ART"
51+ else {
52+ let asset1 = match getString(Address(ownerAddress), toBase58String(assetId)) {
53+ case b: String =>
54+ b
55+ case _ =>
56+ ""
57+ }
58+ if ((asset1 != ""))
59+ then asset1
60+ else {
61+ let asset2 = match getString(Address(nftAddress), toBase58String(assetId)) {
62+ case c: String =>
63+ c
64+ case _ =>
65+ ""
66+ }
67+ if ((asset2 != ""))
68+ then asset2
69+ else ""
70+ }
71+ }
72+
6873
6974 @Callable(i)
70-func withdraw (auctionId) = {
71- let pmt = extract(i.payment)
72- let pmtAssetIdStr = if (isDefined(pmt.assetId))
73- then toBase58String(value(pmt.assetId))
75+func nftBuy (nftId) = {
76+ let isnftart = tryGetBoolean((("nft_" + nftId) + "_nftart"))
77+ let paymentAssetId = if ((isnftart == true))
78+ then nftAssetId
79+ else unit
80+ let paymentAssetName = if ((isnftart == true))
81+ then "nftart"
7482 else "WAVES"
75- let callerAddressStr = toBase58String(i.caller.bytes)
76- let endHeight = getIntegerValue(this, auctionId)
77- let organizer = getStringValue(this, (auctionId + "_organizer"))
78- let winner = getString(this, (auctionId + "_winner"))
79- let lotAssetId = getStringValue(this, (auctionId + "_lot_assetId"))
80- let lotAmount = getIntegerValue(this, (auctionId + "_lot_amount"))
81- let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId"))
82- let winAmount = getIntegerValue(this, (auctionId + "_winAmount"))
83- let lotAsset = if ((lotAssetId == "WAVES"))
84- then unit
85- else fromBase58String(lotAssetId)
86- let priceAsset = if (if ((priceAssetId == "WAVES"))
87- then true
88- else (priceAssetId == ""))
89- then unit
90- else fromBase58String(priceAssetId)
91- let winnerAddr = addressFromStringValue(value(winner))
92- let organizerAddr = addressFromStringValue(value(organizer))
93- let betAmount = getInteger(this, ((auctionId + "_bidder_") + callerAddressStr))
94- if ((endHeight > lastBlock.height))
95- then throw("Auction is not finished yet")
96- else if (!(isDefined(winner)))
97- then if (isDefined(getString(this, (auctionId + "_lot_passed"))))
98- then throw("Organizer has already got his lot back")
99- else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), organizer)]), TransferSet([ScriptTransfer(organizerAddr, lotAmount, lotAsset)]))
100- else if (isDefined(getString(this, (auctionId + "_lot_passed"))))
101- then throw("Lot is already passed to the winner, and organizer got his reward")
102- else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes))]), TransferSet([ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)]))
83+ let pmt = value(i.payments[0])
84+ let amount = pmt.amount
85+ let assetId = tryGetString((("nft_" + nftId) + "_assetId"))
86+ let bidId = toBase58String(i.transactionId)
87+ let nftStatus = tryGetString((("nft_" + nftId) + "_status"))
88+ let finalFee = if ((tryGetBoolean((("nft_" + nftId) + "_isArtefact")) == true))
89+ then artefactsFeePercent
90+ else feePercent
91+ if ((pmt.assetId != paymentAssetId))
92+ then throw((("nft does only support " + paymentAssetName) + " payments."))
93+ else if ((nftStatus != "open"))
94+ then throw("nft is closed. You cannot place a bid.")
95+ else {
96+ let instantPrice = tryGetInteger((("nft_" + nftId) + "_instantPrice"))
97+ if ((instantPrice > amount))
98+ then throw(("For instant purchase you need to pay at least " + toString(instantPrice)))
99+ else {
100+ let nftOwner = tryGetString((("nft_" + nftId) + "_owner"))
101+ let recordPrice = tryGetInteger((assetId + "_recordPrice"))
102+ let newRecordPrice = max([recordPrice, amount])
103+[StringEntry((("nft_" + nftId) + "_status"), "finished"), IntegerEntry((("nft_" + nftId) + "_finalPrice"), amount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"nftId\": \"" + nftId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(amount)) + "\", \"status\": \"finished\"}")), DeleteEntry((((("address_" + nftOwner) + "_nft_") + nftId) + "_lockedNFT")), ScriptTransfer(i.originCaller, 1, fromBase58String(getStringValue(this, (("nft_" + nftId) + "_assetId")))), ScriptTransfer(addressFromStringValue(nftOwner), fraction(amount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(ownerAddress), fraction(amount, finalFee, 100), paymentAssetId)]
104+ }
105+ }
103106 }
104107
105108

github/deemru/w8io/026f985 
43.78 ms