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