tx · EgKs4AaKg79xcC5qaAqcTQ8WwAZk8vHZsCXKXeUuvagp 3Mx9FcvbywzbM3uTGL1ocnC6Yz4LwG6VNnQ: -0.01400000 Waves 2020.09.23 08:24 [1189522] smart account 3Mx9FcvbywzbM3uTGL1ocnC6Yz4LwG6VNnQ > SELF 0.00000000 Waves
{ "type": 13, "id": "EgKs4AaKg79xcC5qaAqcTQ8WwAZk8vHZsCXKXeUuvagp", "fee": 1400000, "feeAssetId": null, "timestamp": 1600838706918, "version": 2, "chainId": 84, "sender": "3Mx9FcvbywzbM3uTGL1ocnC6Yz4LwG6VNnQ", "senderPublicKey": "3rxJnS9mVKpfLXyuwkosSTVgnu1cZ6cGj1WTVNqrhcyd", "proofs": [ "64uq5XUDTqkFXwCgHe6nXNv8f9MiVYrwmHp7S6BZcWF2mDM7qWBdA39WBEhe697atUwkRGvorK7UxngRU29YzHF5" ], "script": "base64:AAIEAAAAAAAAACEIAhIECgIIARIDCgEIEgMKAQgSBAoCCAgSBQoDCAgIEgAAAAAHAAAAAAZMRVNTT04BAAAAIOjnSHw4js1vrbOhaypqBgUMh7yKo+Dj/vvXlCSDAODpAAAAAARQQVI3AQAAACDOWED9mOK0xZN34xzFUmgrQZwssasR1XxpyjfnkulHjAAAAAAUbGVzc29uQ29hY2hQdWJsaWNLZXkBAAAAIJEV1LNN0Z9m46J3ebNUFkD8Hn3i3U/7YD3XLgZSbu1vAAAAAAdwZW5kaW5nAAAAAAAAAAAAAAAAAAVzdGFydAAAAAAAAAAAAQAAAAADZW5kAAAAAAAAAAACAAAAAAxwYXltZW50VG9rZW4FAAAABFBBUjcAAAAGAAAAAWkBAAAAEWlzc3VlTGVzc29uVGlja2V0AAAAAgAAAARqc29uAAAABXByaWNlBAAAAANwbXQJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAADCQEAAAACIT0AAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAABkxFU1NPTgkAAAIAAAABAgAAABZ3b3Jr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YAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwQAAAANY3VycmVudEFtb3VudAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAAhvd25lcktleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAAAwkAAGYAAAACAAAAAAAAAAAABQAAAA1jdXJyZW50QW1vdW50CQAAAgAAAAECAAAAHkNhbid0IHdpdGhkcmF3IG5lZ2F0aXZlIGFtb3VudAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgUAAAAIb3duZXJLZXkAAAAAAAAAAAAJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAA1jdXJyZW50QW1vdW50BQAAAARQQVI3BQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleRuW9DA=", "height": 1189522, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5N4w5gAVo7s6RBj4c3LihKgx1UtnPL9h7FPx8EAZP1E3 Next: Ad9jxEXHCKN4xK8n3HBp6vLCFVbGuH4q1LZ5jzGuJHYu Diff:
Old | New | Differences | |
---|---|---|---|
127 | 127 | case _ => | |
128 | 128 | 0 | |
129 | 129 | } | |
130 | - | let lessonPaymentAmount = (lessonFeeCurrentAmount | |
130 | + | let lessonPaymentAmount = (lessonFeeCurrentAmount * ticketPriceCurrentAmount) | |
131 | 131 | let ownerKey = ("owner_balance_" + toBase58String(i.caller.bytes)) | |
132 | 132 | let ownerAmount = match getInteger(this, ownerKey) { | |
133 | 133 | case a: Int => |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let LESSON = base58'GgA8mL3SEYvuhYoZFd418Li4bqXAasGbYCKJshTt2MGU' | |
5 | 5 | ||
6 | 6 | let PAR7 = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
7 | 7 | ||
8 | 8 | let lessonCoachPublicKey = base58'AmMRZeqDosA2ygpV6GTCJrK3KVvrf4ST7ECPj9pub4mU' | |
9 | 9 | ||
10 | 10 | let pending = 0 | |
11 | 11 | ||
12 | 12 | let start = 1 | |
13 | 13 | ||
14 | 14 | let end = 2 | |
15 | 15 | ||
16 | 16 | let paymentToken = PAR7 | |
17 | 17 | ||
18 | 18 | @Callable(i) | |
19 | 19 | func issueLessonTicket (json,price) = { | |
20 | 20 | let pmt = i.payments[0] | |
21 | 21 | if ((pmt.assetId != LESSON)) | |
22 | 22 | then throw("works with LESSON only") | |
23 | 23 | else { | |
24 | 24 | let issueCurrentKey = "issueNumber" | |
25 | 25 | let issueCurrentNumber = match getInteger(this, issueCurrentKey) { | |
26 | 26 | case a: Int => | |
27 | 27 | a | |
28 | 28 | case _ => | |
29 | 29 | 0 | |
30 | 30 | } | |
31 | 31 | let newIssueNumber = (issueCurrentNumber + 1) | |
32 | 32 | let newIssueNumberString = toString(newIssueNumber) | |
33 | 33 | let ticketDetailsCurrentKey = (("TICKET_" + newIssueNumberString) + "_details") | |
34 | 34 | let ticketPriceCurrentKey = (("TICKET_" + newIssueNumberString) + "_price") | |
35 | 35 | let ticketBalanceCurrentKey = (("TICKET_" + newIssueNumberString) + "_balance") | |
36 | 36 | let ticketBalanceCurrentAmount = match getInteger(this, ticketBalanceCurrentKey) { | |
37 | 37 | case a: Int => | |
38 | 38 | a | |
39 | 39 | case _ => | |
40 | 40 | 0 | |
41 | 41 | } | |
42 | 42 | let newTicketBalanceAmount = (ticketBalanceCurrentAmount + pmt.amount) | |
43 | 43 | [IntegerEntry(ticketPriceCurrentKey, price), IntegerEntry(issueCurrentKey, newIssueNumber), StringEntry(ticketDetailsCurrentKey, json), IntegerEntry(ticketBalanceCurrentKey, newTicketBalanceAmount)] | |
44 | 44 | } | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | ||
49 | 49 | @Callable(i) | |
50 | 50 | func buyTicket (ticketNumber) = { | |
51 | 51 | let pmt = i.payments[0] | |
52 | 52 | let ticketPriceCurrentKey = (("TICKET_" + ticketNumber) + "_price") | |
53 | 53 | let ticketPriceCurrentAmount = match getInteger(this, ticketPriceCurrentKey) { | |
54 | 54 | case a: Int => | |
55 | 55 | a | |
56 | 56 | case _ => | |
57 | 57 | 0 | |
58 | 58 | } | |
59 | 59 | let ticketPrice = ticketPriceCurrentAmount | |
60 | 60 | let rateAmount = (pmt.amount / ticketPrice) | |
61 | 61 | if ((pmt.assetId != paymentToken)) | |
62 | 62 | then throw("works with PAR7 only") | |
63 | 63 | else { | |
64 | 64 | let buyCurrentKey = ("buy_" + toBase58String(i.caller.bytes)) | |
65 | 65 | let buyCurrentAmount = match getInteger(this, buyCurrentKey) { | |
66 | 66 | case a: Int => | |
67 | 67 | a | |
68 | 68 | case _ => | |
69 | 69 | 0 | |
70 | 70 | } | |
71 | 71 | let buyNewAmount = (buyCurrentAmount + rateAmount) | |
72 | 72 | let ticketBalanceCurrentKey = (("TICKET_" + ticketNumber) + "_balance") | |
73 | 73 | let ticketBalanceCurrentAmount = match getInteger(this, ticketBalanceCurrentKey) { | |
74 | 74 | case a: Int => | |
75 | 75 | a | |
76 | 76 | case _ => | |
77 | 77 | 0 | |
78 | 78 | } | |
79 | 79 | let newTicketBalanceAmount = (ticketBalanceCurrentAmount - rateAmount) | |
80 | 80 | [IntegerEntry(buyCurrentKey, buyNewAmount), IntegerEntry(ticketBalanceCurrentKey, newTicketBalanceAmount), ScriptTransfer(i.caller, rateAmount, LESSON)] | |
81 | 81 | } | |
82 | 82 | } | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | ||
86 | 86 | @Callable(i) | |
87 | 87 | func lessonSubscription (lessonId) = { | |
88 | 88 | let pmt = i.payments[0] | |
89 | 89 | let pmtId = pmt.assetId | |
90 | 90 | let studentAddress = toBase58String(i.caller.bytes) | |
91 | 91 | let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress) | |
92 | 92 | let lessonFeeCurrentKey = ((("payment_" + lessonId) + "_") + studentAddress) | |
93 | 93 | let lessonFeeCurrentAmount = match getInteger(this, lessonFeeCurrentKey) { | |
94 | 94 | case a: Int => | |
95 | 95 | a | |
96 | 96 | case _ => | |
97 | 97 | 0 | |
98 | 98 | } | |
99 | 99 | let ticketNewAmount = (lessonFeeCurrentAmount + pmt.amount) | |
100 | 100 | [IntegerEntry(lessonStatusCurrentKey, pending), IntegerEntry(lessonFeeCurrentKey, ticketNewAmount)] | |
101 | 101 | } | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func lessonStart (lessonId,studentAddress) = { | |
107 | 107 | let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress) | |
108 | 108 | [IntegerEntry(lessonStatusCurrentKey, start)] | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | @Callable(i) | |
114 | 114 | func lessonFinish (lessonId,studentAddress,ticketNumber) = { | |
115 | 115 | let ticketId = toBase58String(value(LESSON)) | |
116 | 116 | let lessonFeeCurrentKey = ((("payment_" + lessonId) + "_") + studentAddress) | |
117 | 117 | let lessonFeeCurrentAmount = match getInteger(this, lessonFeeCurrentKey) { | |
118 | 118 | case a: Int => | |
119 | 119 | a | |
120 | 120 | case _ => | |
121 | 121 | 0 | |
122 | 122 | } | |
123 | 123 | let ticketPriceCurrentKey = (("TICKET_" + ticketNumber) + "_price") | |
124 | 124 | let ticketPriceCurrentAmount = match getInteger(this, ticketPriceCurrentKey) { | |
125 | 125 | case a: Int => | |
126 | 126 | a | |
127 | 127 | case _ => | |
128 | 128 | 0 | |
129 | 129 | } | |
130 | - | let lessonPaymentAmount = (lessonFeeCurrentAmount | |
130 | + | let lessonPaymentAmount = (lessonFeeCurrentAmount * ticketPriceCurrentAmount) | |
131 | 131 | let ownerKey = ("owner_balance_" + toBase58String(i.caller.bytes)) | |
132 | 132 | let ownerAmount = match getInteger(this, ownerKey) { | |
133 | 133 | case a: Int => | |
134 | 134 | a | |
135 | 135 | case _ => | |
136 | 136 | 0 | |
137 | 137 | } | |
138 | 138 | let newOwnerAmount = (ownerAmount + lessonPaymentAmount) | |
139 | 139 | let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress) | |
140 | 140 | let ticketCurrentKey = ((ticketId + "_") + studentAddress) | |
141 | 141 | let ticketCurrentAmount = match getInteger(this, ticketCurrentKey) { | |
142 | 142 | case a: Int => | |
143 | 143 | a | |
144 | 144 | case _ => | |
145 | 145 | 0 | |
146 | 146 | } | |
147 | 147 | let ticket = fromBase58String(ticketId) | |
148 | 148 | [IntegerEntry(ownerKey, newOwnerAmount), IntegerEntry(lessonStatusCurrentKey, end), Burn(LESSON, lessonFeeCurrentAmount)] | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | ||
153 | 153 | @Callable(i) | |
154 | 154 | func ownerWithdraw () = { | |
155 | 155 | let ownerKey = toBase58String(i.caller.bytes) | |
156 | 156 | let currentAmount = match getInteger(this, ownerKey) { | |
157 | 157 | case a: Int => | |
158 | 158 | a | |
159 | 159 | case _ => | |
160 | 160 | 0 | |
161 | 161 | } | |
162 | 162 | if ((0 > currentAmount)) | |
163 | 163 | then throw("Can't withdraw negative amount") | |
164 | 164 | else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, currentAmount, PAR7)] | |
165 | 165 | } | |
166 | 166 | ||
167 | 167 | ||
168 | 168 | @Verifier(tx) | |
169 | 169 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
170 | 170 |
github/deemru/w8io/169f3d6 40.86 ms ◑