tx · B2DFhhPHXu5nU4QmwRjLFYzRh35LxHKvPoL6jSQBcwQy

3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk:  -0.01400000 Waves

2019.07.30 16:21 [608886] smart account 3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk > SELF 0.00000000 Waves

{ "type": 13, "id": "B2DFhhPHXu5nU4QmwRjLFYzRh35LxHKvPoL6jSQBcwQy", "fee": 1400000, "feeAssetId": null, "timestamp": 1564492910345, "version": 1, "sender": "3MqLtJ49xFdzpVh8kJoaumrRN9GYXLrScMk", "senderPublicKey": "5XLU4PwAQXZGmcUD3QtB2pXeV3VBEBp8cvA9NnTiv2mW", "proofs": [ "5Hhp9KvFmWHW7LGZfaSmA1J8xJHQU1ajNBenHY9eBDRHsoib1nruyA7CFqkBg7FNmuy8V3GRB7wi3mxhyjNhL8TJ" ], "script": "base64:AAIDAAAAAAAAAAAAAAAJAAAAAApiZXRBc3NldElkAQAAACAea7QCZF/XAXMBPEnDQ5kqHUHyOfWmXu9KHDHL6zcNNwAAAAAGbWF4RmVlAAAAAAAATEtAAAAAAAZtaW5CZXQAAAAAAABMS0AAAAAAD21pbk1hdGNoTm9taW5hbAAAAAAAAExLQAEAAAAIY2hlY2tGZWUAAAABAAAAAWkDCQAAZgAAAAIIBQAAAAFpAAAAA2ZlZQUAAAAGbWF4RmVlCQAAAgAAAAECAAAAFnVucmVhc29uYWJsZSBsYXJnZSBmZWUDCQEAAAACIT0AAAACCAUAAAABaQAAAApmZWVBc3NldElkBQAAAAR1bml0CQAAAgAAAAECAAAAFGZlZSBtdXN0IGJlIGluIFdBVkVTBgEAAAAIcmVwYXlGZWUAAAADAAAAAWkAAAACd3MAAAAGYW1vdW50AwkBAAAACGNoZWNrRmVlAAAAAQUAAAABaQkBAAAADFNjcmlwdFJlc3VsdAAAAAIFAAAAAndzCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIB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PQAAAAIFAAAADXdpbm5lckFkZHJlc3MJAAJYAAAAAQgIBQAAAAFpAAAABmNhbGxlcgAAAAVieXRlcwkAAAIAAAABAgAAACtwYXl3aW5uZXIoKSBzaG91bGQgYmUgY2FsbGVkIGJ5IHdpbm5lciBvbmx5BAAAAAZhbW91bnQJAQAAAAdleHRyYWN0AAAAAQkABBoAAAACBQAAAAR0aGlzCQABLAAAAAIFAAAAB21hdGNoSWQCAAAAB19hbW91bnQJAQAAAAhyZXBheUZlZQAAAAMFAAAAAWkJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAHbWF0Y2hJZAIAAAAFX3BhaWQFAAAABmFtb3VudAUAAAADbmlsBQAAAAZhbW91bnQAAAAAIW2FFw==", "chainId": 84, "height": 608886, "spentComplexity": 0 } View: original | compacted Prev: Ga7qeirLHczmEGRevHsNyRM6ZCWKgweFrdtg3fyKi6RF Next: 6t5YZKTzbM3YyYw85eJKABYHBnUx1GT5Z9jmbRvVfdnc Diff:
OldNewDifferences
4848 else false)
4949 then throw("unexpected side")
5050 else {
51- let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + toBase58String(i.transactionId)) + "_")
51+ let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + take(toBase58String(i.transactionId), 8)) + "_")
5252 let sequence = match getInteger(this, ((("seq_" + event) + "_") + subevent)) {
5353 case prevS: Int =>
5454 (prevS + 1)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let betAssetId = base58'33kV5hRVtgEGpYqhp9wQn2g9hP1fNWSYGCzzYk1T9Hyg'
55
66 let maxFee = 5000000
77
88 let minBet = 5000000
99
1010 let minMatchNominal = 5000000
1111
1212 func checkFee (i) = if ((i.fee > maxFee))
1313 then throw("unreasonable large fee")
1414 else if ((i.feeAssetId != unit))
1515 then throw("fee must be in WAVES")
1616 else true
1717
1818
1919 func repayFee (i,ws,amount) = if (checkFee(i))
2020 then ScriptResult(ws, TransferSet([ScriptTransfer(i.caller, i.fee, unit)]))
2121 else throw("error")
2222
2323
2424 func checkOwner (i,betid) = (getString(this, (betid + "_owner")) == toBase58String(i.caller.bytes))
2525
2626
2727 func getUnspent (betid) = (extract(getInteger(this, (betid + "_amount"))) - extract(getInteger(this, (betid + "_spent"))))
2828
2929
3030 func isDefeated (betid) = {
3131 let defeatStatus = getInteger(this, (betid + "_defeat"))
3232 if ((defeatStatus == 1))
3333 then true
3434 else (defeatStatus == 3)
3535 }
3636
3737
3838 @Callable(i)
3939 func bet (event,subevent,side,odds) = {
4040 let owner = toBase58String(i.caller.bytes)
4141 let payment = extract(i.payment)
4242 if ((payment.assetId != betAssetId))
4343 then throw(("bet must be in asset " + toBase58String(betAssetId)))
4444 else if ((minBet > payment.amount))
4545 then throw(("minimum allowed bet is " + toString(minBet)))
4646 else if (if ((side != "for"))
4747 then (side != "against")
4848 else false)
4949 then throw("unexpected side")
5050 else {
51- let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + toBase58String(i.transactionId)) + "_")
51+ let betid = (((((("bet_" + event) + "_") + toBase58String(i.caller.bytes)) + "_") + take(toBase58String(i.transactionId), 8)) + "_")
5252 let sequence = match getInteger(this, ((("seq_" + event) + "_") + subevent)) {
5353 case prevS: Int =>
5454 (prevS + 1)
5555 case _ =>
5656 1
5757 }
5858 repayFee(i, WriteSet([DataEntry((betid + "owner"), owner), DataEntry((betid + "event"), event), DataEntry((betid + "subevent"), subevent), DataEntry((betid + "side"), side), DataEntry((betid + "odds"), odds), DataEntry((betid + "amount"), payment.amount), DataEntry((betid + "spent"), 0), DataEntry((betid + "timestamp"), lastBlock.timestamp), DataEntry((betid + "sequence"), sequence)]), 0)
5959 }
6060 }
6161
6262
6363
6464 @Callable(i)
6565 func cancel (betid) = if (!(checkOwner(i, betid)))
6666 then throw("permission denied")
6767 else {
6868 let amount = extract(getInteger(this, (betid + "_amount")))
6969 let spent = extract(getInteger(this, (betid + "_spent")))
7070 let cancelAmount = (amount - spent)
7171 repayFee(i, WriteSet([DataEntry((betid + "_spent"), amount), DataEntry((betid + "_cancel_amount"), cancelAmount)]), cancelAmount)
7272 }
7373
7474
7575
7676 @Callable(i)
7777 func betMatch (betFor,betAgainst) = if ((getString(this, (betFor + "_event")) != getString(this, (betAgainst + "_event"))))
7878 then throw("event id must match")
7979 else if ((getString(this, (betFor + "_subevent")) != getString(this, (betAgainst + "_subevent"))))
8080 then throw("subevent id must match")
8181 else if ((getString(this, (betFor + "_side")) != "for"))
8282 then throw("invalid *for* bet")
8383 else if ((getString(this, (betAgainst + "_side")) != "against"))
8484 then throw("invalid *against* bet")
8585 else {
8686 let eventid = extract(getString(this, (betFor + "_event")))
8787 let matchid = (((((((("match_" + betFor) + "_") + betAgainst) + "_") + eventid) + "_") + toBase58String(i.transactionId)) + "_")
8888 let odds = extract(getInteger(this, (betFor + "_odds")))
8989 let unspentFor = getUnspent(betFor)
9090 let unspentAgainst = getUnspent(betAgainst)
9191 let maxForNominal = unspentFor
9292 let maxAgainstNominal = ((unspentAgainst * 100) / odds)
9393 let matchNominal = if ((maxForNominal > maxAgainstNominal))
9494 then maxAgainstNominal
9595 else maxForNominal
9696 if ((minMatchNominal > matchNominal))
9797 then throw("match nominal too low")
9898 else {
9999 let spendFor = matchNominal
100100 let spendAgainst = ((matchNominal * odds) / 100)
101101 let newSpentFor = (spendFor + unspentFor)
102102 let newSpentAgainst = (spendAgainst + unspentAgainst)
103103 if ((newSpentFor > extract(getInteger(this, (betFor + "_amount")))))
104104 then throw("invalid match")
105105 else if ((newSpentAgainst > extract(getInteger(this, (betAgainst + "_amount")))))
106106 then throw("invalid match")
107107 else repayFee(i, WriteSet([DataEntry((matchid + "amount"), (spendFor + spendAgainst)), DataEntry((matchid + "for"), betFor), DataEntry((matchid + "against"), betAgainst), DataEntry((betFor + "_spent"), newSpentFor), DataEntry((betAgainst + "_spent"), newSpentAgainst)]), 0)
108108 }
109109 }
110110
111111
112112
113113 @Callable(i)
114114 func approveDefeat (betId,defeat) = if (if (isDefined(getInteger(this, (betId + "_defeat"))))
115115 then (defeat == 2)
116116 else false)
117117 then throw("can't dispute after approve")
118118 else repayFee(i, WriteSet([DataEntry((betId + "_defeat"), defeat)]), 0)
119119
120120
121121
122122 @Callable(i)
123123 func payWinner (matchId) = if (isDefined(getInteger(this, (matchId + "_paid"))))
124124 then throw("already paid")
125125 else {
126126 let betForId = extract(getString(this, (matchId + "_for")))
127127 let betAgainstId = extract(getString(this, (matchId + "_against")))
128128 let betForDefeated = isDefeated(betForId)
129129 let betAgainstDefeated = isDefeated(betAgainstId)
130130 if (if (!(betForDefeated))
131131 then !(betAgainstDefeated)
132132 else false)
133133 then throw("no side approved defeat")
134134 else {
135135 let winnerId = if (betForDefeated)
136136 then betAgainstId
137137 else betForId
138138 let winnerAddress = getString(this, (winnerId + "_owner"))
139139 if ((winnerAddress != toBase58String(i.caller.bytes)))
140140 then throw("paywinner() should be called by winner only")
141141 else {
142142 let amount = extract(getInteger(this, (matchId + "_amount")))
143143 repayFee(i, WriteSet([DataEntry((matchId + "_paid"), amount)]), amount)
144144 }
145145 }
146146 }
147147
148148

github/deemru/w8io/169f3d6 
33.47 ms