tx · D4VzLGoy2d8t3R5TvEnwibtatYSRbBmDwocAg5WCRH3g

3MzSDS8RibXCsWMkKxfdYVrehLeKAbNAARn:  -0.01000000 Waves

2020.09.23 09:13 [1189569] smart account 3MzSDS8RibXCsWMkKxfdYVrehLeKAbNAARn > SELF 0.00000000 Waves

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

github/deemru/w8io/026f985 
20.88 ms