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