tx · Bihh7Yu559spo8de7b7pN28cane1t4brkzhxpHWrppZR 3MxcEvh1oziDB1AcWLPVecfXxgo8PwvWRaF: -0.01000000 Waves 2019.08.24 09:58 [644883] smart account 3MxcEvh1oziDB1AcWLPVecfXxgo8PwvWRaF > SELF 0.00000000 Waves
{ "type": 13, "id": "Bihh7Yu559spo8de7b7pN28cane1t4brkzhxpHWrppZR", "fee": 1000000, "feeAssetId": null, "timestamp": 1566629937727, "version": 1, "sender": "3MxcEvh1oziDB1AcWLPVecfXxgo8PwvWRaF", "senderPublicKey": "9kwXs4HqgYj1bZUfGfQxnpcfNwMePWAqKBDqpMwcUPsP", "proofs": [ "4oB2sTwMq5r7tmvCA21BbYDpThxZ9nWVrFsZoQweXLgfax5RgZk91ncNFXoS8aWCy5EBjaJnxA293KgXnL6GAAJs" ], "script": "base64:AAIDAAAAAAAAAAAAAAAAAAAABAAAAAFpAQAAAA1hcHByb3ZlQ3JlZGl0AAAABAAAAAZjbGllbnQAAAAGYW1vdW50AAAABnRhcmdldAAAAAhsb2NrSGFzaAMDCQAAAAAAAAIFAAAABHRoaXMIBQAAAAFpAAAABmNhbGxlcgkBAAAAASEAAAABCQEAAAAJaXNEZWZpbmVkAAAAAQkABBsAAAACBQAAAAR0aGlzCQABLAAAAAIFAAAABmNsaWVudAIAAAAHX3N0YXR1cwcJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGY2xpZW50AgAAAAdfc3RhdHVzAgAAAAhhcHByb3ZlZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZjbGllbnQCAAAAB19hbW91bnQFAAAABmFtb3VudAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZjbGllbnQCAAAAB190YXJnZXQFAAAABnRhcmdldAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkAASwAAAACBQAAAAZjbGllbn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Rpb24EAAAAAXQFAAAAByRtYXRjaDAHAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAcJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5vFl39w==", "chainId": 84, "height": 644883, "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 19.36 ms ◑