tx · 5dv17W9kjENMd97aBmUVcFFCMC5fR3Ahvm8gbAVtTi6Q 3Mr6LNXTo2cMvNMrka9pV1pwHZFXVHULoue: -0.01400000 Waves 2021.12.06 09:59 [1822072] smart account 3Mr6LNXTo2cMvNMrka9pV1pwHZFXVHULoue > SELF 0.00000000 Waves
{ "type": 13, "id": "5dv17W9kjENMd97aBmUVcFFCMC5fR3Ahvm8gbAVtTi6Q", "fee": 1400000, "feeAssetId": null, "timestamp": 1638774010719, "version": 2, "chainId": 84, "sender": "3Mr6LNXTo2cMvNMrka9pV1pwHZFXVHULoue", "senderPublicKey": "9tHFZ3PMkyXBYPkjU77RdMPEGBzfm7BWxfuHvGjgdrv5", "proofs": [ "2pAX3MKJs2PtEpzLvFcuxRHckAarcG4WU3iJe9BhEMud4QioyD1Dn8zBAQChHmQ17BEHcQVy4kfihw5vrNxSyzEb" ], "script": "base64:AAIFAAAAAAAAAWIIAhIDCgEBEgMKAQgSAwoBCBoOCgJhMRIIcHJpY2VLZXkaCwoCYTISBWFzc2V0Gg4KAmEzEghvd25lcktleRoPCgJhNBIJaXNzdWVyS2V5Gg0KAmE1EgduYW1lS2V5GhQKAmE2Eg5kZXNjcmlwdGlvbktleRoTCgJhNxINdHJ5R2V0SW50ZWdlchoJCgJhOBIDa2V5GgkKAmE5EgN2YWwaDQoCYjESByRtYXRjaDAaEgoCYjISDHRyeUdldFN0cmluZxoLCgJiMxIFcHJpY2UaEgoCYjQSDGZpcnN0UGF5bWVudBoNCgJiNRIHYXNzZXRJZBoQCgJiNhIKYXNzZXRJZFN0choOCgJiNxIIYXNzZXRTdHIaDgoCYjgSCG93bmVyU3RyGgsKAmI5EgVvd25lchoWCgJjMRIQZmlyc3RQYXltZW50Qm9vbBoJCgJjMhIDZmVlGgwKAmMzEgZ2ZXJpZnkAAAAHAQAAAAJhMQAAAAEAAAACYTIJAAEsAAAAAgUAAAACYTICAAAABl9wcmljZQEAAAACYTMAAAABAAAAAmEyCQABLAAAAAIFAAAAAm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I4AwkAAAEAAAACBQAAAAJiMQIAAAAHQWRkcmVzcwQAAAABYQUAAAACYjEFAAAAAWEJAAACAAAAAQIAAAAVQWRkcmVzcyBwYXJzaW5nIGVycm9yAwkBAAAAAiE9AAAAAgUAAAACYjgJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkAAAIAAAABAgAAADVUaGUgY2FsbGluZyBhZGRyZXNzIGlzIG5vdCB0aGUgb3duZXIgb2YgdGhlIE5GVCB0b2tlbgkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEJAAJZAAAAAQUAAAACYjcJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAmExAAAAAQUAAAACYjcJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAmEzAAAAAQUAAAACYjcJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAmE0AAAAAQUAAAACYjcJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAmE1AAAAAQUAAAACYjcJAARMAAAAAgkBAAAAC0RlbGV0ZUVudHJ5AAAAAQkBAAAAAmE2AAAAAQUAAAACYjcFAAAAA25pbAAAAAEAAAACdHgBAAAAAmMzAAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmIoM4C", "height": 1822072, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 68vEkzF76dyop3nTFC7sVep9KXsXBrKaZsiCfpvWZXKu Next: none Diff:
Old | New | Differences | |
---|---|---|---|
8 | 8 | ||
9 | 9 | ||
10 | 10 | func issuerKey (asset) = (asset + "_issuer") | |
11 | + | ||
12 | + | ||
13 | + | func nameKey (asset) = (asset + "_name") | |
11 | 14 | ||
12 | 15 | ||
13 | 16 | func descriptionKey (asset) = (asset + "_description") | |
59 | 62 | then asset.reissuable | |
60 | 63 | else false) | |
61 | 64 | then throw("Asset is not NFT") | |
62 | - | else [IntegerEntry(priceKey(assetIdStr), price), StringEntry(ownerKey(assetIdStr), toBase58String(i.caller.bytes)), StringEntry(issuerKey(assetIdStr), toBase58String(asset.issuer.bytes)), StringEntry(descriptionKey(assetIdStr), asset.description)] | |
65 | + | else [IntegerEntry(priceKey(assetIdStr), price), StringEntry(ownerKey(assetIdStr), toBase58String(i.caller.bytes)), StringEntry(issuerKey(assetIdStr), toBase58String(asset.issuer.bytes)), StringEntry(nameKey(assetIdStr), asset.name), StringEntry(descriptionKey(assetIdStr), asset.description)] | |
63 | 66 | } | |
64 | 67 | ||
65 | 68 | ||
91 | 94 | then throw("Insufficient funds") | |
92 | 95 | else { | |
93 | 96 | let fee = ((price / 100) * 5) | |
94 | - | [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), ScriptTransfer(owner, (price - fee), unit), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
97 | + | [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), ScriptTransfer(owner, (price - fee), unit), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(nameKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
95 | 98 | } | |
96 | 99 | } | |
97 | 100 | ||
108 | 111 | } | |
109 | 112 | if ((ownerStr != toBase58String(i.caller.bytes))) | |
110 | 113 | then throw("The calling address is not the owner of the NFT token") | |
111 | - | else [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
114 | + | else [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(nameKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
112 | 115 | } | |
113 | 116 | ||
114 | 117 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func priceKey (asset) = (asset + "_price") | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func ownerKey (asset) = (asset + "_owner") | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func issuerKey (asset) = (asset + "_issuer") | |
11 | + | ||
12 | + | ||
13 | + | func nameKey (asset) = (asset + "_name") | |
11 | 14 | ||
12 | 15 | ||
13 | 16 | func descriptionKey (asset) = (asset + "_description") | |
14 | 17 | ||
15 | 18 | ||
16 | 19 | func tryGetInteger (key) = { | |
17 | 20 | let val = match getInteger(this, key) { | |
18 | 21 | case b: Int => | |
19 | 22 | b | |
20 | 23 | case _ => | |
21 | 24 | 0 | |
22 | 25 | } | |
23 | 26 | val | |
24 | 27 | } | |
25 | 28 | ||
26 | 29 | ||
27 | 30 | func tryGetString (key) = { | |
28 | 31 | let val = match getString(this, key) { | |
29 | 32 | case b: String => | |
30 | 33 | b | |
31 | 34 | case _ => | |
32 | 35 | "" | |
33 | 36 | } | |
34 | 37 | val | |
35 | 38 | } | |
36 | 39 | ||
37 | 40 | ||
38 | 41 | @Callable(i) | |
39 | 42 | func offerForSale (price) = { | |
40 | 43 | let firstPayment = value(i.payments[0]) | |
41 | 44 | let assetId = match firstPayment.assetId { | |
42 | 45 | case id: ByteVector => | |
43 | 46 | id | |
44 | 47 | case w: Unit => | |
45 | 48 | throw("Asset is not NFT") | |
46 | 49 | case _ => | |
47 | 50 | throw("Match error") | |
48 | 51 | } | |
49 | 52 | let assetIdStr = toBase58String(assetId) | |
50 | 53 | let asset = match assetInfo(assetId) { | |
51 | 54 | case a: Asset => | |
52 | 55 | a | |
53 | 56 | case _ => | |
54 | 57 | throw("Error getting information about asset") | |
55 | 58 | } | |
56 | 59 | if (if (if ((asset.quantity != 1)) | |
57 | 60 | then (asset.decimals != 0) | |
58 | 61 | else false) | |
59 | 62 | then asset.reissuable | |
60 | 63 | else false) | |
61 | 64 | then throw("Asset is not NFT") | |
62 | - | else [IntegerEntry(priceKey(assetIdStr), price), StringEntry(ownerKey(assetIdStr), toBase58String(i.caller.bytes)), StringEntry(issuerKey(assetIdStr), toBase58String(asset.issuer.bytes)), StringEntry(descriptionKey(assetIdStr), asset.description)] | |
65 | + | else [IntegerEntry(priceKey(assetIdStr), price), StringEntry(ownerKey(assetIdStr), toBase58String(i.caller.bytes)), StringEntry(issuerKey(assetIdStr), toBase58String(asset.issuer.bytes)), StringEntry(nameKey(assetIdStr), asset.name), StringEntry(descriptionKey(assetIdStr), asset.description)] | |
63 | 66 | } | |
64 | 67 | ||
65 | 68 | ||
66 | 69 | ||
67 | 70 | @Callable(i) | |
68 | 71 | func buy (assetStr) = { | |
69 | 72 | let price = tryGetInteger(priceKey(assetStr)) | |
70 | 73 | let ownerStr = tryGetString(ownerKey(assetStr)) | |
71 | 74 | let owner = match addressFromString(ownerStr) { | |
72 | 75 | case a: Address => | |
73 | 76 | a | |
74 | 77 | case _ => | |
75 | 78 | throw("Address parsing error") | |
76 | 79 | } | |
77 | 80 | let firstPayment = value(i.payments[0]) | |
78 | 81 | let firstPaymentBool = match firstPayment.assetId { | |
79 | 82 | case t: ByteVector => | |
80 | 83 | true | |
81 | 84 | case w: Unit => | |
82 | 85 | false | |
83 | 86 | case _ => | |
84 | 87 | throw("Match error") | |
85 | 88 | } | |
86 | 89 | if ((price == 0)) | |
87 | 90 | then throw("This NFT is not for sale") | |
88 | 91 | else if (firstPaymentBool) | |
89 | 92 | then throw("Payment must be in Waves tokens only") | |
90 | 93 | else if ((price > firstPayment.amount)) | |
91 | 94 | then throw("Insufficient funds") | |
92 | 95 | else { | |
93 | 96 | let fee = ((price / 100) * 5) | |
94 | - | [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), ScriptTransfer(owner, (price - fee), unit), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
97 | + | [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), ScriptTransfer(owner, (price - fee), unit), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(nameKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
95 | 98 | } | |
96 | 99 | } | |
97 | 100 | ||
98 | 101 | ||
99 | 102 | ||
100 | 103 | @Callable(i) | |
101 | 104 | func cancelSelling (assetStr) = { | |
102 | 105 | let ownerStr = tryGetString(ownerKey(assetStr)) | |
103 | 106 | let owner = match addressFromString(ownerStr) { | |
104 | 107 | case a: Address => | |
105 | 108 | a | |
106 | 109 | case _ => | |
107 | 110 | throw("Address parsing error") | |
108 | 111 | } | |
109 | 112 | if ((ownerStr != toBase58String(i.caller.bytes))) | |
110 | 113 | then throw("The calling address is not the owner of the NFT token") | |
111 | - | else [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
114 | + | else [ScriptTransfer(i.caller, 1, fromBase58String(assetStr)), DeleteEntry(priceKey(assetStr)), DeleteEntry(ownerKey(assetStr)), DeleteEntry(issuerKey(assetStr)), DeleteEntry(nameKey(assetStr)), DeleteEntry(descriptionKey(assetStr))] | |
112 | 115 | } | |
113 | 116 | ||
114 | 117 | ||
115 | 118 | @Verifier(tx) | |
116 | 119 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
117 | 120 |
github/deemru/w8io/169f3d6 34.29 ms ◑