tx · B5c544PjbspR9bwo7H1vhwSNVF1aCZAu465UUZthV4XU 3MtoBpCc3s2T4CxasJ5MXrZZsU339D28mvD: -0.01000000 Waves 2021.05.25 16:52 [1541271] smart account 3MtoBpCc3s2T4CxasJ5MXrZZsU339D28mvD > SELF 0.00000000 Waves
{ "type": 13, "id": "B5c544PjbspR9bwo7H1vhwSNVF1aCZAu465UUZthV4XU", "fee": 1000000, "feeAssetId": null, "timestamp": 1621950778295, "version": 2, "chainId": 84, "sender": "3MtoBpCc3s2T4CxasJ5MXrZZsU339D28mvD", "senderPublicKey": "8SRjg8K8B7rhV2pih6qRgku886VQE4phwNCDjWZu1fUe", "proofs": [ "kHPsTYuUTqA8A2S7m38xSKhfyiVtng42DzCQMcd6gbCfmG8WyedhKzHH5rcRdwG4MJpcFroHvcSnZmRqVjVtEn9" ], "script": "base64:AAIEAAAAAAAAABcIAhIDCgEIEgMKAQESAwoBARIECgIIAQAAAAsBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPZ2V0S2V5VXNlckVtYWlsAAAAAQAAAAR1c2VyCQABLAAAAAIJAAEsAAAAAgIAAAAFdXNlcl8FAAAABHVzZXICAAAABl9lbWFpbAEAAAARZ2V0VmFsdWVVc2VyRW1haWwAAAABAAAAB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QJAAJZAAAAAQkBAAAAE2dldFZhbHVlREFwcEFzc2V0SWQAAAAABQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleZqur5g=", "height": 1541271, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 694TW1NM2jaP8bZyiDyPmYTWfRk6UsAiPwBmoUDTmog9 Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 4 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | func getNumberByKey (key) = { | |
5 | + | let number = match getInteger(this, key) { | |
6 | + | case a: Int => | |
7 | + | a | |
8 | + | case _ => | |
9 | + | 0 | |
10 | + | } | |
11 | + | number | |
12 | + | } | |
13 | + | ||
14 | + | ||
15 | + | let NONE = "none" | |
16 | + | ||
17 | + | func getStringByKey (key) = { | |
18 | + | let string = match getString(this, key) { | |
19 | + | case a: String => | |
20 | + | a | |
21 | + | case _ => | |
22 | + | NONE | |
23 | + | } | |
24 | + | string | |
25 | + | } | |
26 | + | ||
27 | + | ||
28 | + | func getKeyUserEmail (user) = (("user_" + user) + "_email") | |
29 | + | ||
30 | + | ||
31 | + | func getValueUserEmail (user) = getStringByKey(getKeyUserEmail(user)) | |
32 | + | ||
33 | + | ||
34 | + | func getKeyUserBalance (user) = (("user_" + user) + "_balance") | |
35 | + | ||
36 | + | ||
37 | + | func getValueUserBalance (user) = getNumberByKey(getKeyUserBalance(user)) | |
38 | + | ||
39 | + | ||
40 | + | func getKeyDAppAssetId () = "dApp_assetId" | |
41 | + | ||
42 | + | ||
43 | + | func getValueDAppAssetId () = getStringByKey(getKeyDAppAssetId()) | |
44 | + | ||
45 | + | ||
46 | + | func getKeyDAppBalance () = "dApp_balance" | |
47 | + | ||
48 | + | ||
49 | + | func getValueDAppBalance () = getNumberByKey(getKeyDAppBalance()) | |
50 | + | ||
51 | + | ||
52 | + | @Callable(i) | |
53 | + | func signUp (email) = { | |
54 | + | let currentUserAddress = toBase58String(i.caller.bytes) | |
55 | + | let currentUserEmail = getValueUserEmail(currentUserAddress) | |
56 | + | if ((currentUserEmail != NONE)) | |
57 | + | then throw("user is already registered") | |
58 | + | else [StringEntry(getKeyUserEmail(currentUserAddress), email), IntegerEntry(getKeyUserBalance(currentUserAddress), 0)] | |
59 | + | } | |
60 | + | ||
61 | + | ||
62 | + | ||
63 | + | @Callable(i) | |
64 | + | func issueToken (quantity) = { | |
65 | + | let dAppAssetId = getValueDAppAssetId() | |
66 | + | if ((dAppAssetId != NONE)) | |
67 | + | then throw("token has already been issued") | |
68 | + | else { | |
69 | + | let asset = Issue("NYAN-25", "NYAN-25 token", quantity, 0, true) | |
70 | + | let assetId = calculateAssetId(asset) | |
71 | + | [asset, StringEntry(getKeyDAppAssetId(), toBase58String(assetId)), IntegerEntry(getKeyDAppBalance(), quantity)] | |
72 | + | } | |
73 | + | } | |
74 | + | ||
75 | + | ||
76 | + | ||
77 | + | @Callable(i) | |
78 | + | func reissueToken (quantity) = { | |
79 | + | let dAppAssetId = getValueDAppAssetId() | |
80 | + | if ((dAppAssetId == NONE)) | |
81 | + | then throw("token has not been issued") | |
82 | + | else { | |
83 | + | let currentDAppBalance = getValueDAppBalance() | |
84 | + | let newBalance = (currentDAppBalance + quantity) | |
85 | + | [Reissue(fromBase58String(dAppAssetId), quantity, true), IntegerEntry(getKeyDAppBalance(), newBalance)] | |
86 | + | } | |
87 | + | } | |
88 | + | ||
89 | + | ||
90 | + | ||
91 | + | @Callable(i) | |
92 | + | func transferToken (recipient,amount) = { | |
93 | + | let currentDAppBalance = getValueDAppBalance() | |
94 | + | let newDAppBalance = (currentDAppBalance - amount) | |
95 | + | if ((0 > newDAppBalance)) | |
96 | + | then throw("not enoung balance") | |
97 | + | else { | |
98 | + | let currentUserAddress = toBase58String(i.caller.bytes) | |
99 | + | let currentUserBalance = getValueUserBalance(currentUserAddress) | |
100 | + | let newUserBalance = (currentUserBalance + amount) | |
101 | + | [IntegerEntry(getKeyDAppBalance(), newDAppBalance), IntegerEntry(getKeyUserBalance(recipient), newUserBalance), ScriptTransfer(Address(fromBase58String(recipient)), amount, fromBase58String(getValueDAppAssetId()))] | |
102 | + | } | |
103 | + | } | |
104 | + | ||
105 | + | ||
106 | + | @Verifier(tx) | |
107 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
108 | + |
github/deemru/w8io/169f3d6 19.76 ms ◑