tx · GzUhnRSKqKamEgmQ5JBDYvTWGESPFpUEB7wrxrgar7R7 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4: -0.01400000 Waves 2020.03.11 16:08 [904536] smart account 3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4 > SELF 0.00000000 Waves
{ "type": 13, "id": "GzUhnRSKqKamEgmQ5JBDYvTWGESPFpUEB7wrxrgar7R7", "fee": 1400000, "feeAssetId": null, "timestamp": 1583932095358, "version": 1, "sender": "3N8RGScPyKYySaXd5Z3VcpnttH2uBeMpSy4", "senderPublicKey": "4AHsCbS9QYVdKNvxrPWwsMwwy3KqXaCMXeAscExJZk9L", "proofs": [ "3eZdLhBk7uzo7nvQnnVXzyNQjY2axdr8cJMcJCAuUt6DroCQ9vE52xN2bQh9FYZa1B2t8jyyNLjAPTARpFw2Hxx9" ], "script": "base64:AAIDAAAAAAAAABMIARIGCgQIAQEIEgcKBQgICAEBAAAAHwAAAAAHYUJpdENPMgEAAAAgx/h6AJ03UJ8qMmy7JIhz3VjOE4OL3ofCGi0oG2fBKJYAAAAACHN0YXJ0UXR5AAAAAAAABRQAAAAAAAhub21QcmljZQAAAAAABfXhAAAAAAAQc3VwcGxpZXJEaXNjb3VudAAAAAAAAAAADAAAAAAOT3duZXJFY29QdWJLZXkBAAAAIC70W6NACRoO8DcwW0R46ze+bNGLr0tg3cAkNP8WNkAfAAAAAAN3dnMAAAAAAAX14QAAAAAABE5PTkUCAAAABG5vbmUAAAAABmlzc3VlcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVMr3Oz7nL9FV4g+t+EWzLN77jdANRWt9bwEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAA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wkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADk93bmVyRWNvUHViS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAJ0eAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE0V4Y2hhbmdlVHJhbnNhY3Rpb24EAAAAAnR4BQAAAAckbWF0Y2gwBAAAAAl3aXRoV2F2ZXMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCAgIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAACnByaWNlQXNzZXQGCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCAgIBQAAAAJ0eAAAAAlzZWxsT3JkZXIAAAAJYXNzZXRQYWlyAAAAC2Ftb3VudEFzc2V0BQAAAAl3aXRoV2F2ZXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAAFjBQAAAAckbWF0Y2gwBgfgPpXg", "chainId": 84, "height": 904536, "spentComplexity": 0 } View: original | compacted Prev: 7mw5vsdXj73gTVNyZeM4ZFna6FopDruE9Nnf1T4LqHFQ Next: DGC7cEkmnc1dYgewuqYXVUBW9auUXZaAkvDsz737TNnL Diff:
Old | New | Differences | |
---|---|---|---|
78 | 78 | func getValueItemUserOrderQty (item) = getNumberByKey(getKeyItemUserOrderQty(item)) | |
79 | 79 | ||
80 | 80 | ||
81 | - | func getKeyBalanceSupplier (supplier) = | |
81 | + | func getKeyBalanceSupplier (supplier) = "_balance_del_Seller,_waves" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
85 | 85 | ||
86 | 86 | ||
87 | - | func getKeyItemUser (item) = "Project_name: | |
87 | + | func getKeyItemUser (item) = "Project_name:" | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func getValueItemUser (item) = getStrByKey(getKeyItemUser(item)) | |
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(("Saldo | |
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(("Saldo:_" + 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) = "_balance_del_Seller,_waves" | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueBalanceSupplier (supplier) = getNumberByKey(getKeyBalanceSupplier(supplier)) | |
85 | 85 | ||
86 | 86 | ||
87 | - | func getKeyItemUser (item) = "Project_name: | |
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 | 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), DataEntry(("Saldo/Balance_Supplier,_waves:_" + getKeyBalanceSupplier(supplier)), 0)]) | |
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(("Saldo | |
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(("Saldo:_" + 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/169f3d6 40.07 ms ◑