tx · CDvfhwHmvKUwuTVvE4MHhocSfSkUNWWusFEaxhf6dKme

3MvsWmraQRD2kUduNUrBQ6hP4K5xpc4XGkY:  -0.01400000 Waves

2019.11.04 20:19 [750447] smart account 3MvsWmraQRD2kUduNUrBQ6hP4K5xpc4XGkY > SELF 0.00000000 Waves

{ "type": 13, "id": "CDvfhwHmvKUwuTVvE4MHhocSfSkUNWWusFEaxhf6dKme", "fee": 1400000, "feeAssetId": null, "timestamp": 1572887943857, "version": 1, "sender": "3MvsWmraQRD2kUduNUrBQ6hP4K5xpc4XGkY", "senderPublicKey": "2foPKfEwXBpviGcG7ZXyskcNXGh3Xnr91zKERRXhTchH", "proofs": [ "5H5NPjtuKdvcCYzosvWR7u6v17aoZN6RZVYjiqcfvmmsRTRpYUcyQCXET4LiFNcD1Hs6Gff8uExoF7n246SGFeFn" ], "script": "base64:AAIDAAAAAAAAAA4IARIDCgEBEgUKAwgBCAAAAAMBAAAADmdldE1ldGVyU3RhdHVzAAAAAQAAAAxtZXRlckFkZHJlc3MEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwkAASwAAAACBQAAAAxtZXRlckFkZHJlc3MCAAAAB19zdGF0dXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQEAAAAAXgFAAAAByRtYXRjaDACAAAADm5vdCByZWdpc3RlcmVkAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAXgFAAAAByRtYXRjaDAFAAAAAXgJAQAAAAV0aHJvdwAAAAABAAAADmdldEJhbmtBZGRyZXNzAAAAAAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzAgAAAAxiYW5rX2FkZHJlc3MDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQEAAAAAXgFAAAAByRtYXRjaDACAAAAEm5vIGJhbmsgcmVnaXN0ZXJlZAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAF4BQAAAAckb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AANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAthbW91bnRUb1BheQkAAlkAAAABBQAAAAdhc3NldElkBQAAAANuaWwJAAACAAAAAQIAAAAUaW5zdWZmaWNpZW50IGJhbGFuY2UJAAACAAAAAQIAAAAkTm8gZW5lcmd5IGNvbnN1bWVkIGR1cmluZyB0aGUgcGVyaW9kCQAAAgAAAAECAAAARG9wZXJhdGlvbiBpcyBub3QgcGVybWl0dGVkLCBvbmx5IGJhbmsgaXMgYWxsb3dlZCB0byBjYWxsIHRoaXMgbWV0aG9kAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAcDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAAF0BQAAAAckbWF0Y2gwBwkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXmH2+1D", "chainId": 84, "height": 750447, "spentComplexity": 0 } View: original | compacted Prev: 6ZmAtDLLAYm5uuSaAM3YxofStUBFJ5irgxSAZB3QAqHN Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let PRICE = 100000000
5-
6-let PATENTPRICE = 200000000
7-
8-let ORACLE = "3MvisDfA6vNg4i6iKYWZ8bWvyP4imfBb9eq"
9-
10-let WIN = "WIN"
11-
12-let LOSE = "LOSE"
13-
14-let NONE = "none"
15-
16-func getNumberByKey (key) = {
17- let num = match getInteger(this, key) {
18- case a: Int =>
19- a
20- case _ =>
21- 0
22- }
23- num
24- }
4+func getMeterStatus (meterAddress) = match getString(this, (meterAddress + "_status")) {
5+ case x: Unit =>
6+ "not registered"
7+ case x: String =>
8+ x
9+ case _ =>
10+ throw()
11+}
2512
2613
27-func getStrByKey (key) = {
28- let str = match getString(this, key) {
29- case a: String =>
30- a
31- case _ =>
32- NONE
33- }
34- str
35- }
14+func getBankAddress () = match getString(this, "bank_address") {
15+ case x: Unit =>
16+ "no bank registered"
17+ case x: String =>
18+ x
19+ case _ =>
20+ throw()
21+}
3622
3723
38-func validateTwoCoords (x1,y1,x2,y2) = if ((x1 > x2))
39- then false
40- else if (if ((x1 == x2))
41- then (y1 > y2)
42- else false)
43- then false
44- else true
45-
46-
47-func validateCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = if (!(validateTwoCoords(x1, y1, x2, y2)))
48- then false
49- else if (!(validateTwoCoords(x2, y2, x3, y3)))
50- then false
51- else if (!(validateTwoCoords(x3, y3, x4, y4)))
52- then false
53- else if (!(validateTwoCoords(x4, y4, x5, y5)))
54- then false
55- else if (!(validateTwoCoords(x5, y5, x6, y6)))
56- then false
57- else true
58-
59-
60-func genKeyFromCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = ((((((((((((((((((((((("patent:" + toString(x1)) + ",") + toString(y1)) + ";") + toString(x2)) + ",") + toString(y2)) + ";") + toString(x3)) + ",") + toString(y3)) + ";") + toString(x4)) + ",") + toString(y4)) + ";") + toString(x5)) + ",") + toString(y5)) + ";") + toString(x6)) + ",") + toString(y6))
61-
62-
63-func getKeyBalanceUser (account) = (account + "_balance")
64-
65-
66-func getValueBalanceUser (account) = getNumberByKey(getKeyBalanceUser(account))
67-
68-
69-func getKeyWinCount (user) = (user + "_wincnt")
70-
71-
72-func getValueWinCount (user) = getNumberByKey(getKeyWinCount(user))
73-
74-
75-func getKeyLoseCount (user) = (user + "_losecnt")
76-
77-
78-func getValueLoseCount (user) = getNumberByKey(getKeyLoseCount(user))
79-
80-
81-func getKeyGame (game) = ("game_" + game)
82-
83-
84-func getValueGame (game) = getStrByKey(getKeyGame(game))
85-
86-
87-func getKeyInsuranceCount (user) = (user + "_insurance_cnt")
88-
89-
90-func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user))
91-
92-
93-func getKeyUserPatentCount (user) = (user + "_patent_cnt")
94-
95-
96-func getValueUserPatentCount (user) = getNumberByKey(getKeyUserPatentCount(user))
24+func getEnergyValue (meterAddress,type) = match getInteger(this, (((meterAddress + "_") + type) + "_value")) {
25+ case x: Unit =>
26+ 0
27+ case x: Int =>
28+ x
29+ case _ =>
30+ throw()
31+}
9732
9833
9934 @Callable(i)
100-func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
101- let pmt = extract(i.payment)
102- if (isDefined(pmt.assetId))
103- then throw("can use WAVES only at the moment")
104- else {
105- let userAddress = toBase58String(i.caller.bytes)
106- if ((pmt.amount != PRICE))
107- then throw("purchase amount cannot be not equal to the price")
108- else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
109- then throw("invalid coordinates order")
110- else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE))
111- then throw("this patent is already exists")
112- else if ((getValueUserPatentCount(userAddress) >= 5))
113- then throw("you cannot have more than 2 patents")
114- else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1))])
115- }
35+func sendData (newValue) = {
36+ let meterAddress = toBase58String(i.caller.bytes)
37+ let meterStatus = getMeterStatus(meterAddress)
38+ if ((meterStatus == "active"))
39+ then WriteSet([DataEntry((meterAddress + "_current_value"), newValue)])
40+ else throw("Meter address was not found or meter is not active")
11641 }
11742
11843
11944
12045 @Callable(i)
121-func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
122- let pmt = extract(i.payment)
123- if (isDefined(pmt.assetId))
124- then throw("can use WAVES only at the moment")
125- else {
126- let userAddress = toBase58String(i.caller.bytes)
127- let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))
128- if ((pmt.amount != PATENTPRICE))
129- then throw("purchase amount cannot be not equal to the price")
130- else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
131- then throw("invalid coordinates order")
132- else if ((patentOwnerAddress == NONE))
133- then throw("there is no such patent")
134- else if ((patentOwnerAddress == userAddress))
135- then throw("you cannot buy your own patent")
136- else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount)), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1)), DataEntry(getKeyUserPatentCount(patentOwnerAddress), (getValueUserPatentCount(userAddress) - 1))])
46+func makePayment (meterAddress,tarif,assetId) = {
47+ let sender = toBase58String(i.caller.bytes)
48+ let meterStatus = getMeterStatus(meterAddress)
49+ let bankAddress = getBankAddress()
50+ if (if ((meterStatus == "active"))
51+ then (sender == bankAddress)
52+ else false)
53+ then {
54+ let currentValue = getEnergyValue(meterAddress, "current")
55+ let prevValue = getEnergyValue(meterAddress, "prev")
56+ if ((prevValue != currentValue))
57+ then {
58+ let balance = assetBalance(this, fromBase58String(assetId))
59+ let amountToPay = (tarif * (currentValue - prevValue))
60+ if ((balance > amountToPay))
61+ then ScriptResult(WriteSet([DataEntry((meterAddress + "_prev_value"), currentValue), DataEntry(bankAddress, ((((("invoice_date_" + toString(lastBlock.timestamp)) + "_client_") + toBase58String(this.bytes)) + "_meter_") + meterAddress))]), TransferSet([ScriptTransfer(i.caller, amountToPay, fromBase58String(assetId))]))
62+ else throw("insufficient balance")
63+ }
64+ else throw("No energy consumed during the period")
13765 }
66+ else throw("operation is not permitted, only bank is allowed to call this method")
13867 }
13968
14069
141-
142-@Callable(i)
143-func withdraw () = {
144- let userAddress = toBase58String(i.caller.bytes)
145- let balance = getValueBalanceUser(userAddress)
146- if ((0 >= balance))
147- then throw("insufficient balance")
148- else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)]))
149- }
150-
151-
152-
153-@Callable(i)
154-func gameReport (game,winner,loser) = {
155- let oracleAddres = toBase58String(i.caller.bytes)
156- if ((oracleAddres != ORACLE))
157- then throw("only oracle can inform about games results")
158- else if ((winner == loser))
159- then throw("winner and loser must be different")
160- else if ((getValueGame(game) != NONE))
161- then throw("this game has already been played")
162- else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))])
163- }
164-
165-
166-
167-@Callable(i)
168-func insure () = {
169- let pmt = extract(i.payment)
170- let insurancePrice = fraction(PRICE, 7, 100)
171- if (isDefined(pmt.assetId))
172- then throw("can use WAVES only at the moment")
173- else {
174- let userAddress = toBase58String(i.caller.bytes)
175- if ((pmt.amount != insurancePrice))
176- then throw("insurance payment amount cannot be not equal to the insurance price")
177- else WriteSet([DataEntry(getKeyInsuranceCount(userAddress), (getValueInsuranceCount(userAddress) + 1))])
178- }
179- }
180-
70+@Verifier(tx)
71+func verify () = match tx {
72+ case t: DataTransaction =>
73+ false
74+ case t: SetScriptTransaction =>
75+ false
76+ case _ =>
77+ sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
78+}
18179

github/deemru/w8io/c3f4982 
26.01 ms