tx · 9WJkscDuER8wciaSGwAzS1qW1Qpz9zDbKZPQFwvVjW4e 3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr: -0.01000000 Waves 2019.09.24 01:09 [689565] smart account 3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr > SELF 0.00000000 Waves
{ "type": 13, "id": "9WJkscDuER8wciaSGwAzS1qW1Qpz9zDbKZPQFwvVjW4e", "fee": 1000000, "feeAssetId": null, "timestamp": 1569276521187, "version": 1, "sender": "3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr", "senderPublicKey": "456duGZMs5yvsHurjiNQi2JtHjKtMj4WyRRRcVHzKWrb", "proofs": [ "5bVsz5UMrTKwVY8zbTYMxordh5cmUcYMrZUFaDHmgowfpTFPftsTLVn4P48h2xVAf141WBdmmuJeVkEwBMZc972C" ], "script": "base64:AAIDAAAAAAAAAAAAAAALAAAAAANXVlMAAAAAAAX14QAAAAAAA0ZFRQkAAGgAAAACAAAAAAAAAAABBQAAAANXVlMAAAAABFlFQVIAAAAAB1jw38AAAAAABVRPS0VOAQAAACDFitCU5YxBUBAVXz7rc4xG3gL7SP1euzpDtgeRF0Ba5gAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABbgUAAAAHJG1hdGNoMAUAAAABbgAAAAAAAAAAAAEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABcwUAAAAHJG1hdGNoMAUAAAABcwUAAAAETk9ORQEAAAAUZ2V0S2V5U3Vic2NyaXB0aW9uVHMAAAABAAAABGFkZHIJAAEsAAAAAgkAASwAAAACAgAAA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AAAC9wYXltZW50IGFtb3VudCBjYW5ub3QgYmUgbG93ZXIgdGhlbiByZW5ld2FsIGZlZQkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABRnZXRLZXlTdWJzY3JpcHRpb25UcwAAAAEFAAAAB2FjY291bnQJAABkAAAAAgUAAAAOc3Vic2NyaXB0aW9uVHMFAAAABFlFQVIFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIAAAAAAAAAAAEFAAAABVRPS0VOBQAAAANuaWwAAAAAIEEgaQ==", "chainId": 84, "height": 689565, "spentComplexity": 0 } View: original | compacted Prev: none Next: 2snY9xfwD3bJME647kqDUQgquex6pbmBRegfCE8mSCcj Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let WVS = 100000000 | |
5 | + | ||
6 | + | let FEE = (1 * WVS) | |
7 | + | ||
8 | + | let YEAR = 31556952000 | |
9 | + | ||
10 | + | let TOKEN = base58'EJ85vmBXWEtV4yHLPRTxex4q4s9mC8jKUhheyjZxwnPw' | |
11 | + | ||
12 | + | let NONE = "none" | |
13 | + | ||
14 | + | func getNumberByKey (key) = match getInteger(this, key) { | |
15 | + | case n: Int => | |
16 | + | n | |
17 | + | case _ => | |
18 | + | 0 | |
19 | + | } | |
20 | + | ||
21 | + | ||
22 | + | func getStrByKey (key) = match getString(this, key) { | |
23 | + | case s: String => | |
24 | + | s | |
25 | + | case _ => | |
26 | + | NONE | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func getKeySubscriptionTs (addr) = (("member_" + addr) + "subscription_ts") | |
31 | + | ||
32 | + | ||
33 | + | func getKeyFee (addr) = (("member_" + addr) + "_fee") | |
34 | + | ||
35 | + | ||
36 | + | func getKeyGroup (addr) = (("member_" + addr) + "_group") | |
37 | + | ||
38 | + | ||
39 | + | func getKeyBalance (addr) = (("member_" + addr) + "_balance") | |
40 | + | ||
41 | + | ||
42 | + | @Callable(i) | |
43 | + | func subscribe () = { | |
44 | + | let payment = extract(i.payment) | |
45 | + | if (isDefined(payment.assetId)) | |
46 | + | then throw("can use only WAVES token at the moment") | |
47 | + | else { | |
48 | + | let account = toBase58String(i.caller.bytes) | |
49 | + | let subscriptionTs = getNumberByKey(getKeySubscriptionTs(account)) | |
50 | + | if ((FEE > payment.amount)) | |
51 | + | then throw("payment amount cannot be lowher then subscription fee") | |
52 | + | else if ((subscriptionTs != 0)) | |
53 | + | then throw("Already subscribed") | |
54 | + | else ScriptResult(WriteSet([DataEntry(getKeySubscriptionTs(account), lastBlock.timestamp), DataEntry(getKeyFee(account), FEE), DataEntry(getKeyBalance(account), 0)]), TransferSet([ScriptTransfer(i.caller, 1, TOKEN)])) | |
55 | + | } | |
56 | + | } | |
57 | + | ||
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func renew () = { | |
62 | + | let payment = extract(i.payment) | |
63 | + | if (isDefined(payment.assetId)) | |
64 | + | then throw("can use only WAVES token at the moment") | |
65 | + | else { | |
66 | + | let account = toBase58String(i.caller.bytes) | |
67 | + | let subscriptionTs = getNumberByKey(getKeySubscriptionTs(account)) | |
68 | + | let subscriptionFee = getNumberByKey(getKeyFee(account)) | |
69 | + | if ((subscriptionTs == 0)) | |
70 | + | then throw("subscribe first") | |
71 | + | else if ((subscriptionFee > payment.amount)) | |
72 | + | then throw("payment amount cannot be lower then renewal fee") | |
73 | + | else ScriptResult(WriteSet([DataEntry(getKeySubscriptionTs(account), (subscriptionTs + YEAR))]), TransferSet([ScriptTransfer(i.caller, 1, TOKEN)])) | |
74 | + | } | |
75 | + | } | |
76 | + | ||
77 | + |
github/deemru/w8io/169f3d6 17.70 ms ◑