tx · 6GZCrvWEsrpCLjbiqyrwTyVpoo3Sn3DwM8zsvjCmrVC5 3N72X4SpkNvXqi3ruDJgYdDmVJe8nRqj7zU: -0.01400000 Waves 2020.09.22 08:29 [1188093] smart account 3N72X4SpkNvXqi3ruDJgYdDmVJe8nRqj7zU > SELF 0.00000000 Waves
{ "type": 13, "id": "6GZCrvWEsrpCLjbiqyrwTyVpoo3Sn3DwM8zsvjCmrVC5", "fee": 1400000, "feeAssetId": null, "timestamp": 1600752600009, "version": 2, "chainId": 84, "sender": "3N72X4SpkNvXqi3ruDJgYdDmVJe8nRqj7zU", "senderPublicKey": "Ej9UfgzgHeDPtoinwmZaL71Jv5CgK2QzWZZYyQUbpByz", "proofs": [ "VLdzwPmWfYN2xSweDgBvXES2yhBYLHJ6t2tqxRmzpwMGChHqm5BNzSfRGPLMFNtR2ECVs1aMx6DTt1mobTQFrff" ], "script": "base64:AAIEAAAAAAAAAB8IAhIDCgEBEgMKAQgSBgoECAgIARIHCgUICAgBARIAAAAABgAAAAAGTEVTU09OAQAAACDo50h8OI7Nb62zoWsqagYFDIe8iqPg4/7715QkgwDg6QAAAAAEUEFSNwEAAAAgzlhA/ZjitMWTd+McxVJoK0GcLLGrEdV8aco355LpR4wAAAAAFGxlc3Nvbk93bmVyUHVibGljS2V5AQAAACDL8+i1dh5Vr1e4XeTXQeu2gcnq6/18vsaB8jf4EQnUaQAAAAAHcGVuZGluZwAAAAAAAAAAAAAAAAAFc3RhcnQAAAAAAAAAAAEAAAAAA2VuZAAAAAAAAAAAAgAAAAUAAAABaQEAAAAJYnV5VGlja2V0AAAAAQAAAApzd2FwQW1vdW50BAAAAANwbXQJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAEAAAACnJhdGVBbW91bnQJAABpAAAAAggFAAAAA3BtdAAAAAZhbW91bnQFAAAACnN3YXBBbW91bnQDCQEAAAACIT0AAAACCAUAAAADcG10AAAAB2Fzc2V0SWQFAAAABFBBUjcJAAACAA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BsZXNzb25DdXJyZW50S2V5BQAAAANlbmQJAARMAAAAAgkBAAAABEJ1cm4AAAACBQAAAAZ0aWNrZXQFAAAADHRpY2tldEFtb3VudAUAAAADbmlsAAAAAWkBAAAADW93bmVyV2l0aGRyYXcAAAAABAAAAAhvd25lcktleQkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzBAAAAA1jdXJyZW50QW1vdW50BAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAACG93bmVyS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAADCQAAZgAAAAIAAAAAAAAAAAAFAAAADWN1cnJlbnRBbW91bnQJAAACAAAAAQIAAAAeQ2FuJ3Qgd2l0aGRyYXcgbmVnYXRpdmUgYW1vdW50CQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACBQAAAAhvd25lcktleQAAAAAAAAAAAAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAADWN1cnJlbnRBbW91bnQFAAAABFBBUjcFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAABRsZXNzb25Pd25lclB1YmxpY0tleS9iq7M=", "height": 1188093, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DebXCcYaeHxKCjLPHz3tj1m8XpPey1LJVL2MLCKiRatc Next: HbtV2BCKiYaCA2pm2mHdLAevT6Gr5LsSAvLZNaSMoe8e Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let paymentAsset = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
4 | + | let LESSON = base58'GgA8mL3SEYvuhYoZFd418Li4bqXAasGbYCKJshTt2MGU' | |
5 | + | ||
6 | + | let PAR7 = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
5 | 7 | ||
6 | 8 | let lessonOwnerPublicKey = base58'Ej9UfgzgHeDPtoinwmZaL71Jv5CgK2QzWZZYyQUbpByz' | |
7 | 9 | ||
12 | 14 | let end = 2 | |
13 | 15 | ||
14 | 16 | @Callable(i) | |
15 | - | func buyTicket (swapAmount | |
17 | + | func buyTicket (swapAmount) = { | |
16 | 18 | let pmt = i.payments[0] | |
17 | - | if ((pmt.assetId != paymentAsset)) | |
18 | - | then throw("works with paymentAsset only") | |
19 | + | let rateAmount = (pmt.amount / swapAmount) | |
20 | + | if ((pmt.assetId != PAR7)) | |
21 | + | then throw("works with PAR7 only") | |
19 | 22 | else { | |
20 | 23 | let buyCurrentKey = toBase58String(i.caller.bytes) | |
21 | 24 | let buyCurrentAmount = match getInteger(this, buyCurrentKey) { | |
24 | 27 | case _ => | |
25 | 28 | 0 | |
26 | 29 | } | |
27 | - | let buyNewAmount = (buyCurrentAmount + pmt.amount) | |
28 | - | let rateAmount = (pmt.amount / swapAmount) | |
29 | - | let ticket = fromBase58String(ticketId) | |
30 | - | [IntegerEntry(buyCurrentKey, buyNewAmount), ScriptTransfer(i.caller, rateAmount, ticket)] | |
30 | + | let buyNewAmount = (buyCurrentAmount + rateAmount) | |
31 | + | [IntegerEntry(("buy_" + buyCurrentKey), buyNewAmount), ScriptTransfer(i.caller, rateAmount, LESSON)] | |
31 | 32 | } | |
32 | 33 | } | |
33 | 34 | ||
104 | 105 | } | |
105 | 106 | if ((0 > currentAmount)) | |
106 | 107 | then throw("Can't withdraw negative amount") | |
107 | - | else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, currentAmount, | |
108 | + | else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, currentAmount, PAR7)] | |
108 | 109 | } | |
109 | 110 | ||
110 | 111 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let paymentAsset = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
4 | + | let LESSON = base58'GgA8mL3SEYvuhYoZFd418Li4bqXAasGbYCKJshTt2MGU' | |
5 | + | ||
6 | + | let PAR7 = base58'EtV3CXQ4wqm28WPB1KaBv5B9ke2bpXRZMutYNEJUQcXm' | |
5 | 7 | ||
6 | 8 | let lessonOwnerPublicKey = base58'Ej9UfgzgHeDPtoinwmZaL71Jv5CgK2QzWZZYyQUbpByz' | |
7 | 9 | ||
8 | 10 | let pending = 0 | |
9 | 11 | ||
10 | 12 | let start = 1 | |
11 | 13 | ||
12 | 14 | let end = 2 | |
13 | 15 | ||
14 | 16 | @Callable(i) | |
15 | - | func buyTicket (swapAmount | |
17 | + | func buyTicket (swapAmount) = { | |
16 | 18 | let pmt = i.payments[0] | |
17 | - | if ((pmt.assetId != paymentAsset)) | |
18 | - | then throw("works with paymentAsset only") | |
19 | + | let rateAmount = (pmt.amount / swapAmount) | |
20 | + | if ((pmt.assetId != PAR7)) | |
21 | + | then throw("works with PAR7 only") | |
19 | 22 | else { | |
20 | 23 | let buyCurrentKey = toBase58String(i.caller.bytes) | |
21 | 24 | let buyCurrentAmount = match getInteger(this, buyCurrentKey) { | |
22 | 25 | case a: Int => | |
23 | 26 | a | |
24 | 27 | case _ => | |
25 | 28 | 0 | |
26 | 29 | } | |
27 | - | let buyNewAmount = (buyCurrentAmount + pmt.amount) | |
28 | - | let rateAmount = (pmt.amount / swapAmount) | |
29 | - | let ticket = fromBase58String(ticketId) | |
30 | - | [IntegerEntry(buyCurrentKey, buyNewAmount), ScriptTransfer(i.caller, rateAmount, ticket)] | |
30 | + | let buyNewAmount = (buyCurrentAmount + rateAmount) | |
31 | + | [IntegerEntry(("buy_" + buyCurrentKey), buyNewAmount), ScriptTransfer(i.caller, rateAmount, LESSON)] | |
31 | 32 | } | |
32 | 33 | } | |
33 | 34 | ||
34 | 35 | ||
35 | 36 | ||
36 | 37 | @Callable(i) | |
37 | 38 | func lessonSubscription (lessonId) = { | |
38 | 39 | let pmt = i.payments[0] | |
39 | 40 | let pmtId = pmt.assetId | |
40 | 41 | let ticketId = toBase58String(value(pmtId)) | |
41 | 42 | let studentAddress = toBase58String(i.caller.bytes) | |
42 | 43 | let lessonCurrentKey = ((lessonId + "_") + studentAddress) | |
43 | 44 | let ticketCurrentKey = ((ticketId + "_") + studentAddress) | |
44 | 45 | let ticketCurrentAmount = match getInteger(this, ticketCurrentKey) { | |
45 | 46 | case a: Int => | |
46 | 47 | a | |
47 | 48 | case _ => | |
48 | 49 | 0 | |
49 | 50 | } | |
50 | 51 | let ticketNewAmount = (ticketCurrentAmount + pmt.amount) | |
51 | 52 | [IntegerEntry(lessonCurrentKey, pending), IntegerEntry(ticketCurrentKey, ticketNewAmount)] | |
52 | 53 | } | |
53 | 54 | ||
54 | 55 | ||
55 | 56 | ||
56 | 57 | @Callable(i) | |
57 | 58 | func lessonStart (lessonID,studentAddress,ticketId,paymentAmount) = { | |
58 | 59 | let buyCurrentKey = ((ticketId + "_") + studentAddress) | |
59 | 60 | let buyCurrentAmount = match getInteger(this, buyCurrentKey) { | |
60 | 61 | case a: Int => | |
61 | 62 | a | |
62 | 63 | case _ => | |
63 | 64 | 0 | |
64 | 65 | } | |
65 | 66 | let buyNewAmount = (buyCurrentAmount - paymentAmount) | |
66 | 67 | let lessonCurrentKey = ((lessonID + "_") + studentAddress) | |
67 | 68 | [IntegerEntry(buyCurrentKey, buyNewAmount), IntegerEntry(lessonCurrentKey, start)] | |
68 | 69 | } | |
69 | 70 | ||
70 | 71 | ||
71 | 72 | ||
72 | 73 | @Callable(i) | |
73 | 74 | func lessonFinish (lessonId,ticketId,studentAddress,paymentAmount,ticketAmount) = { | |
74 | 75 | let ownerKey = toBase58String(i.caller.bytes) | |
75 | 76 | let ownerAmount = match getInteger(this, ownerKey) { | |
76 | 77 | case a: Int => | |
77 | 78 | a | |
78 | 79 | case _ => | |
79 | 80 | 0 | |
80 | 81 | } | |
81 | 82 | let newOwnerAmount = (ownerAmount + paymentAmount) | |
82 | 83 | let lessonCurrentKey = ((lessonId + "_") + studentAddress) | |
83 | 84 | let ticketCurrentKey = ((ticketId + "_") + studentAddress) | |
84 | 85 | let ticketCurrentAmount = match getInteger(this, ticketCurrentKey) { | |
85 | 86 | case a: Int => | |
86 | 87 | a | |
87 | 88 | case _ => | |
88 | 89 | 0 | |
89 | 90 | } | |
90 | 91 | let ticket = fromBase58String(ticketId) | |
91 | 92 | [IntegerEntry(ownerKey, newOwnerAmount), IntegerEntry(lessonCurrentKey, end), Burn(ticket, ticketAmount)] | |
92 | 93 | } | |
93 | 94 | ||
94 | 95 | ||
95 | 96 | ||
96 | 97 | @Callable(i) | |
97 | 98 | func ownerWithdraw () = { | |
98 | 99 | let ownerKey = toBase58String(i.caller.bytes) | |
99 | 100 | let currentAmount = match getInteger(this, ownerKey) { | |
100 | 101 | case a: Int => | |
101 | 102 | a | |
102 | 103 | case _ => | |
103 | 104 | 0 | |
104 | 105 | } | |
105 | 106 | if ((0 > currentAmount)) | |
106 | 107 | then throw("Can't withdraw negative amount") | |
107 | - | else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, currentAmount, | |
108 | + | else [IntegerEntry(ownerKey, 0), ScriptTransfer(i.caller, currentAmount, PAR7)] | |
108 | 109 | } | |
109 | 110 | ||
110 | 111 | ||
111 | 112 | @Verifier(tx) | |
112 | 113 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], lessonOwnerPublicKey) | |
113 | 114 |
github/deemru/w8io/026f985 48.36 ms ◑