tx · 7p2nd2GTxzJ3wckcWQsqw82V1nbN9kUf5AYgj6MZg8ak 3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb: -0.01400000 Waves 2019.06.28 20:35 [562288] smart account 3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb > SELF 0.00000000 Waves
{ "type": 13, "id": "7p2nd2GTxzJ3wckcWQsqw82V1nbN9kUf5AYgj6MZg8ak", "fee": 1400000, "feeAssetId": null, "timestamp": 1561743405319, "version": 1, "sender": "3MqxFhe869ri22Y1418TcrXUX2X9YMzG2Yb", "senderPublicKey": "FRkBvFhV1T95mPTxp7sk2Ms2BuHViwyG7yPzxpxye1Kw", "proofs": [ "5RFzmntzH4nzUKzdEJFQBh9WHnmnRVhcpKA9C8yPRacXKTowpibvndWqg3J8Gu7SMKMBo273Ud7F17PckPQu4raP" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAApzZXJ2aWNlRmVlAAAAAAAAmJaAAAAAAAVlbXB0eQIAAAAETlVMTAAAAAASYWxsTWVzc2FnZUJvYXJkS2V5AgAAAAthbGxfbWVzc2FnZQAAAAAQYWN0aXZlTWVzc2FnZUtleQIAAAAOYWN0aXZlX21lc3NhZ2UAAAAADmVhcm5lZFdhdmVzS2V5AgAAAAtlYXJuZWRXYXZlcwAAAAANc2VydmljZUZlZUtleQIAAAAKc2VydmljZUZlZQAAAAAJZEFwcE93bmVyAgAAACMzTXZpS2U4dnlibmtZdUo4M2U4UVZTV1ExVkh5ZmdwaUYzVwEAAAAJdW5pcXVlS2V5AAAAAgAAAAVvd25lcgAAAAR0ZXh0BAAAAAR1S2V5CQACWAAAAAEJAAH3AAAAAQkAAZsAAAABCQABLAAAAAIFAAAABW93bmVyBQAAAAR0ZXh0BQAAAAR1S2V5AQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0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BkaWRuJ3QgZm91bmQDCQEAAAACIT0AAAACBQAAAAVvd25lcgUAAAANc2VuZGVyQWRkcmVzcwkAAAIAAAABCQABLAAAAAICAAAAG1lvdSBkb24ndCBvd25lciBvZiBtZXNzYWdlIAUAAAAEdUtleQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAQYWN0aXZlTWVzc2FnZUtleQkAAGUAAAACBQAAAAphY3RNZXNzYWdlAAAAAAAAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAICAAAACG1lc3NhZ2VfBQAAAAR1S2V5AgAAAAkjUkVNT1ZFRCMFAAAAA25pbAAAAAFpAQAAAA1zZXRTZXJ2aWNlRmVlAAAAAQAAAAZuZXdGZWUEAAAADXNlbmRlckFkZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwMJAQAAAAIhPQAAAAIFAAAADXNlbmRlckFkZHJlc3MFAAAACWRBcHBPd25lcgkAAAIAAAABAgAAABpZb3UgYXJlbid0IG93bmVyIHRoaXMgZEFwcAkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAANc2VydmljZUZlZUtleQUAAAAGbmV3RmVlBQAAAANuaWwAAAAAA7Amyw==", "chainId": 84, "height": 562288, "spentComplexity": 0 } View: original | compacted Prev: EKh4Paqbr7R9syVTqKHRh3za72M7eBG7rTDrQwheuFbv Next: Bo8FsrnwbVoY8YX22459tGpgvw8Dwj3tXAw4KU2qieKh Diff:
Old | New | Differences | |
---|---|---|---|
10 | 10 | let activeMessageKey = "active_message" | |
11 | 11 | ||
12 | 12 | let earnedWavesKey = "earnedWaves" | |
13 | + | ||
14 | + | let serviceFeeKey = "serviceFee" | |
15 | + | ||
16 | + | let dAppOwner = "3MviKe8vybnkYuJ83e8QVSWQ1VHyfgpiF3W" | |
13 | 17 | ||
14 | 18 | func uniqueKey (owner,text) = { | |
15 | 19 | let uKey = toBase58String(sha256(toBytes((owner + text)))) | |
39 | 43 | } | |
40 | 44 | ||
41 | 45 | ||
46 | + | func getSeviceFee () = { | |
47 | + | let fee = match getInteger(this, serviceFeeKey) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | serviceFee | |
52 | + | } | |
53 | + | fee | |
54 | + | } | |
55 | + | ||
56 | + | ||
42 | 57 | @Callable(i) | |
43 | 58 | func setMessage (text) = { | |
44 | 59 | let pmt = extract(i.payment) | |
60 | + | let lFee = getSeviceFee() | |
45 | 61 | if (isDefined(pmt.assetId)) | |
46 | 62 | then throw("WAVES token only at the moment") | |
47 | - | else if ((pmt.amount != | |
48 | - | then throw(" | |
63 | + | else if ((pmt.amount != lFee)) | |
64 | + | then throw("Wrong service fee amount") | |
49 | 65 | else { | |
50 | 66 | let ownerAddress = toBase58String(i.caller.bytes) | |
51 | 67 | let uKey = uniqueKey(ownerAddress, text) | |
72 | 88 | } | |
73 | 89 | ||
74 | 90 | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func setServiceFee (newFee) = { | |
94 | + | let senderAddress = toBase58String(i.caller.bytes) | |
95 | + | if ((senderAddress != dAppOwner)) | |
96 | + | then throw("You aren't owner this dApp") | |
97 | + | else WriteSet([DataEntry(serviceFeeKey, newFee)]) | |
98 | + | } | |
99 | + | ||
100 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let serviceFee = 10000000 | |
5 | 5 | ||
6 | 6 | let empty = "NULL" | |
7 | 7 | ||
8 | 8 | let allMessageBoardKey = "all_message" | |
9 | 9 | ||
10 | 10 | let activeMessageKey = "active_message" | |
11 | 11 | ||
12 | 12 | let earnedWavesKey = "earnedWaves" | |
13 | + | ||
14 | + | let serviceFeeKey = "serviceFee" | |
15 | + | ||
16 | + | let dAppOwner = "3MviKe8vybnkYuJ83e8QVSWQ1VHyfgpiF3W" | |
13 | 17 | ||
14 | 18 | func uniqueKey (owner,text) = { | |
15 | 19 | let uKey = toBase58String(sha256(toBytes((owner + text)))) | |
16 | 20 | uKey | |
17 | 21 | } | |
18 | 22 | ||
19 | 23 | ||
20 | 24 | func getNumberByKey (key) = { | |
21 | 25 | let num = match getInteger(this, key) { | |
22 | 26 | case a: Int => | |
23 | 27 | a | |
24 | 28 | case _ => | |
25 | 29 | 0 | |
26 | 30 | } | |
27 | 31 | num | |
28 | 32 | } | |
29 | 33 | ||
30 | 34 | ||
31 | 35 | func getStrByKey (key) = { | |
32 | 36 | let str = match getString(this, key) { | |
33 | 37 | case a: String => | |
34 | 38 | a | |
35 | 39 | case _ => | |
36 | 40 | empty | |
37 | 41 | } | |
38 | 42 | str | |
39 | 43 | } | |
40 | 44 | ||
41 | 45 | ||
46 | + | func getSeviceFee () = { | |
47 | + | let fee = match getInteger(this, serviceFeeKey) { | |
48 | + | case a: Int => | |
49 | + | a | |
50 | + | case _ => | |
51 | + | serviceFee | |
52 | + | } | |
53 | + | fee | |
54 | + | } | |
55 | + | ||
56 | + | ||
42 | 57 | @Callable(i) | |
43 | 58 | func setMessage (text) = { | |
44 | 59 | let pmt = extract(i.payment) | |
60 | + | let lFee = getSeviceFee() | |
45 | 61 | if (isDefined(pmt.assetId)) | |
46 | 62 | then throw("WAVES token only at the moment") | |
47 | - | else if ((pmt.amount != | |
48 | - | then throw(" | |
63 | + | else if ((pmt.amount != lFee)) | |
64 | + | then throw("Wrong service fee amount") | |
49 | 65 | else { | |
50 | 66 | let ownerAddress = toBase58String(i.caller.bytes) | |
51 | 67 | let uKey = uniqueKey(ownerAddress, text) | |
52 | 68 | let allMessage = getNumberByKey(allMessageBoardKey) | |
53 | 69 | let actMessage = getNumberByKey(activeMessageKey) | |
54 | 70 | let earnedWaves = getNumberByKey(earnedWavesKey) | |
55 | 71 | WriteSet([DataEntry(("owner_" + uKey), ownerAddress), DataEntry(("message_" + uKey), text), DataEntry(allMessageBoardKey, (allMessage + 1)), DataEntry(activeMessageKey, (actMessage + 1)), DataEntry(earnedWavesKey, (earnedWaves + serviceFee))]) | |
56 | 72 | } | |
57 | 73 | } | |
58 | 74 | ||
59 | 75 | ||
60 | 76 | ||
61 | 77 | @Callable(i) | |
62 | 78 | func removeMessage (uKey) = { | |
63 | 79 | let pmt = extract(i.payment) | |
64 | 80 | let owner = getStrByKey(("owner_" + uKey)) | |
65 | 81 | let actMessage = getNumberByKey(activeMessageKey) | |
66 | 82 | let senderAddress = toBase58String(i.caller.bytes) | |
67 | 83 | if ((owner == empty)) | |
68 | 84 | then throw("Message didn't found") | |
69 | 85 | else if ((owner != senderAddress)) | |
70 | 86 | then throw(("You don't owner of message " + uKey)) | |
71 | 87 | else WriteSet([DataEntry(activeMessageKey, (actMessage - 1)), DataEntry(("message_" + uKey), "#REMOVED#")]) | |
72 | 88 | } | |
73 | 89 | ||
74 | 90 | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func setServiceFee (newFee) = { | |
94 | + | let senderAddress = toBase58String(i.caller.bytes) | |
95 | + | if ((senderAddress != dAppOwner)) | |
96 | + | then throw("You aren't owner this dApp") | |
97 | + | else WriteSet([DataEntry(serviceFeeKey, newFee)]) | |
98 | + | } | |
99 | + | ||
100 | + |
github/deemru/w8io/169f3d6 33.66 ms ◑