tx · D96gTsSEfag7zdqvpSe1GKhB951yy5TCs4ecxNUcYYNA

3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW:  -0.01400000 Waves

2021.05.27 15:03 [1544045] smart account 3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW > SELF 0.00000000 Waves

{ "type": 13, "id": "D96gTsSEfag7zdqvpSe1GKhB951yy5TCs4ecxNUcYYNA", "fee": 1400000, "feeAssetId": null, "timestamp": 1622116984575, "version": 2, "chainId": 84, "sender": "3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW", "senderPublicKey": "5srZ8D8Vg1b4qfzwjgdC95jnpt3akRn77NAAmJdoWc6X", "proofs": [ "64eSYCrEedgMDmGAxhGmFim8gbFjKK9BPrkJgSNXkoe2iPPBWyztqT1YB4zznrx4Yo9pStBai856Y7wb1MdUJLLx" ], "script": "base64:AAIEAAAAAAAAACwIAhIDCgEIEgMKAQESAwoBARIECgIIARIHCgUICAEBCBIECgIIARIECgIIAQAAAA8BAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPYWRkcmVzc1RvU3RyaW5nAAAAAQAAAAdhZGRyZXNzCQACWAAAAAEIBQAAAAdhZGRyZXNzAAAABWJ5dGVzAQAAAA9zdHJpbmdUb0FkZ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ACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5TL+0MA==", "height": 1544045, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ArNoBwgvpgoZFd7BG6AXkHRcRVZkDXLiEgNgHxRQ6a64 Next: oo5yMq9JVR1zsFzM5rZYoZhVfQWNRh7qdtdMcPyQkaZ Diff:
OldNewDifferences
6363
6464 @Callable(i)
6565 func signUp (email) = {
66- let userEmail = getUserEmailValue(addressToString(i.caller))
66+ let userAddress = addressToString(i.caller)
67+ let userEmail = getUserEmailValue(userAddress)
6768 if ((userEmail != NONE))
6869 then throw((("User" + userEmail) + "is already registered"))
69- else [StringEntry(getUserEmailKey(email), email)]
70+ else [StringEntry(getUserEmailKey(userAddress), email)]
7071 }
7172
7273
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 getUserEmailKey (userEmail) = (("user_" + userEmail) + "_email")
4141
4242
4343 func getUserEmailValue (userEmail) = getStringByKey(getUserEmailKey(userEmail))
4444
4545
4646 func getNyanTokenKey (dAppAddress) = (("dApp_" + addressToString(dAppAddress)) + "_tokenId")
4747
4848
4949 func getNyanTokenValue (dAppAddress) = getStringByKey(getNyanTokenKey(dAppAddress))
5050
5151
5252 func getAssetPriceKey (assetId) = (("asset_" + assetId) + "_price")
5353
5454
5555 func getAssetPriceValue (assetId) = getNumberByKey(getAssetPriceKey(assetId))
5656
5757
5858 func getAssetDataKey (assetId) = (("asset_" + assetId) + "_data")
5959
6060
6161 func getAssetDataValue (assetId) = getStringByKey(getAssetPriceKey(assetId))
6262
6363
6464 @Callable(i)
6565 func signUp (email) = {
66- let userEmail = getUserEmailValue(addressToString(i.caller))
66+ let userAddress = addressToString(i.caller)
67+ let userEmail = getUserEmailValue(userAddress)
6768 if ((userEmail != NONE))
6869 then throw((("User" + userEmail) + "is already registered"))
69- else [StringEntry(getUserEmailKey(email), email)]
70+ else [StringEntry(getUserEmailKey(userAddress), email)]
7071 }
7172
7273
7374
7475 @Callable(i)
7576 func issueNyanToken (quantity) = {
7677 let nyanToken = getNyanTokenValue(this)
7778 if ((nyanToken != NONE))
7879 then throw("NYAN Token is already issued")
7980 else {
8081 let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
8182 let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
8283 [nyanTokenIssue, StringEntry(getNyanTokenKey(this), byteVectorToString(nyanTokenAssetId))]
8384 }
8485 }
8586
8687
8788
8889 @Callable(i)
8990 func reissueNyanToken (quantity) = {
9091 let nyanToken = getNyanTokenValue(this)
9192 if ((nyanToken != NONE))
9293 then throw("NYAN Token was not issued")
9394 else [Reissue(stringToByteVector(nyanToken), quantity, true)]
9495 }
9596
9697
9798
9899 @Callable(i)
99100 func transferNyanToken (recipient,amount) = {
100101 let userEmail = getUserEmailValue(recipient)
101102 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
102103 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
103104 let newDAppBalance = (currentDAppBalance - amount)
104105 if ((userEmail == NONE))
105106 then throw("You cannot transfer NYAN Tokens to an unregistered user")
106107 else if ((0 > amount))
107108 then throw("You cannot transfer a negative amount")
108109 else if ((0 > newDAppBalance))
109110 then throw("Not enough NYAN Tokens to transfer")
110111 else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
111112 }
112113
113114
114115
115116 @Callable(i)
116117 func issueAssetToken (name,description,quantity,price,data) = {
117118 let assetTokenIssue = Issue(name, description, quantity, 0, true)
118119 let assetTokenAssetId = calculateAssetId(assetTokenIssue)
119120 let assetToken = byteVectorToString(assetTokenAssetId)
120121 if ((quantity == 0))
121122 then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
122123 else {
123124 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
124125 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
125126 let amount = (quantity * price)
126127 let newDAppBalance = (currentDAppBalance - amount)
127128 if ((0 > newDAppBalance))
128129 then throw("Not enough NYAN Tokens to issue an asset")
129130 else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
130131 }
131132 }
132133
133134
134135
135136 @Callable(i)
136137 func reissueAssetToken (assetId,quantity) = {
137138 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
138139 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
139140 let price = getAssetPriceValue(assetId)
140141 let amount = (quantity * price)
141142 let newDAppBalance = (currentDAppBalance - amount)
142143 if ((0 > newDAppBalance))
143144 then throw("Not enough NYAN Tokens to reissue an asset")
144145 else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
145146 }
146147
147148
148149
149150 @Callable(i)
150151 func exchangeAssetToken (assetId,amount) = {
151152 let payments = i.payments
152153 if ((size(payments) == 0))
153154 then throw("You need to attach the payment")
154155 else {
155156 let paymentAmount = payments[0].amount
156157 let paymentAssetId = value(payments[0].assetId)
157158 let assetPrice = getAssetPriceValue(assetId)
158159 let assetAmount = (amount * assetPrice)
159160 let userAddress = i.caller
160161 let assetTokenAssetId = stringToByteVector(assetId)
161162 if ((assetAmount > paymentAmount))
162163 then throw("Not enough NYAN Tokens to exchange an asset")
163164 else if ((paymentAmount == assetAmount))
164165 then [ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, paymentAmount)]
165166 else {
166167 let neededPaymentAmount = (paymentAmount - assetAmount)
167168 let paymentAmountChange = (paymentAmount - neededPaymentAmount)
168169 [ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, neededPaymentAmount), ScriptTransfer(userAddress, paymentAmountChange, paymentAssetId)]
169170 }
170171 }
171172 }
172173
173174
174175 @Verifier(tx)
175176 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
176177

github/deemru/w8io/169f3d6 
31.11 ms