tx · 92F7uHhM4VbWxqVmF26NimdPQmy4uiPSTsN1VsaJDRA7 3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ: -0.05000000 Waves 2019.09.08 16:51 [667180] smart account 3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ > SELF 0.00000000 Waves
{ "type": 13, "id": "92F7uHhM4VbWxqVmF26NimdPQmy4uiPSTsN1VsaJDRA7", "fee": 5000000, "feeAssetId": null, "timestamp": 1567950774252, "version": 1, "sender": "3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ", "senderPublicKey": "3bC9HyDT8KaxdVq6EzZLqW53SX9MrALqoWf8zBXEBc2R", "proofs": [ "2zPsy4sVewixEunbJFpb7KkfW37bGdSW2GtGW1JcpjNmtCfP654fkpVZpAehMiDUyq3hbj17YzhFyNUQ5EMeYgPg" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAAARob3VyCQAAaAAAAAIAAAAAAAAAADwAAAAAAAAAADwAAAAAEXN0YXJ2ZVRvRGVhdGhUaW1lCQAAaAAAAAIJAABoAAAAAgUAAAAEaG91cgAAAAAAAAAAGAAAAAAAAAAABwAAAAAMYmFua0NvbnRyYWN0CQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNON3FRNGFkazY4czJjcVJuVXpIRlJQUUIySlgxQ1B4aGNOAAAAAA9mZWVkaW5nQ29udHJhY3QJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM043cVE0YWRrNjhzMmNxUm5VekhGUlBRQjJKWDFDUHhoY04AAAAACXBpZ2d5QmFuawkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjY0dFo0N1JhNFB3OXVGQ1hIeWFITVF6bkJyUXZ4ZzRzQQAAAAAEdHlwZQIAAAADQ2F0AQAAABJub3JtYWxpemVUaW1lc3RhbXAAAAABAAAACXRpbWVzdGFtcAMJA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3VmaWNpZW50IGFtb3VudCBvZiBXYXZlcyB0byBmZWVkIHRoZSBjcmVhdHVyZQQAAAAJdGltZXN0YW1wCQEAAAADbWF4AAAAAgUAAAAQY3VycmVudFRpbWVzdGFtcAUAAAAUbGFzdEZlZWRpbmdUaW1lc3RhbXAJAQAAAAxTY3JpcHRSZXN1bHQAAAACCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAxsYXN0X2ZlZWRpbmcJAQAAABJub3JtYWxpemVUaW1lc3RhbXAAAAABBQAAAAl0aW1lc3RhbXAFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADBQAAAAxiYW5rQ29udHJhY3QIBQAAAANwbXQAAAAGYW1vdW50BQAAAAR1bml0BQAAAANuaWwAAAAA9ARxYA==", "chainId": 84, "height": 667180, "spentComplexity": 0 } View: original | compacted Prev: Fc2HWrNA4vU9CPPcmQBW7LRGTxftYfjJfUreiHC9JLks Next: none Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | @Callable(i) | |
27 | 27 | func feed () = { | |
28 | 28 | let pmt = extract(i.payment) | |
29 | - | let currentTimestamp = | |
29 | + | let currentTimestamp = lastBlock.timestamp | |
30 | 30 | let lastFeedingTimestamp = match getInteger(this, "last_feeding") { | |
31 | 31 | case t: Int => | |
32 | 32 | t |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let hour = (60 * 60) | |
5 | 5 | ||
6 | 6 | let starveToDeathTime = ((hour * 24) * 7) | |
7 | 7 | ||
8 | 8 | let bankContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN") | |
9 | 9 | ||
10 | 10 | let feedingContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN") | |
11 | 11 | ||
12 | 12 | let piggyBank = addressFromStringValue("3N64tZ47Ra4Pw9uFCXHyaHMQznBrQvxg4sA") | |
13 | 13 | ||
14 | 14 | let type = "Cat" | |
15 | 15 | ||
16 | 16 | func normalizeTimestamp (timestamp) = if ((timestamp > starveToDeathTime)) | |
17 | 17 | then starveToDeathTime | |
18 | 18 | else timestamp | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func max (a,b) = if ((a > b)) | |
22 | 22 | then a | |
23 | 23 | else b | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | @Callable(i) | |
27 | 27 | func feed () = { | |
28 | 28 | let pmt = extract(i.payment) | |
29 | - | let currentTimestamp = | |
29 | + | let currentTimestamp = lastBlock.timestamp | |
30 | 30 | let lastFeedingTimestamp = match getInteger(this, "last_feeding") { | |
31 | 31 | case t: Int => | |
32 | 32 | t | |
33 | 33 | case _ => | |
34 | 34 | (currentTimestamp + (starveToDeathTime / 2)) | |
35 | 35 | } | |
36 | 36 | if ((currentTimestamp > (lastFeedingTimestamp + starveToDeathTime))) | |
37 | 37 | then throw("The creature is dead =(") | |
38 | 38 | else if (isDefined(pmt.assetId)) | |
39 | 39 | then TransferSet([ScriptTransfer(piggyBank, pmt.amount, pmt.assetId)]) | |
40 | 40 | else { | |
41 | 41 | let feedingPrice = 100000 | |
42 | 42 | if ((feedingPrice > pmt.amount)) | |
43 | 43 | then throw("Insuficient amount of Waves to feed the creature") | |
44 | 44 | else { | |
45 | 45 | let timestamp = max(currentTimestamp, lastFeedingTimestamp) | |
46 | 46 | ScriptResult(WriteSet([DataEntry("last_feeding", normalizeTimestamp(timestamp))]), TransferSet([ScriptTransfer(bankContract, pmt.amount, unit)])) | |
47 | 47 | } | |
48 | 48 | } | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 |
github/deemru/w8io/169f3d6 34.07 ms ◑