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:AAIEAAAAAAAAABcIAhIDCgEIEgMKAQESAwoBARIECgIIAQAAAAsBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPZ2V0S2V5VXNlckVtYWlsAAAAAQAAAAR1c2VyCQABLAAAAAIJAAEsAAAAAgIAAAAFdXNlcl8FAAAABHVzZXICAAAABl9lbWFpbAEAAAARZ2V0VmFsdWVVc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pZW50BQAAAAZhbW91bnQJAAJZAAAAAQkBAAAAE2dldFZhbHVlREFwcEFzc2V0SWQAAAAABQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleZqur5g=", "height": 1541239, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G65XF1r2QV6hbrSmMNaGThHX95ar6fBuwSbSEjiM17DW Next: none Diff:
OldNewDifferences
3131 func getValueUserEmail (user) = getStringByKey(getKeyUserEmail(user))
3232
3333
34-func getKeyUserBalance (user) = (("user_" + user) + "balance")
34+func getKeyUserBalance (user) = (("user_" + user) + "_balance")
3535
3636
3737 func getValueUserBalance (user) = getNumberByKey(getKeyUserBalance(user))
4343 func getValueDAppAssetId () = getStringByKey(getKeyDAppAssetId())
4444
4545
46-func getKeyDAppBalance () = "dApp_assetId"
46+func getKeyDAppBalance () = "dApp_balance"
4747
4848
49-func getValueDAppAmount () = getStringByKey(getKeyDAppBalance())
49+func getValueDAppBalance () = getNumberByKey(getKeyDAppBalance())
5050
5151
5252 @Callable(i)
7979 let dAppAssetId = getValueDAppAssetId()
8080 if ((dAppAssetId == NONE))
8181 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+ }
8387 }
8488
8589
8690
8791 @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+ }
89104
90105
91106 @Verifier(tx)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 4 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func getNumberByKey (key) = {
55 let number = match getInteger(this, key) {
66 case a: Int =>
77 a
88 case _ =>
99 0
1010 }
1111 number
1212 }
1313
1414
1515 let NONE = "none"
1616
1717 func getStringByKey (key) = {
1818 let string = match getString(this, key) {
1919 case a: String =>
2020 a
2121 case _ =>
2222 NONE
2323 }
2424 string
2525 }
2626
2727
2828 func getKeyUserEmail (user) = (("user_" + user) + "_email")
2929
3030
3131 func getValueUserEmail (user) = getStringByKey(getKeyUserEmail(user))
3232
3333
34-func getKeyUserBalance (user) = (("user_" + user) + "balance")
34+func getKeyUserBalance (user) = (("user_" + user) + "_balance")
3535
3636
3737 func getValueUserBalance (user) = getNumberByKey(getKeyUserBalance(user))
3838
3939
4040 func getKeyDAppAssetId () = "dApp_assetId"
4141
4242
4343 func getValueDAppAssetId () = getStringByKey(getKeyDAppAssetId())
4444
4545
46-func getKeyDAppBalance () = "dApp_assetId"
46+func getKeyDAppBalance () = "dApp_balance"
4747
4848
49-func getValueDAppAmount () = getStringByKey(getKeyDAppBalance())
49+func getValueDAppBalance () = getNumberByKey(getKeyDAppBalance())
5050
5151
5252 @Callable(i)
5353 func signUp (email) = {
5454 let currentUserAddress = toBase58String(i.caller.bytes)
5555 let currentUserEmail = getValueUserEmail(currentUserAddress)
5656 if ((currentUserEmail != NONE))
5757 then throw("user is already registered")
5858 else [StringEntry(getKeyUserEmail(currentUserAddress), email), IntegerEntry(getKeyUserBalance(currentUserAddress), 0)]
5959 }
6060
6161
6262
6363 @Callable(i)
6464 func issueToken (quantity) = {
6565 let dAppAssetId = getValueDAppAssetId()
6666 if ((dAppAssetId != NONE))
6767 then throw("token has already been issued")
6868 else {
6969 let asset = Issue("NYAN-25", "NYAN-25 token", quantity, 0, true)
7070 let assetId = calculateAssetId(asset)
7171 [asset, StringEntry(getKeyDAppAssetId(), toBase58String(assetId)), IntegerEntry(getKeyDAppBalance(), quantity)]
7272 }
7373 }
7474
7575
7676
7777 @Callable(i)
7878 func reissueToken (quantity) = {
7979 let dAppAssetId = getValueDAppAssetId()
8080 if ((dAppAssetId == NONE))
8181 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+ }
8387 }
8488
8589
8690
8791 @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+ }
89104
90105
91106 @Verifier(tx)
92107 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
93108

github/deemru/w8io/169f3d6 
46.14 ms