tx · 2iFt5Msdd8sjfZ3TgvBbZtwjgt3rYZ6cCvTRDgBoQyKc 3MtVYGt1cJJB8g21cvSzJScK3hxUi9JHdcN: -0.01400000 Waves 2021.12.23 13:01 [1846755] smart account 3MtVYGt1cJJB8g21cvSzJScK3hxUi9JHdcN > SELF 0.00000000 Waves
{ "type": 13, "id": "2iFt5Msdd8sjfZ3TgvBbZtwjgt3rYZ6cCvTRDgBoQyKc", "fee": 1400000, "feeAssetId": null, "timestamp": 1640253677211, "version": 2, "chainId": 84, "sender": "3MtVYGt1cJJB8g21cvSzJScK3hxUi9JHdcN", "senderPublicKey": "65qdY9G3EVQgF1GhvrT6rw2zPmUsFirt9Kjm5q5fdJvu", "proofs": [ "3hrEN1rvRoNGE1SN3cbWJCdjHV84y45VkZnn5KvqBjwnVxn9WKTjdAzcLB8j1ogu1QrbuKw9J4MSwhydU7vnqpiw" ], "script": "base64:AAIFAAAAAAAAAmoIAhIGCgQBAQgIEgMKAQgSBAoCCAgaCgoBQRIFYmlkSWQaDQoBQhIIbWluUHJpY2UaEQoBQxIMYXVjdGlvbk93bmVyGg4KAUQSCWJpZEF1dGhvchoOCgFFEgliaWRBbW91bnQaDgoBRhIJYmlkU3RhdHVzGg0KAUcSCGZpbmFsRmVlGhAKAUgSC3JlY29yZFByaWNlGhMKAUkSDm5ld1JlY29yZFByaWNlGgcKAUoSAnR4GgsKAUsSBnZlcmlmeRoVCgFhEhBORlRJc3N1ZXJBZGRyZXNzGg8KAWISCmVnZ0Fzc2V0SWQaEQoBYxIMb3duZXJBZGRyZXNzGg8KAWQSCmZlZVBlcmNlbnQaGAoBZRITYXJ0ZWZhY3RzRmVlUGVyY2VudBoSCgFmEg10cnlHZXRJbnRlZ2VyGggKAWcSA2tleRoICgFoEgN2YWwaDAoBaRIHJG1hdGNoMBoGCgFqEgFiGhEKAWsSDHRyeUdldFN0cmluZxoSCgFsEg10cnlHZXRCb29sZWFuGhUKAW0SEGdldEFzc2V0R2Vub3R5cGUaDAoB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BQAAAAF0AgAAAApfbG9ja2VkTkZUCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFvAAAABmNhbGxlcgkAAGsAAAADBQAAAAFFCQAAZQAAAAIAAAAAAAAAAGQFAAAAAUcAAAAAAAAAAGQFAAAAAXgJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAB0FkZHJlc3MAAAABBQAAAAFjCQAAawAAAAMFAAAAAUUFAAAAAUcAAAAAAAAAAGQFAAAAAXgJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQUAAAABRAAAAAAAAAAAAQkAAlkAAAABBQAAAAFuBQAAAANuaWwAAAABAAAAAUoBAAAAAUsAAAAACQAB9AAAAAMIBQAAAAFKAAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAABSgAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAFKAAAAD3NlbmRlclB1YmxpY0tleZ6ayow=", "height": 1846755, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G495Ly92r4PnPRqXWGh5HhCvbTYewwAePvz3tNscbc7r Next: EneWmzuMyo8bPo935j7KBhNwm1sHMbCptMKdnJqiyDh Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let eggAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB' | |
7 | 7 | ||
8 | + | let ownerAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU' | |
9 | + | ||
10 | + | let feePercent = 5 | |
11 | + | ||
12 | + | let artefactsFeePercent = 20 | |
13 | + | ||
8 | 14 | func tryGetInteger (key) = { | |
9 | 15 | let val = match getInteger(this, key) { | |
10 | 16 | case b: Int => | |
11 | 17 | b | |
12 | 18 | case _ => | |
13 | 19 | 0 | |
20 | + | } | |
21 | + | val | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func tryGetString (key) = { | |
26 | + | let val = match getString(this, key) { | |
27 | + | case b: String => | |
28 | + | b | |
29 | + | case _ => | |
30 | + | "" | |
14 | 31 | } | |
15 | 32 | val | |
16 | 33 | } | |
66 | 83 | } | |
67 | 84 | ||
68 | 85 | ||
86 | + | ||
87 | + | @Callable(i) | |
88 | + | func acceptBid (auctionId,bidId) = { | |
89 | + | let isEggSell = tryGetBoolean((("auction_" + auctionId) + "_eggSell")) | |
90 | + | let paymentAssetId = if ((isEggSell == true)) | |
91 | + | then eggAssetId | |
92 | + | else unit | |
93 | + | let auctionOwner = tryGetString((("auction_" + auctionId) + "_owner")) | |
94 | + | let bidAuthor = tryGetString((((("auction_" + auctionId) + "_bid_") + bidId) + "_author")) | |
95 | + | let bidAmount = tryGetInteger((((("auction_" + auctionId) + "_bid_") + bidId) + "_amount")) | |
96 | + | let bidStatus = tryGetString((((("auction_" + auctionId) + "_bid_") + bidId) + "_status")) | |
97 | + | let assetId = tryGetString((("auction_" + auctionId) + "_assetId")) | |
98 | + | let finalFee = if ((tryGetBoolean((("auction_" + auctionId) + "_isArtefact")) == true)) | |
99 | + | then artefactsFeePercent | |
100 | + | else feePercent | |
101 | + | if ((toString(i.originCaller) != auctionOwner)) | |
102 | + | then throw("Only allowed to auction owner") | |
103 | + | else if ((bidStatus != "open")) | |
104 | + | then throw("Bid was cancelled and cannot be accepted") | |
105 | + | else if ((tryGetString((("auction_" + auctionId) + "_status")) != "open")) | |
106 | + | then throw("Auction was closed") | |
107 | + | else { | |
108 | + | let recordPrice = tryGetInteger((assetId + "_recordPrice")) | |
109 | + | let newRecordPrice = max([recordPrice, bidAmount]) | |
110 | + | [StringEntry((((("auction_" + auctionId) + "_bid_") + bidId) + "_status"), "finished"), StringEntry((("auction_" + auctionId) + "_status"), "finished"), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"auctionId\": \"" + auctionId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(bidAmount)) + "\", \"status\": \"finished\"}")), IntegerEntry((("auction_" + auctionId) + "_finalPrice"), bidAmount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), DeleteEntry(((((("address_" + bidAuthor) + "_auction_") + auctionId) + "_bid_") + bidId)), DeleteEntry((((("address_" + auctionOwner) + "_auction_") + auctionId) + "_lockedNFT")), ScriptTransfer(i.caller, fraction(bidAmount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(ownerAddress), fraction(bidAmount, finalFee, 100), paymentAssetId), ScriptTransfer(addressFromStringValue(bidAuthor), 1, fromBase58String(assetId))] | |
111 | + | } | |
112 | + | } | |
113 | + | ||
114 | + | ||
69 | 115 | @Verifier(tx) | |
70 | 116 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
71 | 117 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NFTIssuerAddress = base58'3N992tjd7EWM6dSHrdVjjjuJrLD4koNztZ9' | |
5 | 5 | ||
6 | 6 | let eggAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB' | |
7 | 7 | ||
8 | + | let ownerAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU' | |
9 | + | ||
10 | + | let feePercent = 5 | |
11 | + | ||
12 | + | let artefactsFeePercent = 20 | |
13 | + | ||
8 | 14 | func tryGetInteger (key) = { | |
9 | 15 | let val = match getInteger(this, key) { | |
10 | 16 | case b: Int => | |
11 | 17 | b | |
12 | 18 | case _ => | |
13 | 19 | 0 | |
20 | + | } | |
21 | + | val | |
22 | + | } | |
23 | + | ||
24 | + | ||
25 | + | func tryGetString (key) = { | |
26 | + | let val = match getString(this, key) { | |
27 | + | case b: String => | |
28 | + | b | |
29 | + | case _ => | |
30 | + | "" | |
14 | 31 | } | |
15 | 32 | val | |
16 | 33 | } | |
17 | 34 | ||
18 | 35 | ||
19 | 36 | func tryGetBoolean (key) = match getBoolean(this, key) { | |
20 | 37 | case b: Boolean => | |
21 | 38 | b | |
22 | 39 | case _ => | |
23 | 40 | false | |
24 | 41 | } | |
25 | 42 | ||
26 | 43 | ||
27 | 44 | func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(NFTIssuerAddress))) | |
28 | 45 | then "ART" | |
29 | 46 | else "" | |
30 | 47 | ||
31 | 48 | ||
32 | 49 | @Callable(i) | |
33 | 50 | func initAuction (startPrice,instantPrice,description,eggSell) = { | |
34 | 51 | let auctionId = toBase58String(i.transactionId) | |
35 | 52 | let pmt = value(i.payments[0]) | |
36 | 53 | let assetId = value(pmt.assetId) | |
37 | 54 | let asset = getAssetGenotype(assetId) | |
38 | 55 | if ((asset == "")) | |
39 | 56 | then throw("You can only sell an NFT-duck created in incubator or breeder") | |
40 | 57 | else [StringEntry((("auction_" + auctionId) + "_status"), "open"), BooleanEntry((("auction_" + auctionId) + "_eggSell"), (eggSell == "true")), StringEntry((("auction_" + toBase58String(assetId)) + "_last"), auctionId), StringEntry((("auction_" + auctionId) + "_assetGen"), asset), StringEntry((("auction_" + auctionId) + "_assetId"), toBase58String(assetId)), IntegerEntry((("auction_" + auctionId) + "_startedAt"), lastBlock.timestamp), StringEntry((("auction_" + auctionId) + "_owner"), toString(i.originCaller)), StringEntry((("auction_" + auctionId) + "_description"), description), IntegerEntry((("auction_" + auctionId) + "_startPrice"), startPrice), BooleanEntry((("auction_" + auctionId) + "_isArtefact"), (value(assetInfo(assetId)).issuer == Address(NFTIssuerAddress))), IntegerEntry((("auction_" + auctionId) + "_instantPrice"), instantPrice), StringEntry((((("address_" + toString(i.originCaller)) + "_auction_") + auctionId) + "_lockedNFT"), toBase58String(assetId))] | |
41 | 58 | } | |
42 | 59 | ||
43 | 60 | ||
44 | 61 | ||
45 | 62 | @Callable(i) | |
46 | 63 | func placeBid (auctionId) = { | |
47 | 64 | let isEggSell = tryGetBoolean((("auction_" + auctionId) + "_eggSell")) | |
48 | 65 | let paymentAssetId = if ((isEggSell == true)) | |
49 | 66 | then eggAssetId | |
50 | 67 | else unit | |
51 | 68 | let paymentAssetName = if ((isEggSell == true)) | |
52 | 69 | then "EGG" | |
53 | 70 | else "WAVES" | |
54 | 71 | let pmt = value(i.payments[0]) | |
55 | 72 | let amount = pmt.amount | |
56 | 73 | let bidId = toBase58String(i.transactionId) | |
57 | 74 | let assetId = getStringValue(this, (("auction_" + auctionId) + "_assetId")) | |
58 | 75 | if ((pmt.assetId != paymentAssetId)) | |
59 | 76 | then throw((("Auction does only support " + paymentAssetName) + " payments.")) | |
60 | 77 | else { | |
61 | 78 | let minPrice = tryGetInteger((("auction_" + auctionId) + "_startPrice")) | |
62 | 79 | if ((minPrice > amount)) | |
63 | 80 | then throw(("The minimal initial price is set as " + toString(minPrice))) | |
64 | 81 | else [StringEntry((((("auction_" + auctionId) + "_bid_") + bidId) + "_author"), toString(i.originCaller)), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"auctionId\": \"" + auctionId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(amount)) + "\", \"status\": \"open\"}")), IntegerEntry((((("auction_" + auctionId) + "_bid_") + bidId) + "_amount"), amount), StringEntry(((((("address_" + toString(i.originCaller)) + "_auction_") + auctionId) + "_bid_") + bidId), assetId), StringEntry((((("auction_" + auctionId) + "_bid_") + bidId) + "_status"), "open")] | |
65 | 82 | } | |
66 | 83 | } | |
67 | 84 | ||
68 | 85 | ||
86 | + | ||
87 | + | @Callable(i) | |
88 | + | func acceptBid (auctionId,bidId) = { | |
89 | + | let isEggSell = tryGetBoolean((("auction_" + auctionId) + "_eggSell")) | |
90 | + | let paymentAssetId = if ((isEggSell == true)) | |
91 | + | then eggAssetId | |
92 | + | else unit | |
93 | + | let auctionOwner = tryGetString((("auction_" + auctionId) + "_owner")) | |
94 | + | let bidAuthor = tryGetString((((("auction_" + auctionId) + "_bid_") + bidId) + "_author")) | |
95 | + | let bidAmount = tryGetInteger((((("auction_" + auctionId) + "_bid_") + bidId) + "_amount")) | |
96 | + | let bidStatus = tryGetString((((("auction_" + auctionId) + "_bid_") + bidId) + "_status")) | |
97 | + | let assetId = tryGetString((("auction_" + auctionId) + "_assetId")) | |
98 | + | let finalFee = if ((tryGetBoolean((("auction_" + auctionId) + "_isArtefact")) == true)) | |
99 | + | then artefactsFeePercent | |
100 | + | else feePercent | |
101 | + | if ((toString(i.originCaller) != auctionOwner)) | |
102 | + | then throw("Only allowed to auction owner") | |
103 | + | else if ((bidStatus != "open")) | |
104 | + | then throw("Bid was cancelled and cannot be accepted") | |
105 | + | else if ((tryGetString((("auction_" + auctionId) + "_status")) != "open")) | |
106 | + | then throw("Auction was closed") | |
107 | + | else { | |
108 | + | let recordPrice = tryGetInteger((assetId + "_recordPrice")) | |
109 | + | let newRecordPrice = max([recordPrice, bidAmount]) | |
110 | + | [StringEntry((((("auction_" + auctionId) + "_bid_") + bidId) + "_status"), "finished"), StringEntry((("auction_" + auctionId) + "_status"), "finished"), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"auctionId\": \"" + auctionId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(bidAmount)) + "\", \"status\": \"finished\"}")), IntegerEntry((("auction_" + auctionId) + "_finalPrice"), bidAmount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), DeleteEntry(((((("address_" + bidAuthor) + "_auction_") + auctionId) + "_bid_") + bidId)), DeleteEntry((((("address_" + auctionOwner) + "_auction_") + auctionId) + "_lockedNFT")), ScriptTransfer(i.caller, fraction(bidAmount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(ownerAddress), fraction(bidAmount, finalFee, 100), paymentAssetId), ScriptTransfer(addressFromStringValue(bidAuthor), 1, fromBase58String(assetId))] | |
111 | + | } | |
112 | + | } | |
113 | + | ||
114 | + | ||
69 | 115 | @Verifier(tx) | |
70 | 116 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
71 | 117 |
github/deemru/w8io/169f3d6 44.37 ms ◑