tx · 32bGMyh6btapbAUA1FeQPzu4KqsZgr81Xwa1Co9M3Kke 3Mv4H5twpgbPnLpYvSYtiwbf3ky1C9c4pw5: -0.01400000 Waves 2019.09.08 09:57 [666779] smart account 3Mv4H5twpgbPnLpYvSYtiwbf3ky1C9c4pw5 > SELF 0.00000000 Waves
{ "type": 13, "id": "32bGMyh6btapbAUA1FeQPzu4KqsZgr81Xwa1Co9M3Kke", "fee": 1400000, "feeAssetId": null, "timestamp": 1567925819555, "version": 1, "sender": "3Mv4H5twpgbPnLpYvSYtiwbf3ky1C9c4pw5", "senderPublicKey": "75PRzdQQhQEXWVqPWuMDCNUu45GYvXBFpdMNXyGbb1dR", "proofs": [ "47WekLiGBDhoagcMMv1ZzcxirHZZxqD77eGPBdkC3SG7Aq18ETDmSXTrz3o1CaTP9H5phRaJxsVRDKp7gpZumjWp" ], "script": "base64:AAIDAAAAAAAAAAAAAAADAQAAAAtpc0FjdGl2YXRlZAAAAAAEAAAABHVzZXIJAQAAABFAZXh0ck5hdGl2ZSgxMDUzKQAAAAIFAAAABHRoaXMCAAAABHVzZXIJAQAAAAIhPQAAAAIFAAAABHVzZXICAAAAAAEAAAAQdmVyaWZ5TWluRGVwb3NpdAAAAAAEAAAAB2RlcG9zaXQJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAB2RlcG9zaXQEAAAADnByaWNlUGVyTWludXRlCQEAAAARQGV4dHJOYXRpdmUoMTA1MCkAAAACBQAAAAR0aGlzAgAAAA5wcmljZVBlck1pbnV0ZQQAAAALbWluaW11bVRpbWUJAQAAABFAZXh0ck5hdGl2ZSgxMDUwKQAAAAIFAAAABHRoaXMCAAAAC01pbmltdW1UaW1lCQAAZgAAAAIJAABpAAAAAgUAAAAHZGVwb3NpdAUAAAAOcHJpY2VQZXJNaW51dGUFAAAAC21pbmltdW1UaW1lAQAAABBpc1RpbWVMb2NrT3BlbmVkAAAAAQAAAAtjdXJyZW50VGltZQQAAAAJdG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L7bCa Next: 9JWgcizDBnrYncy83gUMeAuVDH7WHrMAwBw744L7bNdG Diff:
Old | New | Differences | |
---|---|---|---|
24 | 24 | ||
25 | 25 | ||
26 | 26 | @Callable(i) | |
27 | - | func init () = if (if ((i.caller == this)) | |
27 | + | func init () = if (if ((Address(i.caller.bytes) == this)) | |
28 | 28 | then !(isDefined(getInteger(this, "pricePerMinute"))) | |
29 | 29 | else false) | |
30 | 30 | then WriteSet([DataEntry("pricePerMinute", 10000000), DataEntry("user", ""), DataEntry("timestart", ""), DataEntry("deposit", 0), DataEntry("withDrawAddress", "")]) |
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 () = { | |
11 | 11 | let deposit = getIntegerValue(this, "deposit") | |
12 | 12 | let pricePerMinute = getIntegerValue(this, "pricePerMinute") | |
13 | 13 | let minimumTime = getIntegerValue(this, "MinimumTime") | |
14 | 14 | ((deposit / pricePerMinute) > minimumTime) | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func isTimeLockOpened (currentTime) = { | |
19 | 19 | let timestart = getIntegerValue(this, "timestart") | |
20 | 20 | let pricePerMinute = getIntegerValue(this, "pricePerMinute") | |
21 | 21 | let deposit = getIntegerValue(this, "deposit") | |
22 | 22 | ((currentTime - timestart) > (deposit / pricePerMinute)) | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | @Callable(i) | |
27 | - | func init () = if (if ((i.caller == this)) | |
27 | + | func init () = if (if ((Address(i.caller.bytes) == this)) | |
28 | 28 | then !(isDefined(getInteger(this, "pricePerMinute"))) | |
29 | 29 | else false) | |
30 | 30 | then WriteSet([DataEntry("pricePerMinute", 10000000), DataEntry("user", ""), DataEntry("timestart", ""), DataEntry("deposit", 0), DataEntry("withDrawAddress", "")]) | |
31 | 31 | else throw("contract is already inited") | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | ||
35 | 35 | @Callable(i) | |
36 | 36 | func activate (deposit,userPk) = if (isActivated()) | |
37 | 37 | then throw("The scooter is already activated") | |
38 | 38 | else if (!(verifyMinDeposit())) | |
39 | 39 | then throw("Your deposit should be for 30 minutes minimum") | |
40 | 40 | else WriteSet([DataEntry("deposit", deposit), DataEntry("user", userPk), DataEntry("timestart", lastBlock.timestamp)]) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func payAndStop (amount) = { | |
46 | 46 | let userAddress = addressFromPublicKey(toBytes(getStringValue(this, "user"))) | |
47 | 47 | let withDrawalAddress = getStringValue(this, "withdrawal") | |
48 | 48 | let deposit = getIntegerValue(this, "deposit") | |
49 | 49 | let remainder = (deposit - amount) | |
50 | 50 | if ((i.caller == userAddress)) | |
51 | 51 | then TransferSet([ScriptTransfer(userAddress, remainder, unit), ScriptTransfer(Address(toBytes(withDrawalAddress)), amount, unit)]) | |
52 | 52 | else throw("not the adress of the renter") | |
53 | 53 | } | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | 57 | @Callable(i) | |
58 | 58 | func withdraw () = if (if (isTimeLockOpened(lastBlock.timestamp)) | |
59 | 59 | then (this == i.caller) | |
60 | 60 | else false) | |
61 | 61 | then { | |
62 | 62 | let deposit = getIntegerValue(this, "deposit") | |
63 | 63 | ScriptResult(WriteSet([DataEntry("deposit", 0), DataEntry("user", ""), DataEntry("timestart", "")]), TransferSet([ScriptTransfer(Address(toBytes(getStringValue(this, "withDrawalAddress"))), deposit, unit)])) | |
64 | 64 | } | |
65 | 65 | else throw("withdraw rejected because timelock is still active") | |
66 | 66 | ||
67 | 67 | ||
68 | 68 | @Verifier(tx) | |
69 | 69 | func verify () = true | |
70 | 70 |
github/deemru/w8io/169f3d6 35.82 ms ◑