tx · CJ9TwmPX3b18PrpqzPMaLJMx9pHmGaXnZERsXS3oodpM 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn: -0.01000000 Waves 2022.11.01 13:26 [2297923] smart account 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn > SELF 0.00000000 Waves
{ "type": 13, "id": "CJ9TwmPX3b18PrpqzPMaLJMx9pHmGaXnZERsXS3oodpM", "fee": 1000000, "feeAssetId": null, "timestamp": 1667298342377, "version": 2, "chainId": 84, "sender": "3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn", "senderPublicKey": "Cq4RbcVcQJpCWyHiACDqUf2PbU8PaX949Dun9wRSeDzE", "proofs": [ "2UAabALb9fdwZ6TYT8qnpeK4ZYNEWGskLNG5WbBdHK6HcBtJmXk31y14j3jdn9yM1sSJKqnNZuUb882Br2Qegz5K" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAADQAAAAAMb3duZXJBZGRyZXNzAQAAAAAAAAAACm5mdEFkZHJlc3MBAAAAAAAAAAAQYXJ0ZWZhY3RzQWRkcmVzcwEAAAAAAAAAAA1mZWVBZ2dyZWdhdG9yAQAAAAAAAAAACm5mdEFzc2V0SWQBAAAAAAAAAAAOa0dsb2JhbENvdW50ZXICAAAADkdMT0JBTF9DT1VOVEVSAAAAAApmZWVQZXJjZW50AAAAAAAAAAAFAAAAABNhcnRlZmFjdHNGZWVQZXJjZW50AAAAAAAAAAAUAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAUAAAADdmFsAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA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AAhmaW5hbEZlZQAAAAAAAAAAZAUAAAAOcGF5bWVudEFzc2V0SWQFAAAAA25pbAAAAAArNAcC", "height": 2297923, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6FtvMC2dQoa5NeVc1WMVD7tvD2Fo48QvkVXXJjtBDjFw Next: AG2dJjbJq5iek81bmJd5XZs5SrZNkfCdUo5ftb2FfJFk Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerAddress = base58'' | |
5 | 5 | ||
6 | 6 | let nftAddress = base58'' | |
7 | 7 | ||
8 | 8 | let artefactsAddress = base58'' | |
9 | 9 | ||
10 | 10 | let feeAggregator = base58'' | |
11 | 11 | ||
12 | 12 | let nftAssetId = base58'' | |
13 | 13 | ||
14 | 14 | let kGlobalCounter = "GLOBAL_COUNTER" | |
15 | 15 | ||
16 | 16 | let feePercent = 5 | |
17 | 17 | ||
18 | 18 | let artefactsFeePercent = 20 | |
19 | 19 | ||
20 | 20 | func tryGetInteger (key) = { | |
21 | 21 | let val = match getInteger(this, key) { | |
22 | 22 | case b: Int => | |
23 | 23 | b | |
24 | 24 | case _ => | |
25 | 25 | 0 | |
26 | 26 | } | |
27 | 27 | val | |
28 | 28 | } | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func tryGetString (key) = { | |
32 | 32 | let val = match getString(this, key) { | |
33 | 33 | case b: String => | |
34 | 34 | b | |
35 | 35 | case _ => | |
36 | 36 | "" | |
37 | 37 | } | |
38 | 38 | val | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func tryGetBoolean (key) = match getBoolean(this, key) { | |
43 | 43 | case b: Boolean => | |
44 | 44 | b | |
45 | 45 | case _ => | |
46 | 46 | false | |
47 | 47 | } | |
48 | 48 | ||
49 | 49 | ||
50 | 50 | func getGlobalCounter () = tryGetInteger(kGlobalCounter) | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(artefactsAddress))) | |
54 | 54 | then "ART" | |
55 | 55 | else { | |
56 | 56 | let asset1 = match getString(Address(ownerAddress), toBase58String(assetId)) { | |
57 | 57 | case b: String => | |
58 | 58 | b | |
59 | 59 | case _ => | |
60 | 60 | "" | |
61 | 61 | } | |
62 | 62 | if ((asset1 != "")) | |
63 | 63 | then asset1 | |
64 | 64 | else { | |
65 | 65 | let asset2 = match getString(Address(nftAddress), toBase58String(assetId)) { | |
66 | 66 | case c: String => | |
67 | 67 | c | |
68 | 68 | case _ => | |
69 | 69 | "" | |
70 | 70 | } | |
71 | 71 | if ((asset2 != "")) | |
72 | 72 | then asset2 | |
73 | 73 | else "" | |
74 | 74 | } | |
75 | 75 | } | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | @Callable(i) | |
79 | 79 | func nftBuy (nftId) = { | |
80 | 80 | let isnftart = tryGetBoolean((("nft_" + nftId) + "_nftart")) | |
81 | 81 | let paymentAssetId = if ((isnftart == true)) | |
82 | 82 | then nftAssetId | |
83 | 83 | else unit | |
84 | 84 | let paymentAssetName = if ((isnftart == true)) | |
85 | 85 | then "nftart" | |
86 | 86 | else "WAVES" | |
87 | 87 | let pmt = value(i.payments[0]) | |
88 | 88 | let amount = pmt.amount | |
89 | 89 | let assetId = tryGetString((("nft_" + nftId) + "_assetId")) | |
90 | 90 | let bidId = toBase58String(i.transactionId) | |
91 | 91 | let nftStatus = tryGetString((("nft_" + nftId) + "_status")) | |
92 | 92 | let finalFee = if ((tryGetBoolean((("nft_" + nftId) + "_isArtefact")) == true)) | |
93 | 93 | then artefactsFeePercent | |
94 | 94 | else feePercent | |
95 | 95 | if ((pmt.assetId != paymentAssetId)) | |
96 | 96 | then throw((("nft does only support " + paymentAssetName) + " payments.")) | |
97 | 97 | else if ((nftStatus != "open")) | |
98 | 98 | then throw("nft is closed. You cannot place a bid.") | |
99 | 99 | else { | |
100 | 100 | let instantPrice = tryGetInteger((("nft_" + nftId) + "_instantPrice")) | |
101 | 101 | if ((instantPrice > amount)) | |
102 | 102 | then throw(("For instant purchase you need to pay at least " + toString(instantPrice))) | |
103 | 103 | else { | |
104 | 104 | let nftOwner = tryGetString((("nft_" + nftId) + "_owner")) | |
105 | 105 | let recordPrice = tryGetInteger((assetId + "_recordPrice")) | |
106 | 106 | let newRecordPrice = max([recordPrice, amount]) | |
107 | 107 | [StringEntry((("nft_" + nftId) + "_status"), "finished"), IntegerEntry((("nft_" + nftId) + "_finalPrice"), amount), IntegerEntry((assetId + "_recordPrice"), newRecordPrice), StringEntry((((("assetId_" + assetId) + "_bid_") + bidId) + "_data"), (((((("{\"nftId\": \"" + nftId) + "\", \"author\": \"") + toString(i.originCaller)) + "\", \"amount\": \"") + toString(amount)) + "\", \"status\": \"finished\"}")), DeleteEntry((((("address_" + nftOwner) + "_nft_") + nftId) + "_lockedNFT")), ScriptTransfer(i.originCaller, 1, fromBase58String(getStringValue(this, (("nft_" + nftId) + "_assetId")))), ScriptTransfer(addressFromStringValue(nftOwner), fraction(amount, (100 - finalFee), 100), paymentAssetId), ScriptTransfer(Address(feeAggregator), fraction(amount, finalFee, 100), paymentAssetId)] | |
108 | 108 | } | |
109 | 109 | } | |
110 | 110 | } | |
111 | 111 | ||
112 | 112 |
github/deemru/w8io/026f985 24.38 ms ◑