tx · yLShz79nytJvrVNUXj9Ffcb4ryABMBRD9GmVtZMF3jw

3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE:  -0.01400000 Waves

2021.06.21 23:59 [1580652] smart account 3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE > SELF 0.00000000 Waves

{ "type": 13, "id": "yLShz79nytJvrVNUXj9Ffcb4ryABMBRD9GmVtZMF3jw", "fee": 1400000, "feeAssetId": null, "timestamp": 1624309209332, "version": 2, "chainId": 84, "sender": "3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE", "senderPublicKey": "EsW1U1EWPD2yLGRwTq3i9ftXRvWVpLbNz9R8U9xAF4e8", "proofs": [ "5FYYqBx5uYqrXwwbLYTfpDxsn2wBTSHkHovM6WBrGjvzANa68zLgshZ5oqb68438Nzjut5pLYeDZdU9wzPP9Xdea" ], "script": "base64:AAIEAAAAAAAAACwIAhIDCgEIEgMKAQESAwoBARIECgIIARIHCgUICAEBCBIECgIIARIECgIIAQAAABABAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPYWRkcmVzc1RvU3RyaW5nAAAAAQAAAAdhZGRyZXNzCQACWAAAAAEIBQAAAAdhZGRyZXNzAAAABWJ5dGVzAQAAAA9zdHJ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vdCBlbm91Z2ggTllBTiBUb2tlbnMgdG8gZXhjaGFuZ2UgYW4gYXNzZXQDCQAAAAAAAAIFAAAADXBheW1lbnRBbW91bnQFAAAAC2Fzc2V0QW1vdW50CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAC3VzZXJBZGRyZXNzBQAAAAZhbW91bnQFAAAAEWFzc2V0VG9rZW5Bc3NldElkCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAAOcGF5bWVudEFzc2V0SWQFAAAADXBheW1lbnRBbW91bnQFAAAAA25pbAQAAAATcGF5bWVudEFtb3VudENoYW5nZQkAAGUAAAACBQAAAA1wYXltZW50QW1vdW50BQAAAAthc3NldEFtb3VudAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAt1c2VyQWRkcmVzcwUAAAAGYW1vdW50BQAAABFhc3NldFRva2VuQXNzZXRJZAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAt1c2VyQWRkcmVzcwUAAAATcGF5bWVudEFtb3VudENoYW5nZQUAAAAOcGF5bWVudEFzc2V0SWQJAARMAAAAAgkBAAAABEJ1cm4AAAACBQAAAA5wYXltZW50QXNzZXRJZAUAAAALYXNzZXRBbW91bnQFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5/JXY+A==", "height": 1580652, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6ucu4qNnuJuPPVKgLT16wo45R679uFRPCAVactTai51r Next: none Diff:
OldNewDifferences
7878 @Callable(i)
7979 func issueNyanToken (quantity) = {
8080 let nyanToken = getNyanTokenValue(this)
81- if ((nyanToken != NONE))
82- then throw("NYAN Token is already issued")
83- else {
84- let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
85- let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
81+ if (!(isAdmin(i.caller)))
82+ then throw("Function invoke not allowed, requested from non-admin address")
83+ else if ((nyanToken != NONE))
84+ then throw("NYAN Token is already issued")
85+ else {
86+ let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
87+ let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
8688 [nyanTokenIssue, StringEntry(getNyanTokenKey(this), byteVectorToString(nyanTokenAssetId))]
87- }
89+ }
8890 }
8991
9092
107109 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
108110 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
109111 let newDAppBalance = (currentDAppBalance - amount)
110- if ((userEmail == NONE))
111- then throw("You cannot transfer NYAN Tokens to an unregistered user")
112- else if ((0 > amount))
113- then throw("You cannot transfer a negative amount")
114- else if ((0 > newDAppBalance))
115- then throw("Not enough NYAN Tokens to transfer")
116- else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
112+ if (!(isAdmin(i.caller)))
113+ then throw("Function invoke not allowed, requested from non-admin address")
114+ else if ((userEmail == NONE))
115+ then throw("You cannot transfer NYAN Tokens to an unregistered user")
116+ else if ((0 > amount))
117+ then throw("You cannot transfer a negative amount")
118+ else if ((0 > newDAppBalance))
119+ then throw("Not enough NYAN Tokens to transfer")
120+ else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
117121 }
118122
119123
123127 let assetTokenIssue = Issue(name, description, quantity, 0, true)
124128 let assetTokenAssetId = calculateAssetId(assetTokenIssue)
125129 let assetToken = byteVectorToString(assetTokenAssetId)
126- if ((quantity == 0))
127- then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
128- else {
129- let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
130- let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
131- let amount = (quantity * price)
132- let newDAppBalance = (currentDAppBalance - amount)
133- if ((0 > newDAppBalance))
134- then throw("Not enough NYAN Tokens to issue an asset")
135- else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
136- }
130+ if (!(isAdmin(i.caller)))
131+ then throw("Function invoke not allowed, requested from non-admin address")
132+ else if ((quantity == 0))
133+ then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
134+ else {
135+ let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
136+ let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
137+ let amount = (quantity * price)
138+ let newDAppBalance = (currentDAppBalance - amount)
139+ if ((0 > newDAppBalance))
140+ then throw("Not enough NYAN Tokens to issue an asset")
141+ else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
142+ }
137143 }
138144
139145
145151 let price = getAssetPriceValue(assetId)
146152 let amount = (quantity * price)
147153 let newDAppBalance = (currentDAppBalance - amount)
148- if ((0 > newDAppBalance))
149- then throw("Not enough NYAN Tokens to reissue an asset")
150- else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
154+ if (!(isAdmin(i.caller)))
155+ then throw("Function invoke not allowed, requested from non-admin address")
156+ else if ((0 > newDAppBalance))
157+ then throw("Not enough NYAN Tokens to reissue an asset")
158+ else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
151159 }
152160
153161
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 addressToString (address) = toBase58String(address.bytes)
2929
3030
3131 func stringToAddress (string) = Address(fromBase58String(string))
3232
3333
3434 func byteVectorToString (byteVector) = toBase58String(byteVector)
3535
3636
3737 func stringToByteVector (string) = fromBase58String(string)
3838
3939
4040 func isAdmin (caller) = (this == caller)
4141
4242
4343 func getUserEmailKey (userEmail) = (("user_" + userEmail) + "_email")
4444
4545
4646 func getUserEmailValue (userEmail) = getStringByKey(getUserEmailKey(userEmail))
4747
4848
4949 func getNyanTokenKey (dAppAddress) = (("dApp_" + addressToString(dAppAddress)) + "_tokenId")
5050
5151
5252 func getNyanTokenValue (dAppAddress) = getStringByKey(getNyanTokenKey(dAppAddress))
5353
5454
5555 func getAssetPriceKey (assetId) = (("asset_" + assetId) + "_price")
5656
5757
5858 func getAssetPriceValue (assetId) = getNumberByKey(getAssetPriceKey(assetId))
5959
6060
6161 func getAssetDataKey (assetId) = (("asset_" + assetId) + "_data")
6262
6363
6464 func getAssetDataValue (assetId) = getStringByKey(getAssetPriceKey(assetId))
6565
6666
6767 @Callable(i)
6868 func signUp (email) = {
6969 let userAddress = addressToString(i.caller)
7070 let userEmail = getUserEmailValue(userAddress)
7171 if ((userEmail != NONE))
7272 then throw((("User " + userEmail) + " is already registered"))
7373 else [StringEntry(getUserEmailKey(userAddress), email)]
7474 }
7575
7676
7777
7878 @Callable(i)
7979 func issueNyanToken (quantity) = {
8080 let nyanToken = getNyanTokenValue(this)
81- if ((nyanToken != NONE))
82- then throw("NYAN Token is already issued")
83- else {
84- let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
85- let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
81+ if (!(isAdmin(i.caller)))
82+ then throw("Function invoke not allowed, requested from non-admin address")
83+ else if ((nyanToken != NONE))
84+ then throw("NYAN Token is already issued")
85+ else {
86+ let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
87+ let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
8688 [nyanTokenIssue, StringEntry(getNyanTokenKey(this), byteVectorToString(nyanTokenAssetId))]
87- }
89+ }
8890 }
8991
9092
9193
9294 @Callable(i)
9395 func reissueNyanToken (quantity) = {
9496 let nyanToken = getNyanTokenValue(this)
9597 if (!(isAdmin(i.caller)))
9698 then throw("Function invoke not allowed, requested from non-admin address")
9799 else if ((nyanToken == NONE))
98100 then throw("NYAN Token was not issued")
99101 else [Reissue(stringToByteVector(nyanToken), quantity, true)]
100102 }
101103
102104
103105
104106 @Callable(i)
105107 func transferNyanToken (recipient,amount) = {
106108 let userEmail = getUserEmailValue(recipient)
107109 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
108110 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
109111 let newDAppBalance = (currentDAppBalance - amount)
110- if ((userEmail == NONE))
111- then throw("You cannot transfer NYAN Tokens to an unregistered user")
112- else if ((0 > amount))
113- then throw("You cannot transfer a negative amount")
114- else if ((0 > newDAppBalance))
115- then throw("Not enough NYAN Tokens to transfer")
116- else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
112+ if (!(isAdmin(i.caller)))
113+ then throw("Function invoke not allowed, requested from non-admin address")
114+ else if ((userEmail == NONE))
115+ then throw("You cannot transfer NYAN Tokens to an unregistered user")
116+ else if ((0 > amount))
117+ then throw("You cannot transfer a negative amount")
118+ else if ((0 > newDAppBalance))
119+ then throw("Not enough NYAN Tokens to transfer")
120+ else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
117121 }
118122
119123
120124
121125 @Callable(i)
122126 func issueAssetToken (name,description,quantity,price,data) = {
123127 let assetTokenIssue = Issue(name, description, quantity, 0, true)
124128 let assetTokenAssetId = calculateAssetId(assetTokenIssue)
125129 let assetToken = byteVectorToString(assetTokenAssetId)
126- if ((quantity == 0))
127- then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
128- else {
129- let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
130- let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
131- let amount = (quantity * price)
132- let newDAppBalance = (currentDAppBalance - amount)
133- if ((0 > newDAppBalance))
134- then throw("Not enough NYAN Tokens to issue an asset")
135- else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
136- }
130+ if (!(isAdmin(i.caller)))
131+ then throw("Function invoke not allowed, requested from non-admin address")
132+ else if ((quantity == 0))
133+ then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
134+ else {
135+ let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
136+ let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
137+ let amount = (quantity * price)
138+ let newDAppBalance = (currentDAppBalance - amount)
139+ if ((0 > newDAppBalance))
140+ then throw("Not enough NYAN Tokens to issue an asset")
141+ else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
142+ }
137143 }
138144
139145
140146
141147 @Callable(i)
142148 func reissueAssetToken (assetId,quantity) = {
143149 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
144150 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
145151 let price = getAssetPriceValue(assetId)
146152 let amount = (quantity * price)
147153 let newDAppBalance = (currentDAppBalance - amount)
148- if ((0 > newDAppBalance))
149- then throw("Not enough NYAN Tokens to reissue an asset")
150- else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
154+ if (!(isAdmin(i.caller)))
155+ then throw("Function invoke not allowed, requested from non-admin address")
156+ else if ((0 > newDAppBalance))
157+ then throw("Not enough NYAN Tokens to reissue an asset")
158+ else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
151159 }
152160
153161
154162
155163 @Callable(i)
156164 func exchangeAssetToken (assetId,amount) = {
157165 let payments = i.payments
158166 if ((size(payments) == 0))
159167 then throw("You need to attach the payment")
160168 else {
161169 let paymentAmount = payments[0].amount
162170 let paymentAssetId = value(payments[0].assetId)
163171 let assetPrice = getAssetPriceValue(assetId)
164172 let assetAmount = (amount * assetPrice)
165173 let userAddress = i.caller
166174 let assetTokenAssetId = stringToByteVector(assetId)
167175 if ((assetAmount > paymentAmount))
168176 then throw("Not enough NYAN Tokens to exchange an asset")
169177 else if ((paymentAmount == assetAmount))
170178 then [ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, paymentAmount)]
171179 else {
172180 let paymentAmountChange = (paymentAmount - assetAmount)
173181 [ScriptTransfer(userAddress, amount, assetTokenAssetId), ScriptTransfer(userAddress, paymentAmountChange, paymentAssetId), Burn(paymentAssetId, assetAmount)]
174182 }
175183 }
176184 }
177185
178186
179187 @Verifier(tx)
180188 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
181189

github/deemru/w8io/026f985 
29.40 ms