tx · CJBoNBF5kKKjWqhLQ2E123KMaCxZM2rei8qyxka2jjKs

3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc:  -0.01400000 Waves

2019.09.08 14:56 [667072] smart account 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc > SELF 0.00000000 Waves

{ "type": 13, "id": "CJBoNBF5kKKjWqhLQ2E123KMaCxZM2rei8qyxka2jjKs", "fee": 1400000, "feeAssetId": null, "timestamp": 1567943722569, "version": 1, "sender": "3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc", "senderPublicKey": "9cETBksYN8YMHGvDB6BEqmH9HScpCMBRZwnjCviRQ9aA", "proofs": [ "C8qe1eAudoZhE3ZDUSGCXvJo1MMZdprvrUEozcC8jB1yLHXve8JrBuFJro6gBpwjfT8T6HuzTvoPmXiZvvx4VX4" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAAVQUklDRQAAAAAABfXhAAAAAAALUEFURU5UUFJJQ0UAAAAAAAvrwgAAAAAABk9SQUNMRQIAAAAjM012aXNEZkE2dk5nNGk2aUtZV1o4Yld2eVA0aW1mQmI5ZXEAAAAAA1dJTgIAAAADV0lOAAAAAARMT1NFAgAAAARMT1NFAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEXZhb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hbHVlTG9zZUNvdW50AAAAAQUAAAAFbG9zZXIAAAAAAAAAAAEFAAAAA25pbAAAAAFpAQAAAAZpbnN1cmUAAAAABAAAAANwbXQJAQAAAAdleHRyYWN0AAAAAQgFAAAAAWkAAAAHcGF5bWVudAQAAAAOaW5zdXJhbmNlUHJpY2UJAABrAAAAAwUAAAAFUFJJQ0UAAAAAAAAAAAcAAAAAAAAAAGQDCQEAAAAJaXNEZWZpbmVkAAAAAQgFAAAAA3BtdAAAAAdhc3NldElkCQAAAgAAAAECAAAAIGNhbiB1c2UgV0FWRVMgb25seSBhdCB0aGUgbW9tZW50BAAAAAt1c2VyQWRkcmVzcwkAAlgAAAABCAgFAAAAAWkAAAAGY2FsbGVyAAAABWJ5dGVzAwkBAAAAAiE9AAAAAggFAAAAA3BtdAAAAAZhbW91bnQFAAAADmluc3VyYW5jZVByaWNlCQAAAgAAAAECAAAAQ2luc3VyYW5jZSBwYXltZW50IGFtb3VudCBjYW5ub3QgYmUgbm90IGVxdWFsIHRvIHRoZSBpbnN1cmFuY2UgcHJpY2UJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAABRnZXRLZXlJbnN1cmFuY2VDb3VudAAAAAEFAAAAC3VzZXJBZGRyZXNzCQAAZAAAAAIJAQAAABZnZXRWYWx1ZUluc3VyYW5jZUNvdW50AAAAAQUAAAALdXNlckFkZHJlc3MAAAAAAAAAAAEFAAAAA25pbAAAAABL5G38", "chainId": 84, "height": 667072, "spentComplexity": 0 } View: original | compacted Prev: 5kXvuNXuHnR48SPhf4ffSCSz5SDzhS1g8ehCzuPDv7fg Next: BBcE14RcP2V15Ck5JEdWuT4NGASCJzuaSzvJRgQ9TFPM Diff:
OldNewDifferences
9090 func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user))
9191
9292
93+func getKeyUserPatentCount (user) = (user + "_patent_cnt")
94+
95+
96+func getValueUserPatentCount (user) = getNumberByKey(getKeyUserPatentCount(user))
97+
98+
9399 @Callable(i)
94100 func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
95101 let pmt = extract(i.payment)
103109 then throw("invalid coordinates order")
104110 else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE))
105111 then throw("this patent is already exists")
106- else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress)])
112+ else if ((getValueUserPatentCount(userAddress) >= 2))
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))])
107115 }
108116 }
109117
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let PRICE = 100000000
55
66 let PATENTPRICE = 200000000
77
88 let ORACLE = "3MvisDfA6vNg4i6iKYWZ8bWvyP4imfBb9eq"
99
1010 let WIN = "WIN"
1111
1212 let LOSE = "LOSE"
1313
1414 let NONE = "none"
1515
1616 func getNumberByKey (key) = {
1717 let num = match getInteger(this, key) {
1818 case a: Int =>
1919 a
2020 case _ =>
2121 0
2222 }
2323 num
2424 }
2525
2626
2727 func getStrByKey (key) = {
2828 let str = match getString(this, key) {
2929 case a: String =>
3030 a
3131 case _ =>
3232 NONE
3333 }
3434 str
3535 }
3636
3737
3838 func validateTwoCoords (x1,y1,x2,y2) = if ((x1 > x2))
3939 then false
4040 else if (if ((x1 == x2))
4141 then (y1 > y2)
4242 else false)
4343 then false
4444 else true
4545
4646
4747 func validateCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = if (!(validateTwoCoords(x1, y1, x2, y2)))
4848 then false
4949 else if (!(validateTwoCoords(x2, y2, x3, y3)))
5050 then false
5151 else if (!(validateTwoCoords(x3, y3, x4, y4)))
5252 then false
5353 else if (!(validateTwoCoords(x4, y4, x5, y5)))
5454 then false
5555 else if (!(validateTwoCoords(x5, y5, x6, y6)))
5656 then false
5757 else true
5858
5959
6060 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))
6161
6262
6363 func getKeyBalanceUser (account) = (account + "_balance")
6464
6565
6666 func getValueBalanceUser (account) = getNumberByKey(getKeyBalanceUser(account))
6767
6868
6969 func getKeyWinCount (user) = (user + "_wincnt")
7070
7171
7272 func getValueWinCount (user) = getNumberByKey(getKeyWinCount(user))
7373
7474
7575 func getKeyLoseCount (user) = (user + "_losecnt")
7676
7777
7878 func getValueLoseCount (user) = getNumberByKey(getKeyLoseCount(user))
7979
8080
8181 func getKeyGame (game) = ("game_" + game)
8282
8383
8484 func getValueGame (game) = getStrByKey(getKeyGame(game))
8585
8686
8787 func getKeyInsuranceCount (user) = (user + "_insurance_cnt")
8888
8989
9090 func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user))
9191
9292
93+func getKeyUserPatentCount (user) = (user + "_patent_cnt")
94+
95+
96+func getValueUserPatentCount (user) = getNumberByKey(getKeyUserPatentCount(user))
97+
98+
9399 @Callable(i)
94100 func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
95101 let pmt = extract(i.payment)
96102 if (isDefined(pmt.assetId))
97103 then throw("can use WAVES only at the moment")
98104 else {
99105 let userAddress = toBase58String(i.caller.bytes)
100106 if ((pmt.amount != PRICE))
101107 then throw("purchase amount cannot be not equal to the price")
102108 else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
103109 then throw("invalid coordinates order")
104110 else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE))
105111 then throw("this patent is already exists")
106- else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress)])
112+ else if ((getValueUserPatentCount(userAddress) >= 2))
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))])
107115 }
108116 }
109117
110118
111119
112120 @Callable(i)
113121 func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
114122 let pmt = extract(i.payment)
115123 if (isDefined(pmt.assetId))
116124 then throw("can use WAVES only at the moment")
117125 else {
118126 let userAddress = toBase58String(i.caller.bytes)
119127 let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))
120128 if ((pmt.amount != PATENTPRICE))
121129 then throw("purchase amount cannot be not equal to the price")
122130 else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
123131 then throw("invalid coordinates order")
124132 else if ((patentOwnerAddress == NONE))
125133 then throw("there is no such patent")
126134 else if ((patentOwnerAddress == userAddress))
127135 then throw("you cannot buy your own patent")
128136 else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))])
129137 }
130138 }
131139
132140
133141
134142 @Callable(i)
135143 func withdraw () = {
136144 let userAddress = toBase58String(i.caller.bytes)
137145 let balance = getValueBalanceUser(userAddress)
138146 if ((0 >= balance))
139147 then throw("insufficient balance")
140148 else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)]))
141149 }
142150
143151
144152
145153 @Callable(i)
146154 func gameReport (game,winner,loser) = {
147155 let oracleAddres = toBase58String(i.caller.bytes)
148156 if ((oracleAddres != ORACLE))
149157 then throw("only oracle can inform about games results")
150158 else if ((winner == loser))
151159 then throw("winner and loser must be different")
152160 else if ((getValueGame(game) != NONE))
153161 then throw("this game has already been played")
154162 else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))])
155163 }
156164
157165
158166
159167 @Callable(i)
160168 func insure () = {
161169 let pmt = extract(i.payment)
162170 let insurancePrice = fraction(PRICE, 7, 100)
163171 if (isDefined(pmt.assetId))
164172 then throw("can use WAVES only at the moment")
165173 else {
166174 let userAddress = toBase58String(i.caller.bytes)
167175 if ((pmt.amount != insurancePrice))
168176 then throw("insurance payment amount cannot be not equal to the insurance price")
169177 else WriteSet([DataEntry(getKeyInsuranceCount(userAddress), (getValueInsuranceCount(userAddress) + 1))])
170178 }
171179 }
172180
173181

github/deemru/w8io/169f3d6 
36.15 ms