tx · 52XBai7eLEAek4cwq7M4q79WGNcm2tDGsaVujEJj9M64

3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4:  -0.01400000 Waves

2020.03.11 12:44 [904327] smart account 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4 > SELF 0.00000000 Waves

{ "type": 13, "id": "52XBai7eLEAek4cwq7M4q79WGNcm2tDGsaVujEJj9M64", "fee": 1400000, "feeAssetId": null, "timestamp": 1583919775148, "version": 1, "sender": "3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4", "senderPublicKey": "4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L", "proofs": [ "8A8xsQr2QtrJKDZ5QzsGDFtty9bVkXCkebRd4iiUoSADuqFvxvxFGfKijSJuN7TX3qdyE7jTdJPwpGv7vMsaTXB" ], "script": "base64:AAIDAAAAAAAAABMIARIGCgQIAQEIEgcKBQgICAEBAAAAHwAAAAAHYUJpdENPMgEAAAAgx/h6AJ03UJ8qMmy7JIhz3VjOE4OL3ofCGi0oG2fBKJYAAAAACHN0YXJ0UXR5AAAAAAAABRQAAAAAAAhub21QcmljZQAAAAAABfXhAAAAAAAQc3VwcGxpZXJEaXNjb3VudAAAAAAAAAAADAAAAAAOT3duZXJFY29QdWJLZXkBAAAAIC70W6NACRoO8DcwW0R46ze+bNGLr0tg3cAkNP8WNkAfAAAAAAN3dnMAAAAAAAX14QAAAAAABE5PTkUCAAAABG5vbmUAAAAABmlzc3VlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMr3Oz7nL9FV4g+t+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0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AgIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAAC2Ftb3VudEFzc2V0BQAAAAl3aXRoV2F2ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAAFjBQAAAAckbWF0Y2gwBgdrJQ5R", "chainId": 84, "height": 904327, "spentComplexity": 0 } View: original | compacted Prev: AWE2Puoc6oeGKB8TjoakwSxfg7P3nEUdgrgzjf9xvHYk Next: FfpVMy8WC5CWDJ1W2fPA2HNY7ZAx7kaWngfHqj1KhV3z Diff:
OldNewDifferences
77
88 let nomPrice = 100000000
99
10-let discountPreIcoSupplier = 12
10+let supplierDiscount = 12
1111
1212 let OwnerEcoPubKey = base58'4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L'
1313
3939 }
4040
4141
42-func getKeyItem (supplier,title) = ("BitCO2:_" + toBase58String(sha256(toBytes((supplier + title)))))
42+func getKeyItem (supplier,title) = ("tokens_Bit-CO2:_" + toBase58String(sha256(toBytes((supplier + title)))))
4343
4444
45-func getKeyItemSupplier (item) = (item + "_Amaz")
45+func getKeyItemSupplier (item) = (item + "_to_Amazonian_Conservation")
4646
4747
4848 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
49-
50-
51-func getKeyItemQty (item) = (item + "_tok.amount")
52-
53-
54-func getValueItemQty (item) = getNumberByKey(getKeyItemQty(item))
5549
5650
5751 func getKeyBalanceQtySupplier (item) = (item + "_tokens")
7872 func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item))
7973
8074
81-func getKeyPaymentUser (item) = (item + "_user.pmt")
82-
83-
84-func getValuePaymentUser (item) = getNumberByKey(getKeyPaymentUser(item))
85-
86-
87-func getKeyBalanceQtyUser (item) = (item + "_saldqty")
88-
89-
90-func getValueBalanceQtyUser (item) = getNumberByKey(getKeyBalanceQtyUser(item))
91-
92-
93-func getKeyItemUserOrderQty (item) = (item + "_qty")
75+func getKeyItemUserOrderQty (item) = (item + "_tokens")
9476
9577
9678 func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item))
9779
9880
99-func getKeyBalanceSupplier (supplier) = (supplier + "_seller_balance")
81+func getKeyBalanceSupplier (supplier) = (supplier + "_waves")
10082
10183
102-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
84+func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier))
10385
10486
105-func getKeyItemUser (item) = (("name:_" + item) + "_")
87+func getKeyItemUser (item) = ("name:_" + item)
10688
10789
10890 func getValueItemUser (item) = getStrByKey(getKeyItemUser(item))
121103
122104
123105 @Callable(i)
124-func AddSupplierToken (title,preIcoQty,supplierData) = {
106+func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = {
125107 let supplier = toBase58String(i.caller.bytes)
126108 let item = getKeyItem(supplier, title)
127109 if ((0 >= preIcoQty))
128110 then throw("Sorry, insufficient token offer")
129- else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_1_BitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData), DataEntry(getKeyBalanceSupplier(supplier), 0)])
111+ else WriteSet([DataEntry(("Ofertante:_" + getKeyItemSupplier(item)), supplier), DataEntry(("Saldo/Cantidad,_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_1_BitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(("Max_Descuento_ofrecido:_" + getKeyItemDiscountSupplier(item)), supplierDiscount), DataEntry(getKeyItemData(item), supplierData), DataEntry(("Saldo/Blance,_waves:_" + getKeyBalanceSupplier(supplier)), 0)])
130112 }
131113
132114
133115
134116 @Callable(i)
135-func PurchaseToken (item,projectName,userData) = {
117+func PurchaseToken (item,projectName,userData,orderQty,userDiscount) = {
136118 let pmt = extract(i.payment)
137119 if (isDefined(pmt.assetId))
138120 then throw("you can adquire cBitCO2 only by Waves tokens")
139121 else {
140- let account = getValueItemSupplier(item)
122+ let supplier = match getString(this, getKeyItemSupplier(item)) {
123+ case a: String =>
124+ a
125+ case _ =>
126+ NONE
127+ }
141128 let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) {
142129 case a: Int =>
143130 a
145132 startQty
146133 }
147134 let userAddress = toBase58String(i.caller.bytes)
148- let buyerTokenPrice = ((nomPrice * (100 - discountPreIcoSupplier)) / 100)
149- let orderAmount = (pmt.amount / buyerTokenPrice)
150- let newQty = (preIcoQty - orderAmount)
151- let totalAmount = (orderAmount * buyerTokenPrice)
135+ let buyerTokenPrice = ((nomPrice * (100 - userDiscount)) / 100)
136+ let totalAmount = (orderQty * buyerTokenPrice)
152137 if ((totalAmount > pmt.amount))
153138 then throw("Payment Amount cannot be less than item Purchase Order")
154139 else if ((pmt.amount > totalAmount))
155140 then throw("Payment Amount can't be higher than item Purchase Order")
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(("Suma_a_invertir:_" + getKeyBalanceUser(item)), pmt.amount), DataEntry(("Request_Status:_" + userAddress), "sold"), DataEntry(("User_Balance:_" + getKeyBalanceQtyUser(item)), (getValueBalanceQtyUser(item) + orderAmount)), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_Seller:_" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, aBitCO2)]))
141+ else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemUser(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry(("Cantidad_solicitada:_" + getKeyItemUserOrderQty(item)), orderQty), DataEntry(("Balance_usuario:_" + getKeyBalanceUser(item)), (getValueBalanceUser(item) - pmt.amount)), DataEntry(("Request_Status:_" + userAddress), "sold"), DataEntry(("Saldo_Supplier:_" + getKeyBalanceQtySupplier(item)), (getValueBalanceQtySupplier(item) - orderQty)), DataEntry(("Saldo_Seller:_" + getKeyBalanceSupplier(supplier)), (getValueBalanceSupplier(supplier) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderQty, aBitCO2)]))
157142 }
158143 }
159144
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let aBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry'
55
66 let startQty = 332800
77
88 let nomPrice = 100000000
99
10-let discountPreIcoSupplier = 12
10+let supplierDiscount = 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
42-func getKeyItem (supplier,title) = ("BitCO2:_" + toBase58String(sha256(toBytes((supplier + title)))))
42+func getKeyItem (supplier,title) = ("tokens_Bit-CO2:_" + toBase58String(sha256(toBytes((supplier + title)))))
4343
4444
45-func getKeyItemSupplier (item) = (item + "_Amaz")
45+func getKeyItemSupplier (item) = (item + "_to_Amazonian_Conservation")
4646
4747
4848 func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item))
49-
50-
51-func getKeyItemQty (item) = (item + "_tok.amount")
52-
53-
54-func getValueItemQty (item) = getNumberByKey(getKeyItemQty(item))
5549
5650
5751 func getKeyBalanceQtySupplier (item) = (item + "_tokens")
5852
5953
6054 func getValueBalanceQtySupplier (item) = getNumberByKey(getKeyBalanceQtySupplier(item))
6155
6256
6357 func getKeyItemData (item) = (item + "_description")
6458
6559
6660 func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt")
6761
6862
6963 func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item))
7064
7165
7266 func getKeyItemUserData (item) = (item + "_userdata")
7367
7468
7569 func getKeyBalanceUser (item) = (item + "_saldwvsuser")
7670
7771
7872 func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item))
7973
8074
81-func getKeyPaymentUser (item) = (item + "_user.pmt")
82-
83-
84-func getValuePaymentUser (item) = getNumberByKey(getKeyPaymentUser(item))
85-
86-
87-func getKeyBalanceQtyUser (item) = (item + "_saldqty")
88-
89-
90-func getValueBalanceQtyUser (item) = getNumberByKey(getKeyBalanceQtyUser(item))
91-
92-
93-func getKeyItemUserOrderQty (item) = (item + "_qty")
75+func getKeyItemUserOrderQty (item) = (item + "_tokens")
9476
9577
9678 func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item))
9779
9880
99-func getKeyBalanceSupplier (supplier) = (supplier + "_seller_balance")
81+func getKeyBalanceSupplier (supplier) = (supplier + "_waves")
10082
10183
102-func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account))
84+func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier))
10385
10486
105-func getKeyItemUser (item) = (("name:_" + item) + "_")
87+func getKeyItemUser (item) = ("name:_" + item)
10688
10789
10890 func getValueItemUser (item) = getStrByKey(getKeyItemUser(item))
10991
11092
11193 func getKeyItemDiscountSupplier (item) = (("disc:_" + item) + "_")
11294
11395
11496 func getValueItemDiscountSupplier (item) = getNumberByKey(getKeyItemDiscountSupplier(item))
11597
11698
11799 func getKeyItemPriceSupplier (item) = (("Nom:_" + item) + "_")
118100
119101
120102 func getValueItemPriceSupplier (item) = getNumberByKey(getKeyItemPriceSupplier(item))
121103
122104
123105 @Callable(i)
124-func AddSupplierToken (title,preIcoQty,supplierData) = {
106+func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = {
125107 let supplier = toBase58String(i.caller.bytes)
126108 let item = getKeyItem(supplier, title)
127109 if ((0 >= preIcoQty))
128110 then throw("Sorry, insufficient token offer")
129- else WriteSet([DataEntry(getKeyItemSupplier(item), supplier), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_1_BitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(getKeyItemDiscountSupplier(item), discountPreIcoSupplier), DataEntry(getKeyItemData(item), supplierData), DataEntry(getKeyBalanceSupplier(supplier), 0)])
111+ else WriteSet([DataEntry(("Ofertante:_" + getKeyItemSupplier(item)), supplier), DataEntry(("Saldo/Cantidad,_tokens:_" + getKeyBalanceQtySupplier(item)), preIcoQty), DataEntry(("Precio_Nominal_1_BitCO2:_" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(("Max_Descuento_ofrecido:_" + getKeyItemDiscountSupplier(item)), supplierDiscount), DataEntry(getKeyItemData(item), supplierData), DataEntry(("Saldo/Blance,_waves:_" + getKeyBalanceSupplier(supplier)), 0)])
130112 }
131113
132114
133115
134116 @Callable(i)
135-func PurchaseToken (item,projectName,userData) = {
117+func PurchaseToken (item,projectName,userData,orderQty,userDiscount) = {
136118 let pmt = extract(i.payment)
137119 if (isDefined(pmt.assetId))
138120 then throw("you can adquire cBitCO2 only by Waves tokens")
139121 else {
140- let account = getValueItemSupplier(item)
122+ let supplier = match getString(this, getKeyItemSupplier(item)) {
123+ case a: String =>
124+ a
125+ case _ =>
126+ NONE
127+ }
141128 let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) {
142129 case a: Int =>
143130 a
144131 case _ =>
145132 startQty
146133 }
147134 let userAddress = toBase58String(i.caller.bytes)
148- let buyerTokenPrice = ((nomPrice * (100 - discountPreIcoSupplier)) / 100)
149- let orderAmount = (pmt.amount / buyerTokenPrice)
150- let newQty = (preIcoQty - orderAmount)
151- let totalAmount = (orderAmount * buyerTokenPrice)
135+ let buyerTokenPrice = ((nomPrice * (100 - userDiscount)) / 100)
136+ let totalAmount = (orderQty * buyerTokenPrice)
152137 if ((totalAmount > pmt.amount))
153138 then throw("Payment Amount cannot be less than item Purchase Order")
154139 else if ((pmt.amount > totalAmount))
155140 then throw("Payment Amount can't be higher than item Purchase Order")
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(("Suma_a_invertir:_" + getKeyBalanceUser(item)), pmt.amount), DataEntry(("Request_Status:_" + userAddress), "sold"), DataEntry(("User_Balance:_" + getKeyBalanceQtyUser(item)), (getValueBalanceQtyUser(item) + orderAmount)), DataEntry(("Saldo_tokens:_" + getKeyBalanceQtySupplier(item)), newQty), DataEntry(("Saldo_Seller:_" + getKeyBalanceSupplier(account)), (getValueBalanceSupplier(account) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderAmount, aBitCO2)]))
141+ else ScriptResult(WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyItemUser(item), projectName), DataEntry(getKeyItemUserData(item), userData), DataEntry(("Cantidad_solicitada:_" + getKeyItemUserOrderQty(item)), orderQty), DataEntry(("Balance_usuario:_" + getKeyBalanceUser(item)), (getValueBalanceUser(item) - pmt.amount)), DataEntry(("Request_Status:_" + userAddress), "sold"), DataEntry(("Saldo_Supplier:_" + getKeyBalanceQtySupplier(item)), (getValueBalanceQtySupplier(item) - orderQty)), DataEntry(("Saldo_Seller:_" + getKeyBalanceSupplier(supplier)), (getValueBalanceSupplier(supplier) + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderQty, aBitCO2)]))
157142 }
158143 }
159144
160145
161146 @Verifier(tx)
162147 func verify () = match tx {
163148 case t: SetScriptTransaction =>
164149 sigVerify(tx.bodyBytes, tx.proofs[0], OwnerEcoPubKey)
165150 case d: DataTransaction =>
166151 true
167152 case tx: TransferTransaction =>
168153 true
169154 case tx: ExchangeTransaction =>
170155 let withWaves = if (!(isDefined(tx.sellOrder.assetPair.priceAsset)))
171156 then true
172157 else !(isDefined(tx.sellOrder.assetPair.amountAsset))
173158 withWaves
174159 case c: InvokeScriptTransaction =>
175160 true
176161 case _ =>
177162 false
178163 }
179164

github/deemru/w8io/026f985 
43.90 ms