tx · AXTkw6VvDUd4QUXxQnx6sdrBpHqHarBNn8gD2SA7zbxi 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4: -0.01400000 Waves 2020.03.14 14:28 [908802] smart account 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4 > SELF 0.00000000 Waves
{ "type": 13, "id": "AXTkw6VvDUd4QUXxQnx6sdrBpHqHarBNn8gD2SA7zbxi", "fee": 1400000, "feeAssetId": null, "timestamp": 1584185303590, "version": 1, "sender": "3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4", "senderPublicKey": "4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L", "proofs": [ "2x2NLoMxHgK3gTnxkJswKDjvYZXBjSXdM33JcQ12RcZ2aDN4g6pNZeBFEMmUdvQetn53Bm8Qs8wQtdrtdzg5wsAa" ], "script": "base64:AAIDAAAAAAAAABMIARIGCgQIAQEIEgcKBQgICAEBAAAAHQAAAAAHYUJpdENPMgEAAAAgx/h6AJ03UJ8qMmy7JIhz3VjOE4OL3ofCGi0oG2fBKJYAAAAACHN0YXJ0UXR5AAAAAAAABRQAAAAAAAhub21QcmljZQAAAAAABfXhAAAAAAAQc3VwcGxpZXJEaXNjb3VudAAAAAAAAAAADAAAAAAOT3duZXJFY29QdWJLZXkBAAAAIC70W6NACRoO8DcwW0R46ze+bNGLr0tg3cAkNP8WNkAfAAAAAAN3dnMAAAAAAAX14QAAAAAABE5PTkUCAAAABG5vbmUAAAAABmlzc3VlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMr3Oz7nL9FV4g+t+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BA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AAAHJG1hdGNoMAIAAAAXSW52b2tlU2NyaXB0VHJhbnNhY3Rpb24EAAAAAWMFAAAAByRtYXRjaDAGB6K4lXQ=", "chainId": 84, "height": 908802, "spentComplexity": 0 } View: original | compacted Prev: FjHrTUeTBVtd8d51Uo6NSBhru8fgRdHosCPMKozSxPoV Next: 77irqrcJnUgULEFERuPLsfLGVETj4E6jwF5ZaSduQJZp Diff:
Old | New | Differences | |
---|---|---|---|
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | - | func | |
111 | + | func purchase (item,projectName,userData,userDiscount,orderQty) = { | |
112 | 112 | let pmt = extract(i.payment) | |
113 | 113 | if (isDefined(pmt.assetId)) | |
114 | 114 | then throw("you can adquire cBitCO2 only by Waves tokens") | |
138 | 138 | then throw("Payment Amount cannot be less than item Purchase Order") | |
139 | 139 | else if ((pmt.amount > totalAmount)) | |
140 | 140 | then throw("Payment Amount can't be higher than item Purchase Order") | |
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(("Request_Status:_" + userAddress), "confirmed"), DataEntry(getKeyBalanceQtySupplier(item), (preIcoQty - orderQty)), DataEntry(getKeyBalanceSupplier(supplier), (balanceSupplier + pmt.amount))]), TransferSet( | |
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(("Request_Status:_" + userAddress), "confirmed"), DataEntry(getKeyBalanceQtySupplier(item), (preIcoQty - orderQty)), DataEntry(getKeyBalanceSupplier(supplier), (balanceSupplier + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderQty, aBitCO2)])) | |
142 | 142 | } | |
143 | 143 | } | |
144 | 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 | 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 | 42 | func getKeyItem (supplier,title) = ("tokens_Bit-CO2:_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getKeyItemSupplier (item) = (item + "_to_Amazonian_Conservation") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getKeyBalanceQtySupplier (item) = "Tokens_ofertados,_Saldo" | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getValueBalanceQtySupplier (item) = getNumberByKey(getKeyBalanceQtySupplier(item)) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getKeyItemData (item) = (item + "_description") | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getKeyItemUserData (item) = "_userdata" | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func getKeyItemUserOrderQty (item) = "_tokens" | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func getKeyBalanceSupplier (supplier) = "Seller_Balance:_waves" | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func getKeyItemUser (item) = "Project_name:" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueItemUser (item) = getStrByKey(getKeyItemUser(item)) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func getKeyItemDiscountSupplier (item) = "_%" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func getValueItemDiscountSupplier (item) = getNumberByKey(getKeyItemDiscountSupplier(item)) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func getKeyItemPriceSupplier (item) = "_waves" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func getValueItemPriceSupplier (item) = getNumberByKey(getKeyItemPriceSupplier(item)) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | @Callable(i) | |
100 | 100 | func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = { | |
101 | 101 | let supplier = toBase58String(i.caller.bytes) | |
102 | 102 | let item = getKeyItem(supplier, title) | |
103 | 103 | if ((0 >= preIcoQty)) | |
104 | 104 | then throw("Sorry, insufficient token offer") | |
105 | 105 | else WriteSet([DataEntry(("Ofertante:_" + getKeyItemSupplier(item)), supplier), DataEntry(getKeyBalanceQtySupplier(item), preIcoQty), DataEntry(("Precio_Nominal:" + getKeyItemPriceSupplier(item)), nomPrice), DataEntry(("Max_Descuento_ofrecido:" + getKeyItemDiscountSupplier(item)), supplierDiscount), DataEntry(getKeyItemData(item), supplierData)]) | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | ||
110 | 110 | @Callable(i) | |
111 | - | func | |
111 | + | func purchase (item,projectName,userData,userDiscount,orderQty) = { | |
112 | 112 | let pmt = extract(i.payment) | |
113 | 113 | if (isDefined(pmt.assetId)) | |
114 | 114 | then throw("you can adquire cBitCO2 only by Waves tokens") | |
115 | 115 | else { | |
116 | 116 | let supplier = match getString(this, getKeyItemSupplier(item)) { | |
117 | 117 | case a: String => | |
118 | 118 | a | |
119 | 119 | case _ => | |
120 | 120 | NONE | |
121 | 121 | } | |
122 | 122 | let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) { | |
123 | 123 | case a: Int => | |
124 | 124 | a | |
125 | 125 | case _ => | |
126 | 126 | startQty | |
127 | 127 | } | |
128 | 128 | let balanceSupplier = match getInteger(this, getKeyBalanceSupplier(supplier)) { | |
129 | 129 | case a: Int => | |
130 | 130 | a | |
131 | 131 | case _ => | |
132 | 132 | 0 | |
133 | 133 | } | |
134 | 134 | let userAddress = toBase58String(i.caller.bytes) | |
135 | 135 | let buyerTokenPrice = ((nomPrice * (100 - userDiscount)) / 100) | |
136 | 136 | let totalAmount = (orderQty * buyerTokenPrice) | |
137 | 137 | if ((totalAmount > pmt.amount)) | |
138 | 138 | then throw("Payment Amount cannot be less than item Purchase Order") | |
139 | 139 | else if ((pmt.amount > totalAmount)) | |
140 | 140 | then throw("Payment Amount can't be higher than item Purchase Order") | |
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(("Request_Status:_" + userAddress), "confirmed"), DataEntry(getKeyBalanceQtySupplier(item), (preIcoQty - orderQty)), DataEntry(getKeyBalanceSupplier(supplier), (balanceSupplier + pmt.amount))]), TransferSet( | |
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(("Request_Status:_" + userAddress), "confirmed"), DataEntry(getKeyBalanceQtySupplier(item), (preIcoQty - orderQty)), DataEntry(getKeyBalanceSupplier(supplier), (balanceSupplier + pmt.amount))]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), orderQty, aBitCO2)])) | |
142 | 142 | } | |
143 | 143 | } | |
144 | 144 | ||
145 | 145 | ||
146 | 146 | @Verifier(tx) | |
147 | 147 | func verify () = match tx { | |
148 | 148 | case t: SetScriptTransaction => | |
149 | 149 | sigVerify(tx.bodyBytes, tx.proofs[0], OwnerEcoPubKey) | |
150 | 150 | case d: DataTransaction => | |
151 | 151 | true | |
152 | 152 | case tx: TransferTransaction => | |
153 | 153 | let recipient = toBase58String(addressFromRecipient(tx.recipient).bytes) | |
154 | 154 | if ((tx.sender == issuer)) | |
155 | 155 | then true | |
156 | 156 | else throw("You can't transferred this token") | |
157 | 157 | case tx: ExchangeTransaction => | |
158 | 158 | let withWaves = if (!(isDefined(tx.sellOrder.assetPair.priceAsset))) | |
159 | 159 | then true | |
160 | 160 | else !(isDefined(tx.sellOrder.assetPair.amountAsset)) | |
161 | 161 | withWaves | |
162 | 162 | case tx: ExchangeTransaction => | |
163 | 163 | let pk = tx.proofs[1] | |
164 | 164 | let address = addressFromPublicKey(pk) | |
165 | 165 | let fee = 1400000 | |
166 | 166 | let hasMoney = ((wavesBalance(address) - fee) >= tx.buyOrder.price) | |
167 | 167 | let sell = sigVerify(tx.sellOrder.bodyBytes, tx.sellOrder.proofs[0], tx.sellOrder.senderPublicKey) | |
168 | 168 | let buy = sigVerify(tx.buyOrder.bodyBytes, tx.buyOrder.proofs[0], tx.buyOrder.senderPublicKey) | |
169 | 169 | let sellOrderSender = toBase58String(tx.sellOrder.sender.bytes) | |
170 | 170 | let minAmount = 1 | |
171 | 171 | let maxAmount = 4 | |
172 | 172 | let maxPrice = (maxAmount * nomPrice) | |
173 | 173 | if (if (buy) | |
174 | 174 | then if (isDefined((maxPrice >= tx.buyOrder.price))) | |
175 | 175 | then true | |
176 | 176 | else throw("El monto a pagar no puede ser menor que el precio de venta") | |
177 | 177 | else false) | |
178 | 178 | then true | |
179 | 179 | else if (sell) | |
180 | 180 | then if (if (if ((tx.sellOrder.sender == issuer)) | |
181 | 181 | then (tx.amount >= minAmount) | |
182 | 182 | else false) | |
183 | 183 | then (maxAmount >= tx.amount) | |
184 | 184 | else false) | |
185 | 185 | then true | |
186 | 186 | else throw("Error: Minimum amount: 1 aBitCO2; Maximum amount offered: 4 aBitCO2 by User Account") | |
187 | 187 | else false | |
188 | 188 | case c: InvokeScriptTransaction => | |
189 | 189 | true | |
190 | 190 | case _ => | |
191 | 191 | false | |
192 | 192 | } | |
193 | 193 |
github/deemru/w8io/169f3d6 50.66 ms ◑