tx · 8ecfM77wZvoTgzed8hBVhwA13fKrwnM1fj9GCJTsVUTA

3Muq3PfPmqEJZPqEgnocvqbiXVpv5izrANH:  -0.01000000 Waves

2020.09.29 09:59 [1198285] smart account 3Muq3PfPmqEJZPqEgnocvqbiXVpv5izrANH > SELF 0.00000000 Waves

{ "type": 13, "id": "8ecfM77wZvoTgzed8hBVhwA13fKrwnM1fj9GCJTsVUTA", "fee": 1000000, "feeAssetId": null, "timestamp": 1601362798335, "version": 2, "chainId": 84, "sender": "3Muq3PfPmqEJZPqEgnocvqbiXVpv5izrANH", "senderPublicKey": "B6uGgrCJ28ayftKQRq9UUHRHbJPnnCCdFCkgyxb1o76K", "proofs": [ "3RsN4A4cF9RhCv83qbTEYCMVVtRjr58dBZcX3sRkaNpDuDbMDrZzBxrHNEGUkcA68RMNFeiTyFZCuFvHhdreeb5a" ], "script": "base64:AAIEAAAAAAAAACIIAhIECgIIARIDCgEIEgQKAggIEgQKAggIEgUKAwgICBIAAAAACgAAAAAGTEVTU09OAQAAACDo50h8OI7Nb62zoWsqagYFDIe8iqPg4/7715QkgwDg6QAAAAAEUEFSNwEAAAAgzlhA/ZjitMWTd+McxVJoK0GcLLGrEdV8aco355LpR4wAAAAABEpQWU4BAAAAIKZMLdXcPx41+Mc+LsNVu8E7R6j/4aKvziD0vOVUnHdgAAAAAARVU0ROAQAAACAiZD8evmBG6RFqExPcpjP+Fn4H+Xfps/IV/JlJKjAKNwAAAAAHUEFSN1BBWQEAAAAgl51uEP4PAsqEAH8fboNjHhm/rGl87nuQzc5I5dIHQSMAAAAAFGxlc3Nvbk93bmVyUHVibGljS2V5AQAAACDW8r+QHNDEXX+7oojqOe4EcvIeuhvd8po2KJvI1DJFVAAAAAAHcGVuZGluZwAAAAAAAAAAAAAAAAAFc3RhcnQAAAAAAAAAAAEAAAAAA2VuZAAAAAAAAAAAAgAAAAAMcGF5bWVudFRva2VuBQAAAARQQVI3AAAABgAAAAFpAQAAABFpc3N1ZUxlc3NvblRpY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ationStatus": "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_TICKET_" + ticketNumber) + "_") + 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 userBalanceCurrentKey = ((("user_balance_TICKET_" + ticketNumber) + "_") + toBase58String(i.caller.bytes))
79+ let userBalanceAmount = match getInteger(this, userBalanceCurrentKey) {
80+ case a: Int =>
81+ a
82+ case _ =>
83+ 0
84+ }
85+ let userBalanceNewAmount = (userBalanceAmount + rateAmount)
86+ let ticketBalanceCurrentKey = (("TICKET_" + ticketNumber) + "_balance")
87+ let ticketBalanceCurrentAmount = match getInteger(this, ticketBalanceCurrentKey) {
88+ case a: Int =>
89+ a
90+ case _ =>
91+ 0
92+ }
93+ let newTicketBalanceAmount = (ticketBalanceCurrentAmount - rateAmount)
94+[IntegerEntry(buyCurrentKey, buyNewAmount), IntegerEntry(ticketBalanceCurrentKey, newTicketBalanceAmount), IntegerEntry(userBalanceCurrentKey, userBalanceNewAmount), ScriptTransfer(i.caller, rateAmount, LESSON)]
95+ }
96+ }
97+
98+
99+
100+@Callable(i)
101+func lessonSubscription (lessonId,ticketNumber) = {
102+ let pmt = i.payments[0]
103+ let pmtId = pmt.assetId
104+ let studentAddress = toBase58String(i.caller.bytes)
105+ let userBalanceCurrentKey = ((("user_balance_TICKET_" + ticketNumber) + "_") + toBase58String(i.caller.bytes))
106+ let userBalanceAmount = match getInteger(this, userBalanceCurrentKey) {
107+ case a: Int =>
108+ a
109+ case _ =>
110+ 0
111+ }
112+ let userBalanceNewAmount = (userBalanceAmount - pmt.amount)
113+ let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress)
114+ let lessonFeeCurrentKey = ((("payment_" + lessonId) + "_") + studentAddress)
115+ let lessonFeeCurrentAmount = match getInteger(this, lessonFeeCurrentKey) {
116+ case a: Int =>
117+ a
118+ case _ =>
119+ 0
120+ }
121+ let ticketNewAmount = (lessonFeeCurrentAmount + pmt.amount)
122+[IntegerEntry(userBalanceCurrentKey, userBalanceNewAmount), IntegerEntry(lessonStatusCurrentKey, pending), IntegerEntry(lessonFeeCurrentKey, ticketNewAmount)]
123+ }
124+
125+
126+
127+@Callable(i)
128+func lessonStart (lessonId,studentAddress) = {
129+ let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress)
130+[IntegerEntry(lessonStatusCurrentKey, start)]
131+ }
132+
133+
134+
135+@Callable(i)
136+func lessonFinish (lessonId,studentAddress,ticketNumber) = {
137+ let ticketId = toBase58String(value(LESSON))
138+ let lessonFeeCurrentKey = ((("payment_" + lessonId) + "_") + studentAddress)
139+ let lessonFeeCurrentAmount = match getInteger(this, lessonFeeCurrentKey) {
140+ case a: Int =>
141+ a
142+ case _ =>
143+ 0
144+ }
145+ let ticketPriceCurrentKey = (("TICKET_" + ticketNumber) + "_price")
146+ let ticketPriceCurrentAmount = match getInteger(this, ticketPriceCurrentKey) {
147+ case a: Int =>
148+ a
149+ case _ =>
150+ 0
151+ }
152+ let lessonPaymentAmount = (lessonFeeCurrentAmount * ticketPriceCurrentAmount)
153+ let ownerKey = ("owner_balance_" + toBase58String(i.caller.bytes))
154+ let ownerAmount = match getInteger(this, ownerKey) {
155+ case a: Int =>
156+ a
157+ case _ =>
158+ 0
159+ }
160+ let newOwnerAmount = (ownerAmount + lessonPaymentAmount)
161+ let lessonStatusCurrentKey = ((("status_" + lessonId) + "_") + studentAddress)
162+ let ticketCurrentKey = ((ticketId + "_") + studentAddress)
163+ let ticketCurrentAmount = match getInteger(this, ticketCurrentKey) {
164+ case a: Int =>
165+ a
166+ case _ =>
167+ 0
168+ }
169+ let ticket = fromBase58String(ticketId)
170+[IntegerEntry(ownerKey, newOwnerAmount), IntegerEntry(lessonStatusCurrentKey, end), IntegerEntry(lessonFeeCurrentKey, 0), Burn(LESSON, lessonFeeCurrentAmount)]
171+ }
172+
173+
174+
175+@Callable(i)
176+func ownerWithdraw () = {
177+ let ownerKey = ("owner_balance_" + toBase58String(i.caller.bytes))
178+ let ownerAmount = match getInteger(this, ownerKey) {
179+ case a: Int =>
180+ a
181+ case _ =>
182+ 0
183+ }
184+ if ((0 > ownerAmount))
185+ then throw("Can't withdraw negative amount")
186+ else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, ownerAmount, paymentToken)]
187+ }
188+
189+
190+@Verifier(tx)
191+func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], lessonOwnerPublicKey)
192+

github/deemru/w8io/169f3d6 
24.07 ms