tx · 55F1TTY5LEyZA8gSAa6sHPQVRDcvrj3oo4QEhKrWnixZ 3N8wF4ntF9niEgikocU8yb1UU9spbdCtWsh: -0.01400000 Waves 2022.02.23 01:24 [1935460] smart account 3N8wF4ntF9niEgikocU8yb1UU9spbdCtWsh > SELF 0.00000000 Waves
{ "type": 13, "id": "55F1TTY5LEyZA8gSAa6sHPQVRDcvrj3oo4QEhKrWnixZ", "fee": 1400000, "feeAssetId": null, "timestamp": 1645568712299, "version": 2, "chainId": 84, "sender": "3N8wF4ntF9niEgikocU8yb1UU9spbdCtWsh", "senderPublicKey": "HD1V9wMeKPrrSPB7aVX6wDgfTgYayNB6vb7LHkVJZzvV", "proofs": [ "3YBVexWatvni1h2djUzLxqh652N9RJjhGYbD13G2LJPBKkQya8ZzFiP64ZREC9RXPmfsgdAhKTQ4uVinmtzcHtX6" ], "script": "base64:AAIDAAAAAAAAABMIARIFCgMBAQgSAwoBCBIDCgEIAAAAAQAAAAASbWF4QXVjdGlvbkR1cmF0aW9uAAAAAAAAAfpAAAAAAwAAAAFpAQAAAAxzdGFydEF1Y3Rpb24AAAADAAAACGR1cmF0aW9uAAAACnN0YXJ0UHJpY2UAAAAMcHJpY2VBc3NldElkBAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAQAAAAJYXVjdGlvbklkCQACWAAAAAEIBQAAAAFpAAAADXRyYW5zYWN0aW9uSWQEAAAACWVuZEhlaWdodAkAAGQAAAACCAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAUAAAAIZHVyYXRpb24EAAAAC29yZ2FuaXNlcmlkCQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMEAAAAD0F1Y3Rpb25kdXJhdGlvbgkBAAAACURhdGFFbnRyeQAAAAIFAAAACWF1Y3Rpb25JZAUAAAAJZW5kSGVpZ2h0BAAAAAlvcmdhbmlzZXIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAAC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F9wYXNzZWQJAAACAAAAAQIAAABBTG90IGlzIGFscmVhZHkgcGFzc2VkIHRvIHRoZSB3aW5uZXIsIGFuZCBvcmdhbml6ZXIgZ290IGhpcyByZXdhcmQJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAACWF1Y3Rpb25JZAIAAAALX2xvdF9wYXNzZWQJAAJYAAAAAQgFAAAACndpbm5lckFkZHIAAAAFYnl0ZXMFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAp3aW5uZXJBZGRyBQAAAAlsb3RBbW91bnQFAAAACGxvdEFzc2V0CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAADW9yZ2FuaXplckFkZHIJAABpAAAAAgkAAGgAAAACBQAAAAl3aW5BbW91bnQAAAAAAAAAAF8AAAAAAAAAAGQFAAAACnByaWNlQXNzZXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAFGFkZHJlc3NGcm9tUHVibGljS2V5AAAAAQEAAAAgPbGudhoC2EmTbbT+1HzFYzykEopCrrlDCkRclNVlCm8JAABpAAAAAgkAAGgAAAACBQAAAAl3aW5BbW91bnQAAAAAAAAAAAUAAAAAAAAAAGQFAAAACnByaWNlQXNzZXQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5AXU5Gw==", "height": 1935460, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AF3Uh5BTus5Nf5uBWTrHybrWt6x3K4CYTKGeoYr3TRMF Next: none Diff:
Old | New | Differences | |
---|---|---|---|
20 | 20 | if ((duration > maxAuctionDuration)) | |
21 | 21 | then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration))) | |
22 | 22 | else if ((1000 >= startPrice)) | |
23 | - | then throw("Auction StartPrice less than 0.001") | |
23 | + | then throw("Auction StartPrice less than 0.001 USDT.") | |
24 | 24 | else WriteSet([Auctionduration, organiser, lotassetid, lotamount, startprice, priceassetid]) | |
25 | 25 | } | |
26 | 26 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let maxAuctionDuration = 129600 | |
5 | 5 | ||
6 | 6 | @Callable(i) | |
7 | 7 | func startAuction (duration,startPrice,priceAssetId) = { | |
8 | 8 | let pmt = extract(i.payment) | |
9 | 9 | let auctionId = toBase58String(i.transactionId) | |
10 | 10 | let endHeight = (lastBlock.height + duration) | |
11 | 11 | let organiserid = toBase58String(i.caller.bytes) | |
12 | 12 | let Auctionduration = DataEntry(auctionId, endHeight) | |
13 | 13 | let organiser = DataEntry((auctionId + "_organizer"), organiserid) | |
14 | 14 | let lotassetid = DataEntry((auctionId + "_lot_assetId"), if (isDefined(pmt.assetId)) | |
15 | 15 | then toBase58String(value(pmt.assetId)) | |
16 | 16 | else "WAVES") | |
17 | 17 | let lotamount = DataEntry((auctionId + "_lot_amount"), pmt.amount) | |
18 | 18 | let startprice = DataEntry((auctionId + "_startPrice"), startPrice) | |
19 | 19 | let priceassetid = DataEntry((auctionId + "_priceAssetId"), priceAssetId) | |
20 | 20 | if ((duration > maxAuctionDuration)) | |
21 | 21 | then throw(("Duration is too long. Must be less than " + toString(maxAuctionDuration))) | |
22 | 22 | else if ((1000 >= startPrice)) | |
23 | - | then throw("Auction StartPrice less than 0.001") | |
23 | + | then throw("Auction StartPrice less than 0.001 USDT.") | |
24 | 24 | else WriteSet([Auctionduration, organiser, lotassetid, lotamount, startprice, priceassetid]) | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | ||
29 | 29 | @Callable(i) | |
30 | 30 | func bid (auctionId) = { | |
31 | 31 | let pmt = extract(i.payment) | |
32 | 32 | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
33 | 33 | then toBase58String(value(pmt.assetId)) | |
34 | 34 | else "WAVES" | |
35 | 35 | let callerAddressStr = toBase58String(i.caller.bytes) | |
36 | 36 | let endHeight = getIntegerValue(this, auctionId) | |
37 | 37 | let startPrice = getIntegerValue(this, (auctionId + "_startPrice")) | |
38 | 38 | let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId")) | |
39 | 39 | let winAmount = getInteger(this, (auctionId + "_winAmount")) | |
40 | 40 | let winner = getString(this, (auctionId + "_winner")) | |
41 | 41 | let bidFromTheSameUser = if (isDefined(winner)) | |
42 | 42 | then (value(winner) == callerAddressStr) | |
43 | 43 | else false | |
44 | 44 | let totalBidAmount = (pmt.amount + (if (bidFromTheSameUser) | |
45 | 45 | then value(winAmount) | |
46 | 46 | else 0)) | |
47 | 47 | if ((lastBlock.height >= endHeight)) | |
48 | 48 | then throw("Auction already finished") | |
49 | 49 | else if ((priceAssetId != pmtAssetIdStr)) | |
50 | 50 | then throw((("Bid must be in asset '" + priceAssetId) + "'")) | |
51 | 51 | else if (if (if (isDefined(winAmount)) | |
52 | 52 | then (value(winAmount) >= totalBidAmount) | |
53 | 53 | else false) | |
54 | 54 | then true | |
55 | 55 | else if (!(isDefined(winAmount))) | |
56 | 56 | then (startPrice >= totalBidAmount) | |
57 | 57 | else false) | |
58 | 58 | then throw(("Bid must be more then " + toString(if (isDefined(winAmount)) | |
59 | 59 | then value(winAmount) | |
60 | 60 | else startPrice))) | |
61 | 61 | else if (if (bidFromTheSameUser) | |
62 | 62 | then true | |
63 | 63 | else !(isDefined(winner))) | |
64 | 64 | then WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]) | |
65 | 65 | else { | |
66 | 66 | let previousBidderAddr = addressFromStringValue(value(winner)) | |
67 | 67 | let priceAsset = if (if ((priceAssetId == "WAVES")) | |
68 | 68 | then true | |
69 | 69 | else (priceAssetId == "")) | |
70 | 70 | then unit | |
71 | 71 | else fromBase58String(priceAssetId) | |
72 | 72 | ScriptResult(WriteSet([DataEntry((auctionId + "_winner"), callerAddressStr), DataEntry((auctionId + "_winAmount"), totalBidAmount)]), TransferSet([ScriptTransfer(previousBidderAddr, value(winAmount), priceAsset)])) | |
73 | 73 | } | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | 78 | @Callable(i) | |
79 | 79 | func withdraw (auctionId) = { | |
80 | 80 | let pmt = extract(i.payment) | |
81 | 81 | let pmtAssetIdStr = if (isDefined(pmt.assetId)) | |
82 | 82 | then toBase58String(value(pmt.assetId)) | |
83 | 83 | else "WAVES" | |
84 | 84 | let callerAddressStr = toBase58String(i.caller.bytes) | |
85 | 85 | let endHeight = getIntegerValue(this, auctionId) | |
86 | 86 | let organizer = getStringValue(this, (auctionId + "_organizer")) | |
87 | 87 | let winner = getString(this, (auctionId + "_winner")) | |
88 | 88 | let lotAssetId = getStringValue(this, (auctionId + "_lot_assetId")) | |
89 | 89 | let lotAmount = getIntegerValue(this, (auctionId + "_lot_amount")) | |
90 | 90 | let priceAssetId = getStringValue(this, (auctionId + "_priceAssetId")) | |
91 | 91 | let winAmount = getIntegerValue(this, (auctionId + "_winAmount")) | |
92 | 92 | let lotAsset = if ((lotAssetId == "WAVES")) | |
93 | 93 | then unit | |
94 | 94 | else fromBase58String(lotAssetId) | |
95 | 95 | let priceAsset = if (if ((priceAssetId == "WAVES")) | |
96 | 96 | then true | |
97 | 97 | else (priceAssetId == "")) | |
98 | 98 | then unit | |
99 | 99 | else fromBase58String(priceAssetId) | |
100 | 100 | let winnerAddr = addressFromStringValue(value(winner)) | |
101 | 101 | let organizerAddr = addressFromStringValue(value(organizer)) | |
102 | 102 | let betAmount = getInteger(this, ((auctionId + "_bidder_") + callerAddressStr)) | |
103 | 103 | if ((endHeight > lastBlock.height)) | |
104 | 104 | then throw("Auction is not finished yet") | |
105 | 105 | else if (!(isDefined(winner))) | |
106 | 106 | then if (isDefined(getString(this, (auctionId + "_lot_passed")))) | |
107 | 107 | then throw("Organizer has already got his lot back") | |
108 | 108 | else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), organizer)]), TransferSet([ScriptTransfer(organizerAddr, lotAmount, lotAsset)])) | |
109 | 109 | else if (isDefined(getString(this, (auctionId + "_lot_passed")))) | |
110 | 110 | then throw("Lot is already passed to the winner, and organizer got his reward") | |
111 | 111 | else ScriptResult(WriteSet([DataEntry((auctionId + "_lot_passed"), toBase58String(winnerAddr.bytes))]), TransferSet([ScriptTransfer(winnerAddr, lotAmount, lotAsset), ScriptTransfer(organizerAddr, ((winAmount * 95) / 100), priceAsset), ScriptTransfer(addressFromPublicKey(base58'59q1hHBmeQgfSRst9Dn52VTBbtCu4SQ7AujhGDjHCqn6'), ((winAmount * 5) / 100), priceAsset)])) | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | @Verifier(tx) | |
116 | 116 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
117 | 117 |
github/deemru/w8io/026f985 28.35 ms ◑