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+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ck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gIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAAC2Ftb3VudEFzc2V0BQAAAAl3aXRoV2F2ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAAFjBQAAAAckbWF0Y2gwBgdrJQ5R", "chainId": 84, "height": 904327, "spentComplexity": 0 } View: original | compacted Prev: AWE2Puoc6oeGKB8TjoakwSxfg7P3nEUdgrgzjf9xvHYk Next: FfpVMy8WC5CWDJ1W2fPA2HNY7ZAx7kaWngfHqj1KhV3z Diff:
Old | New | Differences | |
---|---|---|---|
7 | 7 | ||
8 | 8 | let nomPrice = 100000000 | |
9 | 9 | ||
10 | - | let | |
10 | + | let supplierDiscount = 12 | |
11 | 11 | ||
12 | 12 | let OwnerEcoPubKey = base58'4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L' | |
13 | 13 | ||
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | - | func getKeyItem (supplier,title) = (" | |
42 | + | func getKeyItem (supplier,title) = ("tokens_Bit-CO2:_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 43 | ||
44 | 44 | ||
45 | - | func getKeyItemSupplier (item) = (item + "_ | |
45 | + | func getKeyItemSupplier (item) = (item + "_to_Amazonian_Conservation") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
49 | - | ||
50 | - | ||
51 | - | func getKeyItemQty (item) = (item + "_tok.amount") | |
52 | - | ||
53 | - | ||
54 | - | func getValueItemQty (item) = getNumberByKey(getKeyItemQty(item)) | |
55 | 49 | ||
56 | 50 | ||
57 | 51 | func getKeyBalanceQtySupplier (item) = (item + "_tokens") | |
78 | 72 | func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item)) | |
79 | 73 | ||
80 | 74 | ||
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") | |
94 | 76 | ||
95 | 77 | ||
96 | 78 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
97 | 79 | ||
98 | 80 | ||
99 | - | func getKeyBalanceSupplier (supplier) = (supplier + "_ | |
81 | + | func getKeyBalanceSupplier (supplier) = (supplier + "_waves") | |
100 | 82 | ||
101 | 83 | ||
102 | - | func getValueBalanceSupplier ( | |
84 | + | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
103 | 85 | ||
104 | 86 | ||
105 | - | func getKeyItemUser (item) = ( | |
87 | + | func getKeyItemUser (item) = ("name:_" + item) | |
106 | 88 | ||
107 | 89 | ||
108 | 90 | func getValueItemUser (item) = getStrByKey(getKeyItemUser(item)) | |
121 | 103 | ||
122 | 104 | ||
123 | 105 | @Callable(i) | |
124 | - | func AddSupplierToken (title,preIcoQty,supplierData) = { | |
106 | + | func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = { | |
125 | 107 | let supplier = toBase58String(i.caller.bytes) | |
126 | 108 | let item = getKeyItem(supplier, title) | |
127 | 109 | if ((0 >= preIcoQty)) | |
128 | 110 | 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), | |
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)]) | |
130 | 112 | } | |
131 | 113 | ||
132 | 114 | ||
133 | 115 | ||
134 | 116 | @Callable(i) | |
135 | - | func PurchaseToken (item,projectName,userData) = { | |
117 | + | func PurchaseToken (item,projectName,userData,orderQty,userDiscount) = { | |
136 | 118 | let pmt = extract(i.payment) | |
137 | 119 | if (isDefined(pmt.assetId)) | |
138 | 120 | then throw("you can adquire cBitCO2 only by Waves tokens") | |
139 | 121 | 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 | + | } | |
141 | 128 | let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) { | |
142 | 129 | case a: Int => | |
143 | 130 | a | |
145 | 132 | startQty | |
146 | 133 | } | |
147 | 134 | 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) | |
152 | 137 | if ((totalAmount > pmt.amount)) | |
153 | 138 | then throw("Payment Amount cannot be less than item Purchase Order") | |
154 | 139 | else if ((pmt.amount > totalAmount)) | |
155 | 140 | 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( | |
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)])) | |
157 | 142 | } | |
158 | 143 | } | |
159 | 144 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let aBitCO2 = base58'ETbtNp6MBuSM9EfjmLDwctrYEBBiq8CZ7ti7zbwTktry' | |
5 | 5 | ||
6 | 6 | let startQty = 332800 | |
7 | 7 | ||
8 | 8 | let nomPrice = 100000000 | |
9 | 9 | ||
10 | - | let | |
10 | + | let supplierDiscount = 12 | |
11 | 11 | ||
12 | 12 | let OwnerEcoPubKey = base58'4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L' | |
13 | 13 | ||
14 | 14 | let wvs = 100000000 | |
15 | 15 | ||
16 | 16 | let NONE = "none" | |
17 | 17 | ||
18 | 18 | let issuer = Address(base58'3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4') | |
19 | 19 | ||
20 | 20 | func getNumberByKey (key) = { | |
21 | 21 | let num = match getInteger(this, key) { | |
22 | 22 | case a: Int => | |
23 | 23 | a | |
24 | 24 | case _ => | |
25 | 25 | 0 | |
26 | 26 | } | |
27 | 27 | num | |
28 | 28 | } | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getStrByKey (key) = { | |
32 | 32 | let str = match getString(this, key) { | |
33 | 33 | case a: String => | |
34 | 34 | a | |
35 | 35 | case _ => | |
36 | 36 | NONE | |
37 | 37 | } | |
38 | 38 | str | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | - | func getKeyItem (supplier,title) = (" | |
42 | + | func getKeyItem (supplier,title) = ("tokens_Bit-CO2:_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 43 | ||
44 | 44 | ||
45 | - | func getKeyItemSupplier (item) = (item + "_ | |
45 | + | func getKeyItemSupplier (item) = (item + "_to_Amazonian_Conservation") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
49 | - | ||
50 | - | ||
51 | - | func getKeyItemQty (item) = (item + "_tok.amount") | |
52 | - | ||
53 | - | ||
54 | - | func getValueItemQty (item) = getNumberByKey(getKeyItemQty(item)) | |
55 | 49 | ||
56 | 50 | ||
57 | 51 | func getKeyBalanceQtySupplier (item) = (item + "_tokens") | |
58 | 52 | ||
59 | 53 | ||
60 | 54 | func getValueBalanceQtySupplier (item) = getNumberByKey(getKeyBalanceQtySupplier(item)) | |
61 | 55 | ||
62 | 56 | ||
63 | 57 | func getKeyItemData (item) = (item + "_description") | |
64 | 58 | ||
65 | 59 | ||
66 | 60 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
67 | 61 | ||
68 | 62 | ||
69 | 63 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
70 | 64 | ||
71 | 65 | ||
72 | 66 | func getKeyItemUserData (item) = (item + "_userdata") | |
73 | 67 | ||
74 | 68 | ||
75 | 69 | func getKeyBalanceUser (item) = (item + "_saldwvsuser") | |
76 | 70 | ||
77 | 71 | ||
78 | 72 | func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item)) | |
79 | 73 | ||
80 | 74 | ||
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") | |
94 | 76 | ||
95 | 77 | ||
96 | 78 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
97 | 79 | ||
98 | 80 | ||
99 | - | func getKeyBalanceSupplier (supplier) = (supplier + "_ | |
81 | + | func getKeyBalanceSupplier (supplier) = (supplier + "_waves") | |
100 | 82 | ||
101 | 83 | ||
102 | - | func getValueBalanceSupplier ( | |
84 | + | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
103 | 85 | ||
104 | 86 | ||
105 | - | func getKeyItemUser (item) = ( | |
87 | + | func getKeyItemUser (item) = ("name:_" + item) | |
106 | 88 | ||
107 | 89 | ||
108 | 90 | func getValueItemUser (item) = getStrByKey(getKeyItemUser(item)) | |
109 | 91 | ||
110 | 92 | ||
111 | 93 | func getKeyItemDiscountSupplier (item) = (("disc:_" + item) + "_") | |
112 | 94 | ||
113 | 95 | ||
114 | 96 | func getValueItemDiscountSupplier (item) = getNumberByKey(getKeyItemDiscountSupplier(item)) | |
115 | 97 | ||
116 | 98 | ||
117 | 99 | func getKeyItemPriceSupplier (item) = (("Nom:_" + item) + "_") | |
118 | 100 | ||
119 | 101 | ||
120 | 102 | func getValueItemPriceSupplier (item) = getNumberByKey(getKeyItemPriceSupplier(item)) | |
121 | 103 | ||
122 | 104 | ||
123 | 105 | @Callable(i) | |
124 | - | func AddSupplierToken (title,preIcoQty,supplierData) = { | |
106 | + | func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = { | |
125 | 107 | let supplier = toBase58String(i.caller.bytes) | |
126 | 108 | let item = getKeyItem(supplier, title) | |
127 | 109 | if ((0 >= preIcoQty)) | |
128 | 110 | 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), | |
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)]) | |
130 | 112 | } | |
131 | 113 | ||
132 | 114 | ||
133 | 115 | ||
134 | 116 | @Callable(i) | |
135 | - | func PurchaseToken (item,projectName,userData) = { | |
117 | + | func PurchaseToken (item,projectName,userData,orderQty,userDiscount) = { | |
136 | 118 | let pmt = extract(i.payment) | |
137 | 119 | if (isDefined(pmt.assetId)) | |
138 | 120 | then throw("you can adquire cBitCO2 only by Waves tokens") | |
139 | 121 | 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 | + | } | |
141 | 128 | let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) { | |
142 | 129 | case a: Int => | |
143 | 130 | a | |
144 | 131 | case _ => | |
145 | 132 | startQty | |
146 | 133 | } | |
147 | 134 | 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) | |
152 | 137 | if ((totalAmount > pmt.amount)) | |
153 | 138 | then throw("Payment Amount cannot be less than item Purchase Order") | |
154 | 139 | else if ((pmt.amount > totalAmount)) | |
155 | 140 | 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( | |
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)])) | |
157 | 142 | } | |
158 | 143 | } | |
159 | 144 | ||
160 | 145 | ||
161 | 146 | @Verifier(tx) | |
162 | 147 | func verify () = match tx { | |
163 | 148 | case t: SetScriptTransaction => | |
164 | 149 | sigVerify(tx.bodyBytes, tx.proofs[0], OwnerEcoPubKey) | |
165 | 150 | case d: DataTransaction => | |
166 | 151 | true | |
167 | 152 | case tx: TransferTransaction => | |
168 | 153 | true | |
169 | 154 | case tx: ExchangeTransaction => | |
170 | 155 | let withWaves = if (!(isDefined(tx.sellOrder.assetPair.priceAsset))) | |
171 | 156 | then true | |
172 | 157 | else !(isDefined(tx.sellOrder.assetPair.amountAsset)) | |
173 | 158 | withWaves | |
174 | 159 | case c: InvokeScriptTransaction => | |
175 | 160 | true | |
176 | 161 | case _ => | |
177 | 162 | false | |
178 | 163 | } | |
179 | 164 |
github/deemru/w8io/026f985 43.90 ms ◑