tx · 5kXvuNXuHnR48SPhf4ffSCSz5SDzhS1g8ehCzuPDv7fg

3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc:  -0.01400000 Waves

2019.09.08 13:43 [666991] smart account 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc > SELF 0.00000000 Waves

{ "type": 13, "id": "5kXvuNXuHnR48SPhf4ffSCSz5SDzhS1g8ehCzuPDv7fg", "fee": 1400000, "feeAssetId": null, "timestamp": 1567939414558, "version": 1, "sender": "3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc", "senderPublicKey": "9cETBksYN8YMHGvDB6BEqmH9HScpCMBRZwnjCviRQ9aA", "proofs": [ "4xPxCZS4iRUWBrTcuhcsKSR4tGDSmhcGKihk1SpPYvKdwsgufzsnFmHwtD8xK4m8LGcN2FUKeYzy9v2tcmyEmP8e" ], "script": "base64:AAIDAAAAAAAAAAAAAAAVAAAAAAVQUklDRQAAAAAABfXhAAAAAAALUEFURU5UUFJJQ0UAAAAAAAvrwgAAAAAABk9SQUNMRQIAAAAjM012aXNEZkE2dk5nNGk2aUtZV1o4Yld2eVA0aW1mQmI5ZXEAAAAAA1dJTgIAAAADV0lOAAAAAARMT1NFAgAAAARMT1NFAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBA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AAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAFGdldEtleUluc3VyYW5jZUNvdW50AAAAAQUAAAALdXNlckFkZHJlc3MJAABkAAAAAgkBAAAAFmdldFZhbHVlSW5zdXJhbmNlQ291bnQAAAABBQAAAAt1c2VyQWRkcmVzcwAAAAAAAAAAAQUAAAADbmlsAAAAABn1AZY=", "chainId": 84, "height": 666991, "spentComplexity": 0 } View: original | compacted Prev: Vzswnt7gd2A5f1f7uwyfSoRmTwGhiLfkLkfqHH6kP2E Next: CJBoNBF5kKKjWqhLQ2E123KMaCxZM2rei8qyxka2jjKs Diff:
OldNewDifferences
5757 else true
5858
5959
60-func genKeyFromCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = ((((((((((((((((((((((toString(x1) + ",") + toString(y1)) + ";") + toString(x2)) + ",") + toString(y2)) + ";") + toString(x3)) + ",") + toString(y3)) + ";") + toString(x4)) + ",") + toString(y4)) + ";") + toString(x5)) + ",") + toString(y5)) + ";") + toString(x6)) + ",") + toString(y6))
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))
6161
6262
6363 func getKeyBalanceUser (account) = (account + "_balance")
8282
8383
8484 func getValueGame (game) = getStrByKey(getKeyGame(game))
85+
86+
87+func getKeyInsuranceCount (user) = (user + "_insurance_cnt")
88+
89+
90+func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user))
8591
8692
8793 @Callable(i)
149155 }
150156
151157
158+
159+@Callable(i)
160+func insure () = {
161+ let pmt = extract(i.payment)
162+ let insurancePrice = fraction(PRICE, 7, 100)
163+ if (isDefined(pmt.assetId))
164+ then throw("can use WAVES only at the moment")
165+ else {
166+ let userAddress = toBase58String(i.caller.bytes)
167+ if ((pmt.amount != insurancePrice))
168+ then throw("insurance payment amount cannot be not equal to the insurance price")
169+ else WriteSet([DataEntry(getKeyInsuranceCount(userAddress), (getValueInsuranceCount(userAddress) + 1))])
170+ }
171+ }
172+
173+
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
60-func genKeyFromCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = ((((((((((((((((((((((toString(x1) + ",") + toString(y1)) + ";") + toString(x2)) + ",") + toString(y2)) + ";") + toString(x3)) + ",") + toString(y3)) + ";") + toString(x4)) + ",") + toString(y4)) + ";") + toString(x5)) + ",") + toString(y5)) + ";") + toString(x6)) + ",") + toString(y6))
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))
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))
85+
86+
87+func getKeyInsuranceCount (user) = (user + "_insurance_cnt")
88+
89+
90+func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user))
8591
8692
8793 @Callable(i)
8894 func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
8995 let pmt = extract(i.payment)
9096 if (isDefined(pmt.assetId))
9197 then throw("can use WAVES only at the moment")
9298 else {
9399 let userAddress = toBase58String(i.caller.bytes)
94100 if ((pmt.amount != PRICE))
95101 then throw("purchase amount cannot be not equal to the price")
96102 else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
97103 then throw("invalid coordinates order")
98104 else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE))
99105 then throw("this patent is already exists")
100106 else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress)])
101107 }
102108 }
103109
104110
105111
106112 @Callable(i)
107113 func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = {
108114 let pmt = extract(i.payment)
109115 if (isDefined(pmt.assetId))
110116 then throw("can use WAVES only at the moment")
111117 else {
112118 let userAddress = toBase58String(i.caller.bytes)
113119 let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))
114120 if ((pmt.amount != PATENTPRICE))
115121 then throw("purchase amount cannot be not equal to the price")
116122 else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)))
117123 then throw("invalid coordinates order")
118124 else if ((patentOwnerAddress == NONE))
119125 then throw("there is no such patent")
120126 else if ((patentOwnerAddress == userAddress))
121127 then throw("you cannot buy your own patent")
122128 else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))])
123129 }
124130 }
125131
126132
127133
128134 @Callable(i)
129135 func withdraw () = {
130136 let userAddress = toBase58String(i.caller.bytes)
131137 let balance = getValueBalanceUser(userAddress)
132138 if ((0 >= balance))
133139 then throw("insufficient balance")
134140 else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)]))
135141 }
136142
137143
138144
139145 @Callable(i)
140146 func gameReport (game,winner,loser) = {
141147 let oracleAddres = toBase58String(i.caller.bytes)
142148 if ((oracleAddres != ORACLE))
143149 then throw("only oracle can inform about games results")
144150 else if ((winner == loser))
145151 then throw("winner and loser must be different")
146152 else if ((getValueGame(game) != NONE))
147153 then throw("this game has already been played")
148154 else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))])
149155 }
150156
151157
158+
159+@Callable(i)
160+func insure () = {
161+ let pmt = extract(i.payment)
162+ let insurancePrice = fraction(PRICE, 7, 100)
163+ if (isDefined(pmt.assetId))
164+ then throw("can use WAVES only at the moment")
165+ else {
166+ let userAddress = toBase58String(i.caller.bytes)
167+ if ((pmt.amount != insurancePrice))
168+ then throw("insurance payment amount cannot be not equal to the insurance price")
169+ else WriteSet([DataEntry(getKeyInsuranceCount(userAddress), (getValueInsuranceCount(userAddress) + 1))])
170+ }
171+ }
172+
173+

github/deemru/w8io/169f3d6 
34.14 ms