tx · DGC7cEkmnc1dYgewuqYXVUBW9auUXZaAkvDsz737TNnL 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4: -0.01400000 Waves 2020.03.11 16:23 [904550] smart account 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4 > SELF 0.00000000 Waves
{ "type": 13, "id": "DGC7cEkmnc1dYgewuqYXVUBW9auUXZaAkvDsz737TNnL", "fee": 1400000, "feeAssetId": null, "timestamp": 1583932967768, "version": 1, "sender": "3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4", "senderPublicKey": "4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L", "proofs": [ "3qkDmgbpNtN7kQ4ccQdHooom7LSbwx7vnKT2fW6F5zdKtgBQVwTH1hM5aNPLjxmQ9buixxwQJryodtdizUKk1nmF" ], "script": "base64:AAIDAAAAAAAAABMIARIGCgQIAQEIEgcKBQgICAEBAAAAHwAAAAAHYUJpdENPMgEAAAAgx/h6AJ03UJ8qMmy7JIhz3VjOE4OL3ofCGi0oG2fBKJYAAAAACHN0YXJ0UXR5AAAAAAAABRQAAAAAAAhub21QcmljZQAAAAAABfXhAAAAAAAQc3VwcGxpZXJEaXNjb3VudAAAAAAAAAAADAAAAAAOT3duZXJFY29QdWJLZXkBAAAAIC70W6NACRoO8DcwW0R46ze+bNGLr0tg3cAkNP8WNkAfAAAAAAN3dnMAAAAAAAX14QAAAAAABE5PTkUCAAAABG5vbmUAAAAABmlzc3VlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMr3Oz7nL9FV4g+t+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0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d25lckVjb1B1YktleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAATVHJhbnNmZXJUcmFuc2FjdGlvbgQAAAACdHgFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNFeGNoYW5nZVRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAQAAAAJd2l0aFdhdmVzAwkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQgICAUAAAACdHgAAAAJc2VsbE9yZGVyAAAACWFzc2V0UGFpcgAAAApwcmljZUFzc2V0BgkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQgICAUAAAACdHgAAAAJc2VsbE9yZGVyAAAACWFzc2V0UGFpcgAAAAthbW91bnRBc3NldAUAAAAJd2l0aFdhdmVzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgQAAAABYwUAAAAHJG1hdGNoMAYHD9nYfw==", "chainId": 84, "height": 904550, "spentComplexity": 0 } View: original | compacted Prev: GzUhnRSKqKamEgmQ5JBDYvTWGESPFpUEB7wrxrgar7R7 Next: D7zSmUFNJtAR5gmtTPhRHwB7rL2Y9ecmzVadDw4ZJRWD Diff:
Old | New | Differences | |
---|---|---|---|
78 | 78 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
79 | 79 | ||
80 | 80 | ||
81 | - | func getKeyBalanceSupplier (supplier) = "_ | |
81 | + | func getKeyBalanceSupplier (supplier) = (supplier + "Seller_Balance:_waves") | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
108 | 108 | let item = getKeyItem(supplier, title) | |
109 | 109 | if ((0 >= preIcoQty)) | |
110 | 110 | then throw("Sorry, insufficient token offer") | |
111 | - | 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) | |
111 | + | 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)]) | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
144 | 144 | then throw("Payment Amount cannot be less than item Purchase Order") | |
145 | 145 | else if ((pmt.amount > totalAmount)) | |
146 | 146 | then throw("Payment Amount can't be higher than item Purchase Order") | |
147 | - | 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( | |
147 | + | 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(nil)) | |
148 | 148 | } | |
149 | 149 | } | |
150 | 150 |
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 getKeyBalanceUser (item) = (item + "_saldwvsuser") | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getValueBalanceUser (item) = getNumberByKey(getKeyBalanceUser(item)) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func getKeyItemUserOrderQty (item) = "_tokens" | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
79 | 79 | ||
80 | 80 | ||
81 | - | func getKeyBalanceSupplier (supplier) = "_ | |
81 | + | func getKeyBalanceSupplier (supplier) = (supplier + "Seller_Balance:_waves") | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func getKeyItemUser (item) = "Project_name:" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func getValueItemUser (item) = getStrByKey(getKeyItemUser(item)) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func getKeyItemDiscountSupplier (item) = "_%" | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func getValueItemDiscountSupplier (item) = getNumberByKey(getKeyItemDiscountSupplier(item)) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | func getKeyItemPriceSupplier (item) = "_waves" | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func getValueItemPriceSupplier (item) = getNumberByKey(getKeyItemPriceSupplier(item)) | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func AddSupplierToken (title,preIcoQty,supplierDiscount,supplierData) = { | |
107 | 107 | let supplier = toBase58String(i.caller.bytes) | |
108 | 108 | let item = getKeyItem(supplier, title) | |
109 | 109 | if ((0 >= preIcoQty)) | |
110 | 110 | then throw("Sorry, insufficient token offer") | |
111 | - | 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) | |
111 | + | 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)]) | |
112 | 112 | } | |
113 | 113 | ||
114 | 114 | ||
115 | 115 | ||
116 | 116 | @Callable(i) | |
117 | 117 | func PurchaseToken (item,projectName,userData,orderQty,userDiscount) = { | |
118 | 118 | let pmt = extract(i.payment) | |
119 | 119 | if (isDefined(pmt.assetId)) | |
120 | 120 | then throw("you can adquire cBitCO2 only by Waves tokens") | |
121 | 121 | else { | |
122 | 122 | let supplier = match getString(this, getKeyItemSupplier(item)) { | |
123 | 123 | case a: String => | |
124 | 124 | a | |
125 | 125 | case _ => | |
126 | 126 | NONE | |
127 | 127 | } | |
128 | 128 | let preIcoQty = match getInteger(this, getKeyBalanceQtySupplier(item)) { | |
129 | 129 | case a: Int => | |
130 | 130 | a | |
131 | 131 | case _ => | |
132 | 132 | startQty | |
133 | 133 | } | |
134 | 134 | let balanceSupplier = match getInteger(this, getKeyBalanceSupplier(supplier)) { | |
135 | 135 | case a: Int => | |
136 | 136 | a | |
137 | 137 | case _ => | |
138 | 138 | 0 | |
139 | 139 | } | |
140 | 140 | let userAddress = toBase58String(i.caller.bytes) | |
141 | 141 | let buyerTokenPrice = ((nomPrice * (100 - userDiscount)) / 100) | |
142 | 142 | let totalAmount = (orderQty * buyerTokenPrice) | |
143 | 143 | if ((totalAmount > pmt.amount)) | |
144 | 144 | then throw("Payment Amount cannot be less than item Purchase Order") | |
145 | 145 | else if ((pmt.amount > totalAmount)) | |
146 | 146 | then throw("Payment Amount can't be higher than item Purchase Order") | |
147 | - | 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( | |
147 | + | 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(nil)) | |
148 | 148 | } | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | @Verifier(tx) | |
153 | 153 | func verify () = match tx { | |
154 | 154 | case t: SetScriptTransaction => | |
155 | 155 | sigVerify(tx.bodyBytes, tx.proofs[0], OwnerEcoPubKey) | |
156 | 156 | case d: DataTransaction => | |
157 | 157 | true | |
158 | 158 | case tx: TransferTransaction => | |
159 | 159 | true | |
160 | 160 | case tx: ExchangeTransaction => | |
161 | 161 | let withWaves = if (!(isDefined(tx.sellOrder.assetPair.priceAsset))) | |
162 | 162 | then true | |
163 | 163 | else !(isDefined(tx.sellOrder.assetPair.amountAsset)) | |
164 | 164 | withWaves | |
165 | 165 | case c: InvokeScriptTransaction => | |
166 | 166 | true | |
167 | 167 | case _ => | |
168 | 168 | false | |
169 | 169 | } | |
170 | 170 |
github/deemru/w8io/026f985 39.30 ms ◑