tx · CutsjVuimjekvJ7npM7QPqHSJjHB95NwNxDJ7zNohXtn

3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB:  -0.01000000 Waves

2021.11.01 14:52 [1771896] smart account 3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB > SELF 0.00000000 Waves

{ "type": 13, "id": "CutsjVuimjekvJ7npM7QPqHSJjHB95NwNxDJ7zNohXtn", "fee": 1000000, "feeAssetId": null, "timestamp": 1635767541071, "version": 1, "sender": "3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB", "senderPublicKey": "8apL73EWyKeioNcFF9zCGNMBVmtx2muqJZEF34QDGEU7", "proofs": [ "3MvLiFVmUsJcSikvT3ZQYdxzegNX9RSngsL6L5dutU2rW6PZZYPacVMfZE811Cun5FwU32FsUADSXvcZCfcc3cSL" ], "script": "base64:AAIFAAAAAAAAAA8IAhIECgIBARIAEgMKAQIAAAALAAAAAAlzZXBhcmF0b3ICAAAAAl9fAAAAAAhrZXlTdGFydAkABLkAAAACCQAETAAAAAICAAAAAiVzCQAETAAAAAICAAAABXN0YXJ0BQAAAANuaWwFAAAACXNlcGFyYXRvcgAAAAALa2V5RHVyYXRpb24JAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAAhkdXJhdGlvbgUAAAADbmlsBQAAAAlzZXBhcmF0b3IAAAAACGtleUFzc2V0CQAEuQAAAAIJAARMAAAAAgIAAAACJXMJAARMAAAAAgIAAAAFYXNzZXQFAAAAA25pbAUAAAAJc2VwYXJhdG9yAAAAAA5rZXlJc0RhdGFSZWFkeQkABLkAAAACCQAETAAAAAICAAAAAiVzCQAETAAAAAICAAAAC2lzRGF0YVJlYWR5BQAAAANuaWwFAAAACXNlcGFyYXRvcgEAAAASa2V5VXNlclJld2FyZFRvdGFsAAAAAQAAAAdhZGRyZXNzCQAEuQAAAAIJAARMAAAAAgIAAAAEJXMlcwkABEwAAAACAgAAAA91c2VyUmV3YXJkVG90YWwJAARM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AAAAA25pbAMJAAAAAAAAAgUAAAAGY2hlY2tzBQAAAAZjaGVja3MEAAAACyR0MDMwOTQzMTY2CQEAAAAOZ2V0VXNlclJld2FyZHMAAAABCQEAAAAHQWRkcmVzcwAAAAEFAAAADGFkZHJlc3NCeXRlcwQAAAAFdG90YWwIBQAAAAskdDAzMDk0MzE2NgAAAAJfMQQAAAAHY2xhaW1lZAgFAAAACyR0MDMwOTQzMTY2AAAAAl8yBAAAAAlhdmFpbGFibGUIBQAAAAskdDAzMDk0MzE2NgAAAAJfMwkABRQAAAACBQAAAANuaWwJAAS5AAAAAgkABEwAAAACAgAAAAYlZCVkJWQJAARMAAAAAgkAAaQAAAABBQAAAAV0b3RhbAkABEwAAAACCQABpAAAAAEFAAAAB2NsYWltZWQJAARMAAAAAgkAAaQAAAABBQAAAAlhdmFpbGFibGUFAAAAA25pbAUAAAAJc2VwYXJhdG9yCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAABrGTCx", "chainId": 84, "height": 1771896, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: B6DXvYGgchaGZba71Hnk4BbYteXe2SD8pduXMomVqvvV Full:
OldNewDifferences
1-# no script
1+{-# STDLIB_VERSION 5 #-}
2+{-# SCRIPT_TYPE ACCOUNT #-}
3+{-# CONTENT_TYPE DAPP #-}
4+let separator = "__"
5+
6+let keyStart = makeString(["%s", "start"], separator)
7+
8+let keyDuration = makeString(["%s", "duration"], separator)
9+
10+let keyAsset = makeString(["%s", "asset"], separator)
11+
12+let keyIsDataReady = makeString(["%s", "isDataReady"], separator)
13+
14+func keyUserRewardTotal (address) = makeString(["%s%s", "userRewardTotal", toString(address)], separator)
15+
16+
17+func keyUserRewardClaimed (address) = makeString(["%s%s", "userRewardClaimed", toString(address)], separator)
18+
19+
20+func keyClaimHistoryRecord (address,txId) = makeString(["%s%s%s", "claimHistoryRecord", toString(address), toBase58String(txId)], separator)
21+
22+
23+func formatHistoryRecord (amount) = makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(amount)], separator)
24+
25+
26+func checkIfDataIsReady () = {
27+ let isDataReady = valueOrElse(getBoolean(this, keyIsDataReady), false)
28+ if (isDataReady)
29+ then true
30+ else throw("Data is not ready")
31+ }
32+
33+
34+func getUserRewards (address) = {
35+ let start = valueOrErrorMessage(getInteger(this, keyStart), "Start block is not specified")
36+ let duration = valueOrErrorMessage(getInteger(this, keyDuration), "Duration is not specified")
37+ let total = valueOrElse(getInteger(this, keyUserRewardTotal(address)), 0)
38+ let claimed = valueOrElse(getInteger(this, keyUserRewardClaimed(address)), 0)
39+ let availableTotal = fraction(total, min([duration, max([0, (height - start)])]), duration)
40+ let available = max([0, (availableTotal - claimed)])
41+ $Tuple3(total, claimed, available)
42+ }
43+
44+
45+@Callable(i)
46+func constructor (start,duration) = {
47+ let targetPaymentsSize = 1
48+ let checks = [if ((i.caller == this))
49+ then true
50+ else throw("Access denied"), if ((size(i.payments) == targetPaymentsSize))
51+ then true
52+ else throw("Exactly 1 payment must be attached")]
53+ if ((checks == checks))
54+ then {
55+ let assetId = valueOrErrorMessage(value(i.payments[0]).assetId, "WAVES can't be used")
56+[IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), BinaryEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)]
57+ }
58+ else throw("Strict value is not equal to itself.")
59+ }
60+
61+
62+
63+@Callable(i)
64+func claim () = {
65+ let $t023492408 = getUserRewards(i.caller)
66+ let total = $t023492408._1
67+ let claimed = $t023492408._2
68+ let available = $t023492408._3
69+ let asset = valueOrErrorMessage(getBinary(this, keyAsset), "Asset is not specified")
70+ let balance = assetBalance(this, asset)
71+ let checks = [checkIfDataIsReady(), if ((available > 0))
72+ then true
73+ else throw("No reward available"), if ((balance >= available))
74+ then true
75+ else throw("Insufficient funds. Contact support")]
76+ if ((checks == checks))
77+ then [ScriptTransfer(i.caller, available, asset), IntegerEntry(keyUserRewardClaimed(i.caller), (claimed + available)), StringEntry(keyClaimHistoryRecord(i.caller, i.transactionId), formatHistoryRecord(available))]
78+ else throw("Strict value is not equal to itself.")
79+ }
80+
81+
82+
83+@Callable(i)
84+func getUserRewardsREADONLY (addressBytes) = {
85+ let checks = [checkIfDataIsReady()]
86+ if ((checks == checks))
87+ then {
88+ let $t030943166 = getUserRewards(Address(addressBytes))
89+ let total = $t030943166._1
90+ let claimed = $t030943166._2
91+ let available = $t030943166._3
92+ $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator))
93+ }
94+ else throw("Strict value is not equal to itself.")
95+ }
96+
97+

github/deemru/w8io/169f3d6 
33.67 ms