tx · ArNoBwgvpgoZFd7BG6AXkHRcRVZkDXLiEgNgHxRQ6a64

3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW:  -0.01000000 Waves

2021.05.27 14:51 [1544032] smart account 3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW > SELF 0.00000000 Waves

{ "type": 13, "id": "ArNoBwgvpgoZFd7BG6AXkHRcRVZkDXLiEgNgHxRQ6a64", "fee": 1000000, "feeAssetId": null, "timestamp": 1622116344977, "version": 2, "chainId": 84, "sender": "3My8JdxskXSWKLkjcyYvRPyoymhs9F9KeuW", "senderPublicKey": "5srZ8D8Vg1b4qfzwjgdC95jnpt3akRn77NAAmJdoWc6X", "proofs": [ "CGiubP3t1eVP7MrXDEPDDVgt4QVSvrPmCE4MzZtCS8mrCcf2RhwUiA48Bv5zHpyWXizofm37cK8ctMQAk2QatBa" ], "script": "base64:AAIEAAAAAAAAACwIAhIDCgEIEgMKAQESAwoBARIECgIIARIHCgUICAEBCBIECgIIARIECgIIAQAAAA8BAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAABm51bWJlcgQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAAGbnVtYmVyAAAAAAROT05FAgAAAARub25lAQAAAA5nZXRTdHJpbmdCeUtleQAAAAEAAAADa2V5BAAAAAZzdHJpbmcEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAABnN0cmluZwEAAAAPYWRkcmVzc1RvU3RyaW5nAAAAAQAAAAdhZGRyZXNzCQACWAAAAAEIBQAAAAdhZGRyZXNzAAAABWJ5dGVzAQAAAA9zdHJp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AAAAnR4AAAAD3NlbmRlclB1YmxpY0tlefcsIBY=", "height": 1544032, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: D96gTsSEfag7zdqvpSe1GKhB951yy5TCs4ecxNUcYYNA Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 4 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+func getNumberByKey (key) = {
5+ let number = match getInteger(this, key) {
6+ case a: Int =>
7+ a
8+ case _ =>
9+ 0
10+ }
11+ number
12+ }
13+
14+
15+let NONE = "none"
16+
17+func getStringByKey (key) = {
18+ let string = match getString(this, key) {
19+ case a: String =>
20+ a
21+ case _ =>
22+ NONE
23+ }
24+ string
25+ }
26+
27+
28+func addressToString (address) = toBase58String(address.bytes)
29+
30+
31+func stringToAddress (string) = Address(fromBase58String(string))
32+
33+
34+func byteVectorToString (byteVector) = toBase58String(byteVector)
35+
36+
37+func stringToByteVector (string) = fromBase58String(string)
38+
39+
40+func getUserEmailKey (userEmail) = (("user_" + userEmail) + "_email")
41+
42+
43+func getUserEmailValue (userEmail) = getStringByKey(getUserEmailKey(userEmail))
44+
45+
46+func getNyanTokenKey (dAppAddress) = (("dApp_" + addressToString(dAppAddress)) + "_tokenId")
47+
48+
49+func getNyanTokenValue (dAppAddress) = getStringByKey(getNyanTokenKey(dAppAddress))
50+
51+
52+func getAssetPriceKey (assetId) = (("asset_" + assetId) + "_price")
53+
54+
55+func getAssetPriceValue (assetId) = getNumberByKey(getAssetPriceKey(assetId))
56+
57+
58+func getAssetDataKey (assetId) = (("asset_" + assetId) + "_data")
59+
60+
61+func getAssetDataValue (assetId) = getStringByKey(getAssetPriceKey(assetId))
62+
63+
64+@Callable(i)
65+func signUp (email) = {
66+ let userEmail = getUserEmailValue(addressToString(i.caller))
67+ if ((userEmail != NONE))
68+ then throw((("User" + userEmail) + "is already registered"))
69+ else [StringEntry(getUserEmailKey(email), email)]
70+ }
71+
72+
73+
74+@Callable(i)
75+func issueNyanToken (quantity) = {
76+ let nyanToken = getNyanTokenValue(this)
77+ if ((nyanToken != NONE))
78+ then throw("NYAN Token is already issued")
79+ else {
80+ let nyanTokenIssue = Issue("NYAN Token", "NYAN Token is a cryptocurrency token that operates on the Waves platform", quantity, 0, true)
81+ let nyanTokenAssetId = calculateAssetId(nyanTokenIssue)
82+[nyanTokenIssue, StringEntry(getNyanTokenKey(this), byteVectorToString(nyanTokenAssetId))]
83+ }
84+ }
85+
86+
87+
88+@Callable(i)
89+func reissueNyanToken (quantity) = {
90+ let nyanToken = getNyanTokenValue(this)
91+ if ((nyanToken != NONE))
92+ then throw("NYAN Token was not issued")
93+ else [Reissue(stringToByteVector(nyanToken), quantity, true)]
94+ }
95+
96+
97+
98+@Callable(i)
99+func transferNyanToken (recipient,amount) = {
100+ let userEmail = getUserEmailValue(recipient)
101+ let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
102+ let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
103+ let newDAppBalance = (currentDAppBalance - amount)
104+ if ((userEmail == NONE))
105+ then throw("You cannot transfer NYAN Tokens to an unregistered user")
106+ else if ((0 > amount))
107+ then throw("You cannot transfer a negative amount")
108+ else if ((0 > newDAppBalance))
109+ then throw("Not enough NYAN Tokens to transfer")
110+ else [ScriptTransfer(stringToAddress(recipient), amount, nyanTokenAssetId)]
111+ }
112+
113+
114+
115+@Callable(i)
116+func issueAssetToken (name,description,quantity,price,data) = {
117+ let assetTokenIssue = Issue(name, description, quantity, 0, true)
118+ let assetTokenAssetId = calculateAssetId(assetTokenIssue)
119+ let assetToken = byteVectorToString(assetTokenAssetId)
120+ if ((quantity == 0))
121+ then [assetTokenIssue, IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
122+ else {
123+ let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
124+ let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
125+ let amount = (quantity * price)
126+ let newDAppBalance = (currentDAppBalance - amount)
127+ if ((0 > newDAppBalance))
128+ then throw("Not enough NYAN Tokens to issue an asset")
129+ else [assetTokenIssue, Burn(nyanTokenAssetId, amount), IntegerEntry(getAssetPriceKey(assetToken), price), StringEntry(getAssetDataKey(assetToken), data)]
130+ }
131+ }
132+
133+
134+
135+@Callable(i)
136+func reissueAssetToken (assetId,quantity) = {
137+ let nyanTokenAssetId = stringToByteVector(getNyanTokenValue(this))
138+ let currentDAppBalance = assetBalance(this, nyanTokenAssetId)
139+ let price = getAssetPriceValue(assetId)
140+ let amount = (quantity * price)
141+ let newDAppBalance = (currentDAppBalance - amount)
142+ if ((0 > newDAppBalance))
143+ then throw("Not enough NYAN Tokens to reissue an asset")
144+ else [Reissue(stringToByteVector(assetId), quantity, true), Burn(nyanTokenAssetId, amount)]
145+ }
146+
147+
148+
149+@Callable(i)
150+func exchangeAssetToken (assetId,amount) = {
151+ let payments = i.payments
152+ if ((size(payments) == 0))
153+ then throw("You need to attach the payment")
154+ else {
155+ let paymentAmount = payments[0].amount
156+ let paymentAssetId = value(payments[0].assetId)
157+ let assetPrice = getAssetPriceValue(assetId)
158+ let assetAmount = (amount * assetPrice)
159+ let userAddress = i.caller
160+ let assetTokenAssetId = stringToByteVector(assetId)
161+ if ((assetAmount > paymentAmount))
162+ then throw("Not enough NYAN Tokens to exchange an asset")
163+ else if ((paymentAmount == assetAmount))
164+ then [ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, paymentAmount)]
165+ else {
166+ let neededPaymentAmount = (paymentAmount - assetAmount)
167+ let paymentAmountChange = (paymentAmount - neededPaymentAmount)
168+[ScriptTransfer(userAddress, amount, assetTokenAssetId), Burn(paymentAssetId, neededPaymentAmount), ScriptTransfer(userAddress, paymentAmountChange, paymentAssetId)]
169+ }
170+ }
171+ }
172+
173+
174+@Verifier(tx)
175+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
176+

github/deemru/w8io/169f3d6 
20.70 ms