tx · 5q2uHhyUo3db3yprrkoeKnrfNFvbNodv1wPBrzq33FeB 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy: -0.01000000 Waves 2022.11.05 20:58 [2304135] smart account 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy > SELF 0.00000000 Waves
{ "type": 13, "id": "5q2uHhyUo3db3yprrkoeKnrfNFvbNodv1wPBrzq33FeB", "fee": 1000000, "feeAssetId": null, "timestamp": 1667671109514, "version": 2, "chainId": 84, "sender": "3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy", "senderPublicKey": "65hdh3BQVcB4NhB1URp1RBWMK7AWDhrCSVjwbFjS64jo", "proofs": [ "3sSfxFHNRC3wrAe31YMjRGMJyg33UxheNeVomWpoukTpwhdMdqRJxvUvoUjcTokWYq23A6zSfwFdDWQDFz9vkUqF" ], "script": "base64:AAIFAAAAAAAAAAsIAhIDCgEIEgASAAAAAAUAAAAACXByZWNpc2lvbgAN4Lazp2QAAAEAAAATa2V5TWFuYWdlclB1YmxpY0tleQAAAAAJAAQiAAAAAQIAAAAQbWFuYWdlclB1YmxpY0tleQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAAEAAAAByRtYXRjaDAJAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwCQACWQAAAAEFAAAAAXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQFAAAABHVuaXQJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IBAAAAC211c3RNYW5hZ2VyAAAAAQAAAAFpBAAAAAJwZAkAAAIAAAABAgAAABFwZXJtaXNzaW9uIGRlbmllZAQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9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dBbW91bnQFAAAAA25pbAkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABAgAAAAdsZWFzZUlkBQAAAANuaWwEAAAAB3Jlc3VsdHMJAARMAAAAAgkBAAAAC0xlYXNlQ2FuY2VsAAAAAQUAAAAHbGVhc2VJZAkABEwAAAACCQEAAAAEQnVybgAAAAIFAAAADXNXYXZlc0Fzc2V0SWQIBQAAAAdwYXltZW50AAAABmFtb3VudAkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAACnRvVHJhbnNmZXIFAAAABHVuaXQFAAAAA25pbAkABE4AAAACBQAAAAdyZXN1bHRzBQAAAAxsZWFzZVJlc3VsdHMAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAACQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tlea/QT5A=", "height": 2304135, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: 7GwfEHQ37WfsNB7QZi1QFpLFnvB4RrC7fekWsta2BZ6s Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let precision = 1000000000000000000 | |
5 | + | ||
6 | + | func keyManagerPublicKey () = getString("managerPublicKey") | |
7 | + | ||
8 | + | ||
9 | + | func managerPublicKeyOrUnit () = match keyManagerPublicKey() { | |
10 | + | case s: String => | |
11 | + | fromBase58String(s) | |
12 | + | case _: Unit => | |
13 | + | unit | |
14 | + | case _ => | |
15 | + | throw("Match error") | |
16 | + | } | |
17 | + | ||
18 | + | ||
19 | + | func mustManager (i) = { | |
20 | + | let pd = throw("permission denied") | |
21 | + | match managerPublicKeyOrUnit() { | |
22 | + | case pk: ByteVector => | |
23 | + | if ((i.callerPublicKey == pk)) | |
24 | + | then true | |
25 | + | else pd | |
26 | + | case _: Unit => | |
27 | + | if ((i.caller == this)) | |
28 | + | then true | |
29 | + | else pd | |
30 | + | case _ => | |
31 | + | throw("Match error") | |
32 | + | } | |
33 | + | } | |
34 | + | ||
35 | + | ||
36 | + | func mustNotInited () = match getBoolean("inited") { | |
37 | + | case inited: Boolean => | |
38 | + | if ((inited == false)) | |
39 | + | then true | |
40 | + | else throw("Already inited") | |
41 | + | case _: Unit => | |
42 | + | false | |
43 | + | case _ => | |
44 | + | throw("Match error") | |
45 | + | } | |
46 | + | ||
47 | + | ||
48 | + | @Callable(i) | |
49 | + | func init (leaserAddress) = { | |
50 | + | let checks = [mustManager(i), mustNotInited()] | |
51 | + | if ((checks == checks)) | |
52 | + | then { | |
53 | + | let sWaves = Issue("sWaves", "", 0, 8, true, unit, 0) | |
54 | + | let sWavesAssetId = calculateAssetId(sWaves) | |
55 | + | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(sWavesAssetId)), StringEntry("leaserAddress", leaserAddress), IntegerEntry("ratio", precision), IntegerEntry("leasedAmount", 0), sWaves] | |
56 | + | } | |
57 | + | else throw("Strict value is not equal to itself.") | |
58 | + | } | |
59 | + | ||
60 | + | ||
61 | + | ||
62 | + | @Callable(i) | |
63 | + | func stake () = { | |
64 | + | let payment = i.payments[0] | |
65 | + | if ((payment.assetId != unit)) | |
66 | + | then throw("Only WAVES supported") | |
67 | + | else if ((size(i.payments) != 1)) | |
68 | + | then throw("Wrong payments amount") | |
69 | + | else { | |
70 | + | let ratio = getIntegerValue("ratio") | |
71 | + | let toReissue = fraction(payment.amount, precision, ratio) | |
72 | + | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
73 | + | let leasedAmount = getIntegerValue("leasedAmount") | |
74 | + | let newAmount = (leasedAmount + payment.amount) | |
75 | + | let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress"))) | |
76 | + | let lease = Lease(leaserAddress, newAmount) | |
77 | + | let newLeaseId = calculateLeaseId(lease) | |
78 | + | let results = [BinaryEntry("leaseId", newLeaseId), lease, IntegerEntry("leasedAmount", newAmount), Reissue(sWavesAssetId, toReissue, true), ScriptTransfer(i.caller, toReissue, sWavesAssetId)] | |
79 | + | match getBinary("leaseId") { | |
80 | + | case leaseId: ByteVector => | |
81 | + | LeaseCancel(leaseId) :: results | |
82 | + | case _: Unit => | |
83 | + | results | |
84 | + | case _ => | |
85 | + | throw("Match error") | |
86 | + | } | |
87 | + | } | |
88 | + | } | |
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func unstake () = { | |
94 | + | let payment = i.payments[0] | |
95 | + | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
96 | + | if ((payment.assetId != sWavesAssetId)) | |
97 | + | then throw("Only sWAVES supported") | |
98 | + | else if ((size(i.payments) != 1)) | |
99 | + | then throw("Wrong payments amount") | |
100 | + | else { | |
101 | + | let ratio = getIntegerValue("ratio") | |
102 | + | let toTransfer = fraction(payment.amount, ratio, precision) | |
103 | + | let assetId = getStringValue("internalAssetId") | |
104 | + | let leasedAmount = getIntegerValue("leasedAmount") | |
105 | + | let newAmount = (leasedAmount - toTransfer) | |
106 | + | let leaseId = getBinaryValue("leaseId") | |
107 | + | let leaseResults = if ((newAmount > 0)) | |
108 | + | then { | |
109 | + | let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress"))) | |
110 | + | let lease = Lease(leaserAddress, newAmount) | |
111 | + | let newLeaseId = calculateLeaseId(lease) | |
112 | + | [lease, BinaryEntry("leaseId", newLeaseId), IntegerEntry("leasedAmount", newAmount)] | |
113 | + | } | |
114 | + | else [DeleteEntry("leaseId")] | |
115 | + | let results = [LeaseCancel(leaseId), Burn(sWavesAssetId, payment.amount), ScriptTransfer(i.caller, toTransfer, unit)] | |
116 | + | (results ++ leaseResults) | |
117 | + | } | |
118 | + | } | |
119 | + | ||
120 | + | ||
121 | + | @Verifier(tx) | |
122 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
123 | + |
github/deemru/w8io/03bedc9 39.87 ms ◑![]()