tx · 3qdYSrekJpjh5vFcBepDAe5TAfkPg2B3JncpvnyV7yjp 3N8j9eAYBv8qa4q2UggwvykZmfN9sLaEyGQ: -0.01400000 Waves 2019.11.03 13:57 [748599] smart account 3N8j9eAYBv8qa4q2UggwvykZmfN9sLaEyGQ > SELF 0.00000000 Waves
{ "type": 13, "id": "3qdYSrekJpjh5vFcBepDAe5TAfkPg2B3JncpvnyV7yjp", "fee": 1400000, "feeAssetId": null, "timestamp": 1572778686685, "version": 1, "sender": "3N8j9eAYBv8qa4q2UggwvykZmfN9sLaEyGQ", "senderPublicKey": "4z5JAqGUwcJ6TdnmG41r6Xg519kD5pris4PbjmX5ipAx", "proofs": [ "2YXrooyiVWBg6wHF57Bd4TKSxbVAcUUhu9hGEcejyLL8z4U3BjJ8zuGjmLdeYxgcAeG1QnoRCUoLwRaAUP8HTYUU" ], "script": "base64:AAIDAAAAAAAAAA0IARIAEgASAwoBARIAAAAAAwEAAAALaXNBY3RpdmF0ZWQAAAAABAAAAAR1c2VyCQEAAAARQGV4dHJOYXRpdmUoMTA1MykAAAACBQAAAAR0aGlzAgAAAAR1c2VyCQEAAAACIT0AAAACBQAAAAR1c2VyAgAAAAABAAAAEHZlcmlmeU1pbkRlcG9zaXQAAAABAAAAB2RlcG9zaXQEAAAADnByaWNlUGVyTWludXRlCQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAA5wcmljZVBlck1pbnV0ZQQAAAALbWluaW11bVRpbWUJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAC21pbmltdW1UaW1lCQAAZgAAAAIJAABpAAAAAgUAAAAHZGVwb3NpdAUAAAAOcHJpY2VQZXJNaW51dGUFAAAAC21pbmltdW1UaW1lAQAAABBpc1RpbWVMb2NrT3BlbmVkAAAAAQAAAAtjdXJyZW50VGltZQQAAAAJdGltZXN0YXJ0CQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0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AOKK1+A==", "chainId": 84, "height": 748599, "spentComplexity": 0 } View: original | compacted Prev: 9dtMXz9HTpnNMMoweJeDmFGxAUz2pAp6kCZdi9zMZAkB Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func isActivated () = { | |
5 | 5 | let user = getStringValue(this, "user") | |
6 | 6 | (user != "") | |
7 | 7 | } | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func verifyMinDeposit (deposit) = { | |
11 | 11 | let pricePerMinute = getIntegerValue(this, "pricePerMinute") | |
12 | 12 | let minimumTime = getIntegerValue(this, "minimumTime") | |
13 | 13 | ((deposit / pricePerMinute) > minimumTime) | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func isTimeLockOpened (currentTime) = { | |
18 | 18 | let timestart = getIntegerValue(this, "timestart") | |
19 | 19 | let pricePerMinute = getIntegerValue(this, "pricePerMinute") | |
20 | 20 | let deposit = getIntegerValue(this, "deposit") | |
21 | 21 | ((currentTime - timestart) > (deposit / pricePerMinute)) | |
22 | 22 | } | |
23 | 23 | ||
24 | 24 | ||
25 | 25 | @Callable(i) | |
26 | 26 | func init () = if (if ((this == i.caller)) | |
27 | 27 | then !(isDefined(getInteger(this, "pricePerMinute"))) | |
28 | 28 | else false) | |
29 | 29 | then WriteSet([DataEntry("minimumTime", 30), DataEntry("pricePerMinute", 1), DataEntry("user", ""), DataEntry("timestart", ""), DataEntry("deposit", 0), DataEntry("withDrawAddress", "3N5KacfEg3N5155jWmxVY39rpdox566YxXa")]) | |
30 | 30 | else throw("contract is already inited") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | ||
34 | 34 | @Callable(i) | |
35 | 35 | func activate () = { | |
36 | 36 | let pmt = extract(i.payment) | |
37 | 37 | if (isActivated()) | |
38 | 38 | then throw("The scooter is already activated") | |
39 | 39 | else if (!(verifyMinDeposit(pmt.amount))) | |
40 | 40 | then throw("Your deposit should be for 30 minutes minimum") | |
41 | 41 | else WriteSet([DataEntry("deposit", pmt.amount), DataEntry("user", toBase58String(i.callerPublicKey)), DataEntry("timestart", lastBlock.timestamp)]) | |
42 | 42 | } | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | ||
46 | 46 | @Callable(i) | |
47 | 47 | func payAndStop (amount) = { | |
48 | 48 | let userAddress = value(addressFromPublicKey(fromBase58String(getStringValue(this, "user")))) | |
49 | 49 | let withDrawalAddress = getStringValue(this, "withDrawAddress") | |
50 | 50 | let deposit = getIntegerValue(this, "deposit") | |
51 | 51 | let remainder = (deposit - amount) | |
52 | 52 | if ((i.caller == userAddress)) | |
53 | 53 | then TransferSet([ScriptTransfer(userAddress, remainder, unit), ScriptTransfer(Address(fromBase58String(withDrawalAddress)), amount, unit)]) | |
54 | 54 | else throw("not the adress of the renter") | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | ||
59 | 59 | @Callable(i) | |
60 | 60 | func withdraw () = if (if (isTimeLockOpened(lastBlock.timestamp)) | |
61 | 61 | then (this == i.caller) | |
62 | 62 | else false) | |
63 | 63 | then { | |
64 | 64 | let deposit = getIntegerValue(this, "deposit") | |
65 | 65 | ScriptResult(WriteSet([DataEntry("deposit", 0), DataEntry("user", ""), DataEntry("timestart", "")]), TransferSet([ScriptTransfer(Address(toBytes(getStringValue(this, "withDrawAddress"))), deposit, unit)])) | |
66 | 66 | } | |
67 | 67 | else throw("withdraw rejected because timelock is still active") | |
68 | 68 | ||
69 | 69 |
github/deemru/w8io/169f3d6 61.39 ms ◑