tx · 556En4i6UP5gtpxpfpAraCRYzB8Qtw7eUm2p6PT2R7nn 3N1GFqbTMvLWDwx9UGw93Csxe4d6PxSGP3a: -0.07000000 Waves 2020.03.16 11:01 [911534] smart account 3N1GFqbTMvLWDwx9UGw93Csxe4d6PxSGP3a > SELF 0.00000000 Waves
{ "type": 13, "id": "556En4i6UP5gtpxpfpAraCRYzB8Qtw7eUm2p6PT2R7nn", "fee": 7000000, "feeAssetId": null, "timestamp": 1584345716387, "version": 1, "sender": "3N1GFqbTMvLWDwx9UGw93Csxe4d6PxSGP3a", "senderPublicKey": "A55HbjC3kNmKc5YREN4cDWUL4VpR92UFktxoHu3DvNDm", "proofs": [ "5nH96rrPiWYMemd94Shvr57bGQqHAyJvGB3rXJrRCoB9Mz6QjWQxBrNrbwyiAjex71LfKyJxT83xKsKKqyDAN25g" ], "script": "base64:AAIDAAAAAAAAABAIARIGCgQIAQECEgASABIAAAAAAAAAAAQAAAABaQEAAAANYXBwcm92ZUNyZWRpdAAAAAQAAAAGY2xpZW50AAAABmFtb3VudAAAAAZ0YXJnZXQAAAAIbG9ja0hhc2gDAwkAAAAAAAACBQAAAAR0aGlzCAUAAAABaQAAAAZjYWxsZXIJAQAAAAEhAAAAAQkBAAAACWlzRGVmaW5lZAAAAAEJAAQbAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAAZjbGllbnQCAAAAB19zdGF0dXMHCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAABmNsaWVudAIAAAAHX3N0YXR1cwIAAAAIYXBwcm92ZWQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGY2xpZW50AgAAAAdfYW1vdW50BQAAAAZhbW91bnQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGY2xpZW50AgAAAAdfdGFyZ2V0BQAAAAZ0YXJnZXQJAARMAAAAAgkBAAAACURh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ckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAF0BQAAAAckbWF0Y2gwBwMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDAHCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleRS4c0k=", "chainId": 84, "height": 911534, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | ||
5 | + | ||
6 | + | @Callable(i) | |
7 | + | func approveCredit (client,amount,target,lockHash) = if (if ((this == i.caller)) | |
8 | + | then !(isDefined(getBoolean(this, (client + "_status")))) | |
9 | + | else false) | |
10 | + | then WriteSet([DataEntry((client + "_status"), "approved"), DataEntry((client + "_amount"), amount), DataEntry((client + "_target"), target), DataEntry((client + "_lockScriptId"), lockHash)]) | |
11 | + | else throw((("Credit for " + client) + " has already been approved or caller is not dApp owner")) | |
12 | + | ||
13 | + | ||
14 | + | ||
15 | + | @Callable(i) | |
16 | + | func getMoney () = { | |
17 | + | let callerStr = toBase58String(i.caller.bytes) | |
18 | + | let status = match getString(this, (callerStr + "_status")) { | |
19 | + | case x: Unit => | |
20 | + | "unset" | |
21 | + | case x: String => | |
22 | + | x | |
23 | + | case _ => | |
24 | + | throw() | |
25 | + | } | |
26 | + | let lockTxId = extract(getString(this, (callerStr + "_lockScriptId"))) | |
27 | + | let lockTx = transactionHeightById(fromBase58String(lockTxId)) | |
28 | + | let isLockSet = match lockTx { | |
29 | + | case t: Int => | |
30 | + | true | |
31 | + | case _ => | |
32 | + | throw("Lock has not been set") | |
33 | + | } | |
34 | + | let amount = extract(getInteger(this, (callerStr + "_amount"))) | |
35 | + | if (if ((status == "approved")) | |
36 | + | then isLockSet | |
37 | + | else false) | |
38 | + | then ScriptResult(WriteSet([DataEntry((callerStr + "_status"), "borrowed")]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) | |
39 | + | else throw("Credit was not approved or money has already been taken") | |
40 | + | } | |
41 | + | ||
42 | + | ||
43 | + | ||
44 | + | @Callable(i) | |
45 | + | func returnMoney () = { | |
46 | + | let callerStr = toBase58String(i.caller.bytes) | |
47 | + | let status = match getString(this, (callerStr + "_status")) { | |
48 | + | case x: Unit => | |
49 | + | "unset" | |
50 | + | case x: String => | |
51 | + | x | |
52 | + | case _ => | |
53 | + | throw() | |
54 | + | } | |
55 | + | let pmt = extract(i.payment) | |
56 | + | let amountToReturn = getInteger(this, (callerStr + "_amount")) | |
57 | + | if ((status != "borrowed")) | |
58 | + | then throw("Cannot return, nothing was borrowed") | |
59 | + | else if (isDefined(pmt.assetId)) | |
60 | + | then throw("Can return only WAVES at the moment") | |
61 | + | else if ((amountToReturn != pmt.amount)) | |
62 | + | then throw("Should return borrowed amount") | |
63 | + | else WriteSet([DataEntry((callerStr + "_status"), "returned")]) | |
64 | + | } | |
65 | + | ||
66 | + | ||
67 | + | ||
68 | + | @Callable(i) | |
69 | + | func cancelContract () = { | |
70 | + | let callerStr = toBase58String(i.caller.bytes) | |
71 | + | let status = match getString(this, (callerStr + "_status")) { | |
72 | + | case x: Unit => | |
73 | + | "unset" | |
74 | + | case x: String => | |
75 | + | x | |
76 | + | case _ => | |
77 | + | throw() | |
78 | + | } | |
79 | + | if (if ((status == "approved")) | |
80 | + | then true | |
81 | + | else (status == "unset")) | |
82 | + | then WriteSet([DataEntry((callerStr + "_status"), "canceled")]) | |
83 | + | else throw("Cannot cancel credit. Money has already been taken") | |
84 | + | } | |
85 | + | ||
86 | + | ||
87 | + | @Verifier(tx) | |
88 | + | func verify () = match tx { | |
89 | + | case t: DataTransaction => | |
90 | + | false | |
91 | + | case t: SetScriptTransaction => | |
92 | + | false | |
93 | + | case _ => | |
94 | + | sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
95 | + | } | |
96 | + |
github/deemru/w8io/169f3d6 21.32 ms ◑