tx · 8ubdGLD6vFVDPUQL7ZmfcMiexTLeuEALfM6agDECVKDE

3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE:  -0.01400000 Waves

2021.06.21 23:53 [1580645] smart account 3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE > SELF 0.00000000 Waves

{ "type": 13, "id": "8ubdGLD6vFVDPUQL7ZmfcMiexTLeuEALfM6agDECVKDE", "fee": 1400000, "feeAssetId": null, "timestamp": 1624308802555, "version": 2, "chainId": 84, "sender": "3Mr5qPbeVKxVRjGMAumaEkSK7dMo3FbtFYE", "senderPublicKey": "EsW1U1EWPD2yLGRwTq3i9ftXRvWVpLbNz9R8U9xAF4e8", "proofs": [ "4fd6DP5Us1SD1eSS71fTsRa9jeicmNno6RXhJmSxHfRi4fPMwi6mGGiX66iZ37UVmHj4RZpgWiRWGVRJYMFGCyff" ], "script": "base64:AAIEAAAAAAAAACwIAhIDCgEIEgMKAQESAwoBARIECgIIARIHCgUICAEBCBIECgIIARIECgIIAQAAABABAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPYWRkcmVzc1RvU3RyaW5nAAAAAQAAAAdhZGRyZXNzCQACWAAAAAEIBQAAAAdhZGRyZXNzAAAABWJ5dGVzAQAAAA9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2V0QW1vdW50BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleVPVewQ=", "height": 1580645, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 89eJNseCvbRvACYZEpvNitiigR8rVEL3gk2cDJZr29pY Next: 6ucu4qNnuJuPPVKgLT16wo45R679uFRPCAVactTai51r Diff:
OldNewDifferences
3535
3636
3737 func stringToByteVector (string) = fromBase58String(string)
38+
39+
40+func isAdmin (caller) = (this == caller)
3841
3942
4043 func getUserEmailKey (userEmail) = (("user_" + userEmail) + "_email")
8992 @Callable(i)
9093 func reissueNyanToken (quantity) = {
9194 let nyanToken = getNyanTokenValue(this)
92- if ((nyanToken == NONE))
93- then throw("NYAN Token was not issued")
94- else [Reissue(stringToByteVector(nyanToken), quantity, true)]
95+ if (!(isAdmin(i.caller)))
96+ then throw("not admin, // TODO message")
97+ else if ((nyanToken == NONE))
98+ then throw("NYAN Token was not issued")
99+ else [Reissue(stringToByteVector(nyanToken), quantity, true)]
95100 }
96101
97102
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)
38+
39+
40+func isAdmin (caller) = (this == caller)
3841
3942
4043 func getUserEmailKey (userEmail) = (("user_" + userEmail) + "_email")
4144
4245
4346 func getUserEmailValue (userEmail) = getStringByKey(getUserEmailKey(userEmail))
4447
4548
4649 func getNyanTokenKey (dAppAddress) = (("dApp_" + addressToString(dAppAddress)) + "_tokenId")
4750
4851
4952 func getNyanTokenValue (dAppAddress) = getStringByKey(getNyanTokenKey(dAppAddress))
5053
5154
5255 func getAssetPriceKey (assetId) = (("asset_" + assetId) + "_price")
5356
5457
5558 func getAssetPriceValue (assetId) = getNumberByKey(getAssetPriceKey(assetId))
5659
5760
5861 func getAssetDataKey (assetId) = (("asset_" + assetId) + "_data")
5962
6063
6164 func getAssetDataValue (assetId) = getStringByKey(getAssetPriceKey(assetId))
6265
6366
6467 @Callable(i)
6568 func signUp (email) = {
6669 let userAddress = addressToString(i.caller)
6770 let userEmail = getUserEmailValue(userAddress)
6871 if ((userEmail != NONE))
6972 then throw((("User " + userEmail) + " is already registered"))
7073 else [StringEntry(getUserEmailKey(userAddress), email)]
7174 }
7275
7376
7477
7578 @Callable(i)
7679 func issueNyanToken (quantity) = {
7780 let nyanToken = getNyanTokenValue(this)
7881 if ((nyanToken != NONE))
7982 then throw("NYAN Token is already issued")
8083 else {
8184 let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
8285 let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
8386 [nyanTokenIssue, StringEntry(getNyanTokenKey(this), byteVectorToString(nyanTokenAssetId))]
8487 }
8588 }
8689
8790
8891
8992 @Callable(i)
9093 func reissueNyanToken (quantity) = {
9194 let nyanToken = getNyanTokenValue(this)
92- if ((nyanToken == NONE))
93- then throw("NYAN Token was not issued")
94- else [Reissue(stringToByteVector(nyanToken), quantity, true)]
95+ if (!(isAdmin(i.caller)))
96+ then throw("not admin, // TODO message")
97+ else if ((nyanToken == NONE))
98+ then throw("NYAN Token was not issued")
99+ else [Reissue(stringToByteVector(nyanToken), quantity, true)]
95100 }
96101
97102
98103
99104 @Callable(i)
100105 func transferNyanToken (recipient,amount) = {
101106 let userEmail = getUserEmailValue(recipient)
102107 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
103108 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
104109 let newDAppBalance = (currentDAppBalance - amount)
105110 if ((userEmail == NONE))
106111 then throw("You cannot transfer NYAN Tokens to an unregistered user")
107112 else if ((0 > amount))
108113 then throw("You cannot transfer a negative amount")
109114 else if ((0 > newDAppBalance))
110115 then throw("Not enough NYAN Tokens to transfer")
111116 else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
112117 }
113118
114119
115120
116121 @Callable(i)
117122 func issueAssetToken (name,description,quantity,price,data) = {
118123 let assetTokenIssue = Issue(name, description, quantity, 0, true)
119124 let assetTokenAssetId = calculateAssetId(assetTokenIssue)
120125 let assetToken = byteVectorToString(assetTokenAssetId)
121126 if ((quantity == 0))
122127 then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
123128 else {
124129 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
125130 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
126131 let amount = (quantity * price)
127132 let newDAppBalance = (currentDAppBalance - amount)
128133 if ((0 > newDAppBalance))
129134 then throw("Not enough NYAN Tokens to issue an asset")
130135 else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
131136 }
132137 }
133138
134139
135140
136141 @Callable(i)
137142 func reissueAssetToken (assetId,quantity) = {
138143 let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
139144 let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
140145 let price = getAssetPriceValue(assetId)
141146 let amount = (quantity * price)
142147 let newDAppBalance = (currentDAppBalance - amount)
143148 if ((0 > newDAppBalance))
144149 then throw("Not enough NYAN Tokens to reissue an asset")
145150 else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
146151 }
147152
148153
149154
150155 @Callable(i)
151156 func exchangeAssetToken (assetId,amount) = {
152157 let payments = i.payments
153158 if ((size(payments) == 0))
154159 then throw("You need to attach the payment")
155160 else {
156161 let paymentAmount = payments[0].amount
157162 let paymentAssetId = value(payments[0].assetId)
158163 let assetPrice = getAssetPriceValue(assetId)
159164 let assetAmount = (amount * assetPrice)
160165 let userAddress = i.caller
161166 let assetTokenAssetId = stringToByteVector(assetId)
162167 if ((assetAmount > paymentAmount))
163168 then throw("Not enough NYAN Tokens to exchange an asset")
164169 else if ((paymentAmount == assetAmount))
165170 then [ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, paymentAmount)]
166171 else {
167172 let paymentAmountChange = (paymentAmount - assetAmount)
168173 [ScriptTransfer(userAddress, amount, assetTokenAssetId), ScriptTransfer(userAddress, paymentAmountChange, paymentAssetId), Burn(paymentAssetId, assetAmount)]
169174 }
170175 }
171176 }
172177
173178
174179 @Verifier(tx)
175180 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
176181

github/deemru/w8io/026f985 
28.91 ms