tx · JRvRTDej6F7KyG8o5X7MbSVggiGFQxfpH4Ct4FqLyNA

3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr:  -0.14000000 Waves

2019.11.09 00:25 [756525] smart account 3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr > SELF 0.00000000 Waves

{ "type": 13, "id": "JRvRTDej6F7KyG8o5X7MbSVggiGFQxfpH4Ct4FqLyNA", "fee": 14000000, "feeAssetId": null, "timestamp": 1573248167830, "version": 1, "sender": "3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr", "senderPublicKey": "456duGZMs5yvsHurjiNQi2JtHjKtMj4WyRRRcVHzKWrb", "proofs": [ "3oSyaBJccU2VVZUxj5LGpdyUBbjFaxbvPtWjpvyWgXMwSVdXMUCpci3WWraKSsHAMAjt3sdTsk4GMBghCfAsxZfQ" ], "script": "base64:AwQAAAAEZGFwcAEAAAAaAVTZDED91GsXJBgo7UdeILvwcSjDlUkeiNkEAAAABWFkbWluAQAAABoBVOmuoVJsv6TiJstBb2xa9Cn23dlUAX+uZQQAAAAHJG1hdGNoMAUAAAACdHgDAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAGVNldEFzc2V0U2NyaXB0VHJhbnNhY3Rpb24GAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdNYXNzVHJhbnNmZXJUcmFuc2FjdGlvbgYJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMJAAAAAAAAAggFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQUAAAAEZGFwcAYJAAAAAAAAAggFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQUAAAAFYWRtaW4HZ8KGNg==", "chainId": 84, "height": 756525, "spentComplexity": 0 } View: original | compacted Prev: AZhF2jY54pgJgrUdu24hiP4zztaXNJUmQ4o5wDigMGDd Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
2-{-# SCRIPT_TYPE ACCOUNT #-}
3-{-# CONTENT_TYPE DAPP #-}
4-let YEAR = 31556952000
5-
6-let MONTH = (YEAR / 12)
7-
8-let ADMIN = "3NBDgR8hU6W86Sstn3EGid8k9uxkqiJjxT6"
9-
10-let TOKEN = base58'EJ85vmBXWEtV4yHLPRTxex4q4s9mC8jKUhheyjZxwnPw'
11-
12-let wEUR = base58'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU'
13-
14-let WVS = 100000000
15-
16-let PRICExBASIC = 60
17-
18-let PRICExADVANCED = 50
19-
20-let BASIC = "basic"
21-
22-let ADVANCED = "advanced"
23-
24-let NONE = "none"
25-
26-func getNumberByKey (key) = match getInteger(this, key) {
27- case n: Int =>
28- n
2+{-# CONTENT_TYPE EXPRESSION #-}
3+let dapp = base58'3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr'
4+let admin = base58'3NBDgR8hU6W86Sstn3EGid8k9uxkqiJjxT6'
5+match tx {
6+ case t: InvokeScriptTransaction|SetAssetScriptTransaction|MassTransferTransaction|TransferTransaction =>
7+ if ((tx.senderPublicKey == dapp))
8+ then true
9+ else (tx.senderPublicKey == admin)
2910 case _ =>
30- 0
11+ false
3112 }
32-
33-
34-func getStrByKey (key) = match getString(this, key) {
35- case s: String =>
36- s
37- case _ =>
38- NONE
39-}
40-
41-
42-func getKeySubscriptionEnd (addr) = (("member_" + addr) + "_subscription_end")
43-
44-
45-func getKeyPlan (addr) = (("member_" + addr) + "_plan")
46-
47-
48-func getTransferSet (account) = TransferSet([ScriptTransfer(account, 1, TOKEN)])
49-
50-
51-func getWriteSet (account,period,plan) = WriteSet([DataEntry(getKeySubscriptionEnd(account), (lastBlock.timestamp + period)), DataEntry(getKeyPlan(account), plan)])
52-
53-
54-func getResult (address,period,plan,isRenewal) = {
55- let account = toBase58String(address.bytes)
56- if (isRenewal)
57- then getWriteSet(account, period, plan)
58- else ScriptResult(getWriteSet(account, period, plan), getTransferSet(address))
59- }
60-
61-
62-@Callable(i)
63-func subscribe (plan) = {
64- let payment = extract(i.payment)
65- if ((payment.assetId != wEUR))
66- then throw("can use only wEUR token at the moment")
67- else {
68- let account = toBase58String(i.caller.bytes)
69- let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(account))
70- let isRenewal = (subscriptionEnd != 0)
71- if ((plan == BASIC))
72- then if ((PRICExBASIC > payment.amount))
73- then throw("unsufficient payment amount for basic plan")
74- else getResult(i.caller, YEAR, plan, isRenewal)
75- else if ((plan == ADVANCED))
76- then if ((PRICExADVANCED > payment.amount))
77- then throw("unsufficient payment amount for advanced plan")
78- else getResult(i.caller, MONTH, plan, isRenewal)
79- else throw(("subscription to an unknown plan: " + plan))
80- }
81- }
82-
83-
84-
85-@Callable(i)
86-func subscribeUser (userAddress,plan) = {
87- let account = toBase58String(i.caller.bytes)
88- let dAppAccount = toBase58String(this.bytes)
89- if (if ((account != ADMIN))
90- then (account != dAppAccount)
91- else false)
92- then throw("only admins can do that")
93- else {
94- let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(userAddress))
95- let isRenewal = (subscriptionEnd != 0)
96- let period = if ((plan == BASIC))
97- then YEAR
98- else if ((plan == ADVANCED))
99- then MONTH
100- else throw(("subscription to an unknown plan: " + plan))
101- getResult(addressFromStringValue(userAddress), period, plan, isRenewal)
102- }
103- }
104-
105-

github/deemru/w8io/169f3d6 
32.91 ms