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