tx · GKoaEa2R9sGpKnjtfeU4pHh33jh4SzeinxPayBxcNPiG

3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4:  -0.01400000 Waves

2020.03.10 11:54 [902821] smart account 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4 > SELF 0.00000000 Waves

{ "type": 13, "id": "GKoaEa2R9sGpKnjtfeU4pHh33jh4SzeinxPayBxcNPiG", "fee": 1400000, "feeAssetId": null, "timestamp": 1583830426416, "version": 1, "sender": "3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4", "senderPublicKey": "4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L", "proofs": [ "5x9Q2kHsiCWY5DddBypzz1k7jXNVaqKbxB5ZNE6Wx6K5PrGPaZ1xXH6GS9WyT2YvKeFArismn2qPEPuTQaScKiiR" ], "script": "base64:AAIDAAAAAAAAABAIARIFCgMIAQgSBQoDCAgIAAAAJQAAAAAHYUJpdENPMgEAAAAgx/h6AJ03UJ8qMmy7JIhz3VjOE4OL3ofCGi0oG2fBKJYAAAAACHN0YXJ0UXR5AAAAAAAABRQAAAAAAAhub21QcmljZQAAAAAABfXhAAAAAAAWZGlzY291bnRQcmVJY29TdXBwbGllcgAAAAAAAAAADAAAAAAOT3duZXJFY29QdWJLZXkBAAAAIC70W6NACRoO8DcwW0R46ze+bNGLr0tg3cAkNP8WNkAfAAAAAAN3dnMAAAAAAAX14QAAAAAABE5PTkUCAAAABG5vbmUAAAAABmlzc3VlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMr3Oz7nL9FV4g+t+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAA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0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADk93bmVyRWNvUHViS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE0V4Y2hhbmdlVHJhbnNhY3Rpb24EAAAAAnR4BQAAAAckbWF0Y2gwBAAAAAl3aXRoV2F2ZXMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCAgIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAACnByaWNlQXNzZXQGCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCAgIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAAC2Ftb3VudEFzc2V0BQAAAAl3aXRoV2F2ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAAFjBQAAAAckbWF0Y2gwBgfGTkb+", "chainId": 84, "height": 902821, "spentComplexity": 0 } View: original | compacted Prev: 8NoNFDidy3yoA3LNMVCpQ4fgb2C1GfJ3AwAiGP5JVAEz Next: 2EjbzBc2KyqBpvtCeAcbGp4cNbA8qFTzMXzoDdYS4tfa Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let cBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry'
4+let aBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry'
55
66 let startQty = 332800
77
121121
122122
123123 @Callable(i)
124-func AddSupplierToken (title,supplierData) = {
124+func AddSupplierToken (title,preIcoQty,supplierData) = {
125125 let supplier = toBase58String(i.caller.bytes)
126126 let item = getKeyItem(supplier, title)
127- let preIcoQty = match getInteger(this, supplier) {
128- case a: Int =>
129- a
130- case _ =>
131- startQty
132- }
133127 if ((0 >= preIcoQty))
134128 then throw("Sorry, insufficient token offer")
135- else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(getKeyBalanceQtySupplier(item), preIcoQty), DataEntry(("Precio_Nominal_de_1 token_cBitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData)])
129+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_de_1 token_cBitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData)])
136130 }
137131
138132
144138 then throw("you can adquire cBitCO2 only by Waves tokens")
145139 else {
146140 let account = getValueItemSupplier(item)
147- let currentQty = match getInteger(this, account) {
141+ let preIcoQty = match getInteger(this, account) {
148142 case a: Int =>
149143 a
150144 case _ =>
153147 let userAddress = toBase58String(i.caller.bytes)
154148 let buyerTokenPrice = ((nomPrice * (100 - discountPreIcoSupplier)) / 100)
155149 let orderAmount = (pmt.amount / buyerTokenPrice)
156- let newQty = (currentQty - orderAmount)
150+ let newQty = (preIcoQty - orderAmount)
157151 let totalAmount = (orderAmount * buyerTokenPrice)
158152 if ((totalAmount > pmt.amount))
159153 then throw("Payment Amount cannot be less than item Purchase Order")
160154 else if ((pmt.amount > totalAmount))
161155 then throw("Payment Amount can't be higher than item Purchase Order")
162- else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemSupplier(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry("Cantidad_de_tokens_a_comprar:_", orderAmount), DataEntry(("Investment_Amount,_waves_" + getKeyPaymentUser(item)), totalAmount), DataEntry(("Pago_en__waves_del_Inversor" + getKeyBalanceUser(item)), pmt.amount), DataEntry((("Request_Status:_" + userAddress) + "_"), "sold"), DataEntry((("User_Balance:_" + getKeyBalanceQtyUser(item)) + "_"), orderAmount), DataEntry(("Saldo_tokens_del_Proyecto" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_waves_del_vendedor" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, cBitCO2)]))
156+ else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemSupplier(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry("Cantidad_de_tokens_a_comprar:_", orderAmount), DataEntry(("Investment_Amount,_waves_" + getKeyPaymentUser(item)), totalAmount), DataEntry(("Pago_en__waves_del_Inversor" + getKeyBalanceUser(item)), pmt.amount), DataEntry((("Request_Status:_" + userAddress) + "_"), "sold"), DataEntry((("User_Balance:_" + getKeyBalanceQtyUser(item)) + "_"), orderAmount), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_waves_del_vendedor" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, aBitCO2)]))
163157 }
164158 }
165159
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let cBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry'
4+let aBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry'
55
66 let startQty = 332800
77
88 let nomPrice = 100000000
99
1010 let discountPreIcoSupplier = 12
1111
1212 let OwnerEcoPubKey = base58'4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L'
1313
1414 let wvs = 100000000
1515
1616 let NONE = "none"
1717
1818 let issuer = Address(base58'3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4')
1919
2020 func getNumberByKey (key) = {
2121 let num = match getInteger(this, key) {
2222 case a: Int =>
2323 a
2424 case _ =>
2525 0
2626 }
2727 num
2828 }
2929
3030
3131 func getStrByKey (key) = {
3232 let str = match getString(this, key) {
3333 case a: String =>
3434 a
3535 case _ =>
3636 NONE
3737 }
3838 str
3939 }
4040
4141
4242 func getKeyItem (supplier,title) = ("BitCO2:_" + toBase58String(sha256(toBytes((supplier + title)))))
4343
4444
4545 func getKeyItemSupplier (item) = (item + "_Amaz")
4646
4747
4848 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
4949
5050
5151 func getKeyItemQty (item) = (item + "_tok.amount")
5252
5353
5454 func getValueItemQty (item) = getNumberByKey(getKeyItemQty(item))
5555
5656
5757 func getKeyBalanceQtySupplier (item) = (item + "_tokens")
5858
5959
6060 func getValueBalanceQtySupplier (item) = getNumberByKey(getKeyBalanceQtySupplier(item))
6161
6262
6363 func getKeyItemData (item) = (item + "_description")
6464
6565
6666 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
6767
6868
6969 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
7070
7171
7272 func getKeyItemUserData (item) = (item + "_userdata")
7373
7474
7575 func getKeyBalanceUser (item) = (item + "_saldwvsuser")
7676
7777
7878 func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item))
7979
8080
8181 func getKeyPaymentUser (item) = (item + "_user.pmt")
8282
8383
8484 func getValuePaymentUser (item) = getNumberByKey(getKeyPaymentUser(item))
8585
8686
8787 func getKeyBalanceQtyUser (item) = (item + "_saldqty")
8888
8989
9090 func getValueBalanceQtyUser (item) = getNumberByKey(getKeyBalanceQtyUser(item))
9191
9292
9393 func getKeyItemUserOrderQty (item) = (item + "_qty")
9494
9595
9696 func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item))
9797
9898
9999 func getKeyBalanceSupplier (account) = (account + "_balance")
100100
101101
102102 func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
103103
104104
105105 func getKeyItemUser (item) = (("name:_" + item) + "_")
106106
107107
108108 func getValueItemUser (item) = getStrByKey(getKeyItemUser(item))
109109
110110
111111 func getKeyItemDiscountSupplier (item) = (("disc:_" + item) + "_")
112112
113113
114114 func getValueItemDiscountSupplier (item) = getNumberByKey(getKeyItemDiscountSupplier(item))
115115
116116
117117 func getKeyItemPriceSupplier (item) = (("Nom:_" + item) + "_")
118118
119119
120120 func getValueItemPriceSupplier (item) = getNumberByKey(getKeyItemPriceSupplier(item))
121121
122122
123123 @Callable(i)
124-func AddSupplierToken (title,supplierData) = {
124+func AddSupplierToken (title,preIcoQty,supplierData) = {
125125 let supplier = toBase58String(i.caller.bytes)
126126 let item = getKeyItem(supplier, title)
127- let preIcoQty = match getInteger(this, supplier) {
128- case a: Int =>
129- a
130- case _ =>
131- startQty
132- }
133127 if ((0 >= preIcoQty))
134128 then throw("Sorry, insufficient token offer")
135- else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(getKeyBalanceQtySupplier(item), preIcoQty), DataEntry(("Precio_Nominal_de_1 token_cBitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData)])
129+ else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_de_1 token_cBitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData)])
136130 }
137131
138132
139133
140134 @Callable(i)
141135 func PurchaseToken (item,projectName,userData) = {
142136 let pmt = extract(i.payment)
143137 if (isDefined(pmt.assetId))
144138 then throw("you can adquire cBitCO2 only by Waves tokens")
145139 else {
146140 let account = getValueItemSupplier(item)
147- let currentQty = match getInteger(this, account) {
141+ let preIcoQty = match getInteger(this, account) {
148142 case a: Int =>
149143 a
150144 case _ =>
151145 startQty
152146 }
153147 let userAddress = toBase58String(i.caller.bytes)
154148 let buyerTokenPrice = ((nomPrice * (100 - discountPreIcoSupplier)) / 100)
155149 let orderAmount = (pmt.amount / buyerTokenPrice)
156- let newQty = (currentQty - orderAmount)
150+ let newQty = (preIcoQty - orderAmount)
157151 let totalAmount = (orderAmount * buyerTokenPrice)
158152 if ((totalAmount > pmt.amount))
159153 then throw("Payment Amount cannot be less than item Purchase Order")
160154 else if ((pmt.amount > totalAmount))
161155 then throw("Payment Amount can't be higher than item Purchase Order")
162- else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemSupplier(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry("Cantidad_de_tokens_a_comprar:_", orderAmount), DataEntry(("Investment_Amount,_waves_" + getKeyPaymentUser(item)), totalAmount), DataEntry(("Pago_en__waves_del_Inversor" + getKeyBalanceUser(item)), pmt.amount), DataEntry((("Request_Status:_" + userAddress) + "_"), "sold"), DataEntry((("User_Balance:_" + getKeyBalanceQtyUser(item)) + "_"), orderAmount), DataEntry(("Saldo_tokens_del_Proyecto" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_waves_del_vendedor" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, cBitCO2)]))
156+ else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemSupplier(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry("Cantidad_de_tokens_a_comprar:_", orderAmount), DataEntry(("Investment_Amount,_waves_" + getKeyPaymentUser(item)), totalAmount), DataEntry(("Pago_en__waves_del_Inversor" + getKeyBalanceUser(item)), pmt.amount), DataEntry((("Request_Status:_" + userAddress) + "_"), "sold"), DataEntry((("User_Balance:_" + getKeyBalanceQtyUser(item)) + "_"), orderAmount), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_waves_del_vendedor" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, aBitCO2)]))
163157 }
164158 }
165159
166160
167161 @Verifier(tx)
168162 func verify () = match tx {
169163 case t: SetScriptTransaction =>
170164 sigVerify(tx.bodyBytes, tx.proofs[0], OwnerEcoPubKey)
171165 case d: DataTransaction =>
172166 true
173167 case tx: TransferTransaction =>
174168 true
175169 case tx: ExchangeTransaction =>
176170 let withWaves = if (!(isDefined(tx.sellOrder.assetPair.priceAsset)))
177171 then true
178172 else !(isDefined(tx.sellOrder.assetPair.amountAsset))
179173 withWaves
180174 case c: InvokeScriptTransaction =>
181175 true
182176 case _ =>
183177 false
184178 }
185179

github/deemru/w8io/026f985 
58.18 ms