tx · 6W9s6wUYFBTWhGghogWN3DgEwfzWgfaG5TajC1EZz9kP

3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ:  -0.05000000 Waves

2019.09.08 08:18 [666669] smart account 3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ > SELF 0.00000000 Waves

{ "type": 13, "id": "6W9s6wUYFBTWhGghogWN3DgEwfzWgfaG5TajC1EZz9kP", "fee": 5000000, "feeAssetId": null, "timestamp": 1567919956266, "version": 1, "sender": "3N7cKXykq32Xk6z4jSbECdcjyswJy84iSLZ", "senderPublicKey": "3bC9HyDT8KaxdVq6EzZLqW53SX9MrALqoWf8zBXEBc2R", "proofs": [ "5S1GsaA3QzWTm8R6DaKzaEXrhnwHhmV53DmDnXk2WqtBewzLCt9a4khfbU5NXPVKnMXNYQXxyvnwk35J9xpWcYpV" ], "script": "base64:AAIDAAAAAAAAAAAAAAAIAAAAAARob3VyCQAAaAAAAAIAAAAAAAAAADwAAAAAAAAAADwAAAAAEXN0YXJ2ZVRvRGVhdGhUaW1lCQAAaAAAAAIJAABoAAAAAgUAAAAEaG91cgAAAAAAAAAAGAAAAAAAAAAABwAAAAAMYmFua0NvbnRyYWN0CQEAAAAcQGV4dHJVc2VyKGFkZHJlc3NGcm9tU3RyaW5nKQAAAAECAAAAIzNON3FRNGFkazY4czJjcVJuVXpIRlJQUUIySlgxQ1B4aGNOAAAAAA9mZWVkaW5nQ29udHJhY3QJAQAAABxAZXh0clVzZXIoYWRkcmVzc0Zyb21TdHJpbmcpAAAAAQIAAAAjM043cVE0YWRrNjhzMmNxUm5VekhGUlBRQjJKWDFDUHhoY04AAAAACXBpZ2d5QmFuawkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABAgAAACMzTjY0dFo0N1JhNFB3OXVGQ1hIeWFITVF6bkJyUXZ4ZzRzQQAAAAAEdHlwZQIAAAADQ2F0AQAAABJub3JtYWxpemVUaW1lc3RhbXAAAAABAAAACXRpbWVzdGFtc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FAAAAA3BtdAAAAAZhbW91bnQIBQAAAANwbXQAAAAHYXNzZXRJZAUAAAADbmlsBAAAAAxmZWVkaW5nUHJpY2UAAAAAAAAPQkADCQAAZgAAAAIFAAAADGZlZWRpbmdQcmljZQgFAAAAA3BtdAAAAAZhbW91bnQJAAACAAAAAQIAAAAwSW5zdWZpY2llbnQgYW1vdW50IG9mIFdhdmVzIHRvIGZlZWQgdGhlIGNyZWF0dXJlBAAAAAl0aW1lc3RhbXAJAQAAAANtYXgAAAACBQAAABBjdXJyZW50VGltZXN0YW1wBQAAABRsYXN0RmVlZGluZ1RpbWVzdGFtcAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAADGxhc3RfZmVlZGluZwkBAAAAEm5vcm1hbGl6ZVRpbWVzdGFtcAAAAAEFAAAACXRpbWVzdGFtcAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAADGJhbmtDb250cmFjdAgFAAAAA3BtdAAAAAZhbW91bnQFAAAABHVuaXQFAAAAA25pbAAAAABUI4tj", "chainId": 84, "height": 666669, "spentComplexity": 0 } View: original | compacted Prev: HCAb1vt7VX4A19VvxNYF6TT1nVuNNEEB4qiWfGxJEipM Next: EfvCmhui79eoXCWAdHR6VQmFVBfo2sd7Rv1DLxY7Cd9J Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let hour = 1
4+let hour = (60 * 60)
55
66 let starveToDeathTime = ((hour * 24) * 7)
7+
8+let bankContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN")
79
810 let feedingContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN")
911
1113
1214 let type = "Cat"
1315
14-func isDead (id,currentBlock) = {
15- let lastFeedingBlockHeight = match getInteger(this, "last_feeding") {
16- case lf: Int =>
17- lf
18- case _ =>
19- match transactionHeightById(id) {
20- case a: Int =>
21- a
22- case _ =>
23- throw()
24- }
25- }
26- let lastFeedingBlock = match blockInfoByHeight(lastFeedingBlockHeight) {
27- case bi: BlockInfo =>
28- bi
29- case _ =>
30- throw()
31- }
32- ((lastFeedingBlock.timestamp + starveToDeathTime) >= currentBlock.timestamp)
33- }
16+func normalizeTimestamp (timestamp) = if ((timestamp > starveToDeathTime))
17+ then starveToDeathTime
18+ else timestamp
19+
20+
21+func max (a,b) = if ((a > b))
22+ then a
23+ else b
3424
3525
3626 @Callable(i)
3727 func feed () = {
3828 let pmt = extract(i.payment)
39- let currentBlockHeight = match transactionHeightById(i.transactionId) {
40- case a: Int =>
41- a
29+ let currentTimestamp = match blockInfoByHeight(extract(transactionHeightById(i.transactionId))) {
30+ case bi: BlockInfo =>
31+ bi.timestamp
4232 case _ =>
4333 throw()
4434 }
45- let currentBlock = match blockInfoByHeight(currentBlockHeight) {
46- case bi: BlockInfo =>
47- bi
35+ let lastFeedingTimestamp = match getInteger(this, "last_feeding") {
36+ case t: Int =>
37+ t
4838 case _ =>
49- throw()
39+ (currentTimestamp + (starveToDeathTime / 2))
5040 }
51- if (isDead(i.transactionId, currentBlock))
41+ if ((currentTimestamp > (lastFeedingTimestamp + starveToDeathTime)))
5242 then throw("The creature is dead =(")
5343 else if (isDefined(pmt.assetId))
5444 then TransferSet([ScriptTransfer(piggyBank, pmt.amount, pmt.assetId)])
5545 else {
56- let feedingPrice = getIntegerValue(feedingContract, ("price_" + type))
46+ let feedingPrice = 1000000
5747 if ((feedingPrice > pmt.amount))
5848 then throw("Insuficient amount of Waves to feed the creature")
5949 else {
60- let animalFund = addressFromStringValue(getStringValue(feedingContract, ("fund_" + type)))
61- ScriptResult(WriteSet([DataEntry("last_feeding", currentBlock.timestamp)]), TransferSet([ScriptTransfer(animalFund, pmt.amount, unit)]))
50+ let timestamp = max(currentTimestamp, lastFeedingTimestamp)
51+ ScriptResult(WriteSet([DataEntry("last_feeding", normalizeTimestamp(timestamp))]), TransferSet([ScriptTransfer(bankContract, pmt.amount, unit)]))
6252 }
6353 }
6454 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let hour = 1
4+let hour = (60 * 60)
55
66 let starveToDeathTime = ((hour * 24) * 7)
7+
8+let bankContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN")
79
810 let feedingContract = addressFromStringValue("3N7qQ4adk68s2cqRnUzHFRPQB2JX1CPxhcN")
911
1012 let piggyBank = addressFromStringValue("3N64tZ47Ra4Pw9uFCXHyaHMQznBrQvxg4sA")
1113
1214 let type = "Cat"
1315
14-func isDead (id,currentBlock) = {
15- let lastFeedingBlockHeight = match getInteger(this, "last_feeding") {
16- case lf: Int =>
17- lf
18- case _ =>
19- match transactionHeightById(id) {
20- case a: Int =>
21- a
22- case _ =>
23- throw()
24- }
25- }
26- let lastFeedingBlock = match blockInfoByHeight(lastFeedingBlockHeight) {
27- case bi: BlockInfo =>
28- bi
29- case _ =>
30- throw()
31- }
32- ((lastFeedingBlock.timestamp + starveToDeathTime) >= currentBlock.timestamp)
33- }
16+func normalizeTimestamp (timestamp) = if ((timestamp > starveToDeathTime))
17+ then starveToDeathTime
18+ else timestamp
19+
20+
21+func max (a,b) = if ((a > b))
22+ then a
23+ else b
3424
3525
3626 @Callable(i)
3727 func feed () = {
3828 let pmt = extract(i.payment)
39- let currentBlockHeight = match transactionHeightById(i.transactionId) {
40- case a: Int =>
41- a
29+ let currentTimestamp = match blockInfoByHeight(extract(transactionHeightById(i.transactionId))) {
30+ case bi: BlockInfo =>
31+ bi.timestamp
4232 case _ =>
4333 throw()
4434 }
45- let currentBlock = match blockInfoByHeight(currentBlockHeight) {
46- case bi: BlockInfo =>
47- bi
35+ let lastFeedingTimestamp = match getInteger(this, "last_feeding") {
36+ case t: Int =>
37+ t
4838 case _ =>
49- throw()
39+ (currentTimestamp + (starveToDeathTime / 2))
5040 }
51- if (isDead(i.transactionId, currentBlock))
41+ if ((currentTimestamp > (lastFeedingTimestamp + starveToDeathTime)))
5242 then throw("The creature is dead =(")
5343 else if (isDefined(pmt.assetId))
5444 then TransferSet([ScriptTransfer(piggyBank, pmt.amount, pmt.assetId)])
5545 else {
56- let feedingPrice = getIntegerValue(feedingContract, ("price_" + type))
46+ let feedingPrice = 1000000
5747 if ((feedingPrice > pmt.amount))
5848 then throw("Insuficient amount of Waves to feed the creature")
5949 else {
60- let animalFund = addressFromStringValue(getStringValue(feedingContract, ("fund_" + type)))
61- ScriptResult(WriteSet([DataEntry("last_feeding", currentBlock.timestamp)]), TransferSet([ScriptTransfer(animalFund, pmt.amount, unit)]))
50+ let timestamp = max(currentTimestamp, lastFeedingTimestamp)
51+ ScriptResult(WriteSet([DataEntry("last_feeding", normalizeTimestamp(timestamp))]), TransferSet([ScriptTransfer(bankContract, pmt.amount, unit)]))
6252 }
6353 }
6454 }
6555
6656

github/deemru/w8io/169f3d6 
36.76 ms