tx · 3PATYRBvW1eqntrTjwRhPxJMQ2udWogCfqHBX88Esp1J

3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo:  -0.01000000 Waves

2022.11.30 17:50 [2339974] smart account 3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo > SELF 0.00000000 Waves

{ "type": 13, "id": "3PATYRBvW1eqntrTjwRhPxJMQ2udWogCfqHBX88Esp1J", "fee": 1000000, "feeAssetId": null, "timestamp": 1669819792833, "version": 2, "chainId": 84, "sender": "3N72SETEKtTuaA3YNVYWgVEmXKrRrZYXHGo", "senderPublicKey": "Kwu4LYBMntApXv8t7csxV23Kvc3tvak26wMKK56tA4V", "proofs": [ "3hvLC48DUQp6JSttkwB7zT9v7DTzDuho5RsJ2SnVacmAZieonafhJ6stRW2E2r4hPCUb9nx1XcCCreTvgJXXiwAW" ], "script": "base64:BgIECAISAAMACHNyY1Rva2VuASDrDORiL78bfnLZD9yQPcKtl1WDneElHcPWa5Q89KYjBQAIZHN0VG9rZW4BIHuQGmnVEyOcsKL8y7H43/pBbyVsZO5cGLxU2tkA8570AAdtZXNzYWdlAiFUaGFuayB5b3UgZm9yIHVzaW5nIHRoZSBTV0FQIERBcHABAWkBBHN3YXAABANwbXQJAQV2YWx1ZQEJAJEDAggFAWkIcGF5bWVudHMAAAMJAQIhPQIIBQNwbXQHYXNzZXRJZAUIc3JjVG9rZW4JAAIBAhdJbmNvcnJlY3QgYXNzZXQgcGFzc2VkLgkAzAgCCQELU3RyaW5nRW50cnkCAgdtZXNzYWdlCQCsAgIJAKwCAgIfPGgxPllvdSBkaWQgYSBzd2FwITwvaDE+PGJyPjxwPgUHbWVzc2FnZQIDPHA+CQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcggFA3BtdAZhbW91bnQFCGRzdFRva2VuBQNuaWwBAnR4AQZ2ZXJpZnkABAckbWF0Y2gwBQJ0eAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tlea/5pv4=", "height": 2339974, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Bgkz9vQtpSJv2EoTS7GBsMyHQFA1qwK9YfgBcUgRJ6mt Next: CFX9BLfo98YfWYQdqrLAPxQvSuMs2ohhSUQUurdAE532 Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let maxAuctionDuration = 7
4+let srcToken = base58'GpYDEF3wvpq8eGtk8EA5nUTWrpYnAnHmkrFoHAa1exf6'
5+
6+let dstToken = base58'9KLbMrNFxAToNzXvm517165sbNjmKdTNMvjgoxEyx62F'
7+
8+let message = "Thank you for using the SWAP DApp"
59
610 @Callable(i)
7-func startAuction (duration,startPrice) = {
8- let auctionId = toBase58String(i.transactionId)
9- let endHeight = (lastBlock.height + duration)
11+func swap () = {
1012 let pmt = value(i.payments[0])
11- if ((duration > maxAuctionDuration))
12- then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration)))
13- else [IntegerEntry(auctionId, endHeight), StringEntry((auctionId + "_organizer"), toBase58String(i.caller.bytes)), StringEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId))
14- then toBase58String(value(pmt.assetId))
15- else "WAVES"), IntegerEntry((auctionId + "_lot_amount"), pmt.amount), IntegerEntry((auctionId + "_startPrice"), startPrice)]
13+ if ((pmt.assetId != srcToken))
14+ then throw("Incorrect asset passed.")
15+ else [StringEntry("message", (("<h1>You did a swap!</h1><br><p>" + message) + "<p>")), ScriptTransfer(i.caller, pmt.amount, dstToken)]
1616 }
1717
1818
19-
20-@Callable(i)
21-func bid (auctionId) = {
22- let pmt = value(i.payments[0])
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 [StringEntry((auctionId + "_winner"), callerAddressStr), IntegerEntry((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-[StringEntry((auctionId + "_winner"), callerAddressStr), IntegerEntry((auctionId + "_winAmount"), totalBidAmount), ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)]
64- }
65- }
66-
67-
68-
69-@Callable(i)
70-func withdraw (auctionId) = {
71- let pmt = value(i.payments[0])
72- let pmtAssetIdStr = if (isDefined(pmt.assetId))
73- then toBase58String(value(pmt.assetId))
74- 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 [StringEntry((auctionId + "_lot_passed"), organizer), 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 [StringEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes)), ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, winAmount, priceAsset)]
103- }
104-
19+@Verifier(tx)
20+func verify () = match tx {
21+ case _ =>
22+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
23+}
10524

github/deemru/w8io/026f985 
30.04 ms