tx · 6FtvMC2dQoa5NeVc1WMVD7tvD2Fo48QvkVXXJjtBDjFw 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn: -0.01000000 Waves 2022.11.01 13:24 [2297922] smart account 3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn > SELF 0.00000000 Waves
{ "type": 13, "id": "6FtvMC2dQoa5NeVc1WMVD7tvD2Fo48QvkVXXJjtBDjFw", "fee": 1000000, "feeAssetId": null, "timestamp": 1667298308601, "version": 2, "chainId": 84, "sender": "3N2D6tJAXzcTDgUiTWmcdCHd6ctYwNENuBn", "senderPublicKey": "Cq4RbcVcQJpCWyHiACDqUf2PbU8PaX949Dun9wRSeDzE", "proofs": [ "5wbpSb3EHSRNLAoiMMeDSWD96WLUYANhJ8qV9uKWvfoookAcRQv5gA1vqM7DmXDdkWXowkvdudH9Cicj9pa5S3Mt" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEIAAAADQAAAAAMb3duZXJBZGRyZXNzAQAAAAAAAAAACm5mdEFkZHJlc3MBAAAAAAAAAAAQYXJ0ZWZhY3RzQWRkcmVzcwEAAAAAAAAAAA1mZWVBZ2dyZWdhdG9yAQAAAAAAAAAACm5mdEFzc2V0SWQBAAAAAAAAAAAOa0dsb2JhbENvdW50ZXICAAAADkdMT0JBTF9DT1VOVEVSAAAAAApmZWVQZXJjZW50AAAAAAAAAAAFAAAAABNhcnRlZmFjdHNGZWVQZXJjZW50AAAAAAAAAAAUAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAUAAAADdmFsAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXM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W50BQAAAAhmaW5hbEZlZQAAAAAAAAAAZAUAAAAOcGF5bWVudEFzc2V0SWQFAAAAA25pbAAAAAArNAcC", "height": 2297922, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DL6LMqPNMUaQfLgAbqgmVaujgn12VQMftz6QJN6ZZDst Next: CJ9TwmPX3b18PrpqzPMaLJMx9pHmGaXnZERsXS3oodpM Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let ownerAddress = base58'' | |
5 | 5 | ||
6 | - | let | |
6 | + | let nftAddress = base58'' | |
7 | 7 | ||
8 | - | let | |
8 | + | let artefactsAddress = base58'' | |
9 | 9 | ||
10 | - | let | |
10 | + | let feeAggregator = base58'' | |
11 | 11 | ||
12 | - | @Callable(i) | |
13 | - | func issueNewEgg () = if ((getBoolean(kEggIssued) != unit)) | |
14 | - | then throw(("New EGG is already issued and its asset id is: " + getStringValue(kAssetId))) | |
12 | + | let nftAssetId = base58'' | |
13 | + | ||
14 | + | let kGlobalCounter = "GLOBAL_COUNTER" | |
15 | + | ||
16 | + | let feePercent = 5 | |
17 | + | ||
18 | + | let artefactsFeePercent = 20 | |
19 | + | ||
20 | + | func tryGetInteger (key) = { | |
21 | + | let val = match getInteger(this, key) { | |
22 | + | case b: Int => | |
23 | + | b | |
24 | + | case _ => | |
25 | + | 0 | |
26 | + | } | |
27 | + | val | |
28 | + | } | |
29 | + | ||
30 | + | ||
31 | + | func tryGetString (key) = { | |
32 | + | let val = match getString(this, key) { | |
33 | + | case b: String => | |
34 | + | b | |
35 | + | case _ => | |
36 | + | "" | |
37 | + | } | |
38 | + | val | |
39 | + | } | |
40 | + | ||
41 | + | ||
42 | + | func tryGetBoolean (key) = match getBoolean(this, key) { | |
43 | + | case b: Boolean => | |
44 | + | b | |
45 | + | case _ => | |
46 | + | false | |
47 | + | } | |
48 | + | ||
49 | + | ||
50 | + | func getGlobalCounter () = tryGetInteger(kGlobalCounter) | |
51 | + | ||
52 | + | ||
53 | + | func getAssetGenotype (assetId) = if ((value(assetInfo(assetId)).issuer == Address(artefactsAddress))) | |
54 | + | then "ART" | |
15 | 55 | else { | |
16 | - | let newEgg = Issue("Duck Egg", "Utility and Reward token @ WavesDucks.com game. The duckiest token in the world.", 1, 8, true, unit, 0) | |
17 | - | let newEggId = calculateAssetId(newEgg) | |
18 | - | [newEgg, BooleanEntry(kEggIssued, true), StringEntry(kAssetId, toBase58String(newEggId))] | |
56 | + | let asset1 = match getString(Address(ownerAddress), toBase58String(assetId)) { | |
57 | + | case b: String => | |
58 | + | b | |
59 | + | case _ => | |
60 | + | "" | |
61 | + | } | |
62 | + | if ((asset1 != "")) | |
63 | + | then asset1 | |
64 | + | else { | |
65 | + | let asset2 = match getString(Address(nftAddress), toBase58String(assetId)) { | |
66 | + | case c: String => | |
67 | + | c | |
68 | + | case _ => | |
69 | + | "" | |
70 | + | } | |
71 | + | if ((asset2 != "")) | |
72 | + | then asset2 | |
73 | + | else "" | |
74 | + | } | |
19 | 75 | } | |
20 | 76 | ||
21 | 77 | ||
78 | + | @Callable(i) | |
79 | + | func nftBuy (nftId) = { | |
80 | + | let isnftart = tryGetBoolean((("nft_" + nftId) + "_nftart")) | |
81 | + | let paymentAssetId = if ((isnftart == true)) | |
82 | + | then nftAssetId | |
83 | + | else unit | |
84 | + | let paymentAssetName = if ((isnftart == true)) | |
85 | + | then "nftart" | |
86 | + | else "WAVES" | |
87 | + | let pmt = value(i.payments[0]) | |
88 | + | let amount = pmt.amount | |
89 | + | let assetId = tryGetString((("nft_" + nftId) + "_assetId")) | |
90 | + | let bidId = toBase58String(i.transactionId) | |
91 | + | let nftStatus = tryGetString((("nft_" + nftId) + "_status")) | |
92 | + | let finalFee = if ((tryGetBoolean((("nft_" + nftId) + "_isArtefact")) == true)) | |
93 | + | then artefactsFeePercent | |
94 | + | else feePercent | |
95 | + | if ((pmt.assetId != paymentAssetId)) | |
96 | + | then throw((("nft does only support " + paymentAssetName) + " payments.")) | |
97 | + | else if ((nftStatus != "open")) | |
98 | + | then throw("nft is closed. You cannot place a bid.") | |
99 | + | else { | |
100 | + | let instantPrice = tryGetInteger((("nft_" + nftId) + "_instantPrice")) | |
101 | + | if ((instantPrice > amount)) | |
102 | + | then throw(("For instant purchase you need to pay at least " + toString(instantPrice))) | |
103 | + | else { | |
104 | + | let nftOwner = tryGetString((("nft_" + nftId) + "_owner")) | |
105 | + | let recordPrice = tryGetInteger((assetId + "_recordPrice")) | |
106 | + | let newRecordPrice = max([recordPrice, amount]) | |
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 | + | } | |
109 | + | } | |
110 | + | } | |
22 | 111 | ||
23 | - | @Callable(i) | |
24 | - | func swapEgg () = if ((size(i.payments) != 1)) | |
25 | - | then throw("You can attach only EGG tokens") | |
26 | - | else if ((value(i.payments[0]).assetId != oldEggAssetId)) | |
27 | - | then throw("You can attach only EGG tokens") | |
28 | - | else { | |
29 | - | let totalSwappedVal = match getInteger(kTotalSwapped) { | |
30 | - | case int: Int => | |
31 | - | int | |
32 | - | case _ => | |
33 | - | 0 | |
34 | - | } | |
35 | - | let newEggAssetId = fromBase58String(getStringValue(kAssetId)) | |
36 | - | let toSwapAmount = value(i.payments[0]).amount | |
37 | - | let swappedAmount = (toSwapAmount * 1000000) | |
38 | - | let reissue = Reissue(newEggAssetId, swappedAmount, true) | |
39 | - | [reissue, IntegerEntry((("swap_" + toBase58String(i.transactionId)) + "_amount"), toSwapAmount), IntegerEntry(kTotalSwapped, (totalSwappedVal + toSwapAmount)), ScriptTransfer(i.caller, swappedAmount, newEggAssetId)] | |
40 | - | } | |
41 | - | ||
42 | - | ||
43 | - | @Verifier(tx) | |
44 | - | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
45 | 112 |
github/deemru/w8io/026f985 39.05 ms ◑