tx · BhzoXLfoRHr7tUxbZ6VfGbJ7aARoMdCvswj1ntmtTMGh

3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk:  -0.01000000 Waves

2021.10.14 18:53 [1746144] smart account 3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk > SELF 0.00000000 Waves

{ "type": 13, "id": "BhzoXLfoRHr7tUxbZ6VfGbJ7aARoMdCvswj1ntmtTMGh", "fee": 1000000, "feeAssetId": null, "timestamp": 1634226829552, "version": 2, "chainId": 84, "sender": "3Mu9qAjmg8fVTxxpwPZnBAH948ujt4m6Xvk", "senderPublicKey": "8v9pmcXqHz9DTc5k1Z8duTYyDwykFxN3EzdZ9WAn3KXJ", "proofs": [ "3UE5uYKzYuCXCfsJHge3GdSGiuFE1SpGFc1bpmXbPk8v8AUUusouZFWsPfU5B1fUePX1YUCPJ3essqF8QiaTRPMk" ], "script": "base64:AAIDAAAAAAAAAAgIARIECgIBAQAAAAIBAAAACnJhbmRvbWl6ZXIAAAABAAAAA2ludgQAAAAIbGFzdFBsYXkEAAAAByRtYXRjaDAJAAQcAAAAAgUAAAAEdGhpcwIAAAAIbGFzdFBsYXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAACkJ5dGVWZWN0b3IEAAAAAXMFAAAAByRtYXRjaDAFAAAAAXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQBAAAADFdhdmVzTG90dG9WMgkAAAIAAAABAgAAAAtNYXRjaCBlcnJvcgQAAAAEcmFuZAkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACCQAAywAAAAIFAAAACGxhc3RQbGF5CAUAAAADaW52AAAADXRyYW5zYWN0aW9uSWQIBQAAAANpbnYAAAAPY2FsbGVyUHVibGljS2V5CAUAAAAJbGFzdEJsb2NrAAAAE2dlbmVyYXRpb25TaWduYXR1cmUJAAGaAAAAAQgFAAAACWxhc3RCbG9jawAAAAl0aW1lc3RhbXAJAAGaAAAAAQgFAAAACWxh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G9taXplcgAAAAEFAAAAA2ludgQAAAANd3JpdGVMYXN0UGxheQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAIbGFzdFBsYXkFAAAACHJhbmRoYXNoBQAAAANuaWwEAAAABHJhbmQJAABqAAAAAgkABLEAAAABBQAAAAhyYW5kaGFzaAAAAAAAAAAD6AMDCQAAZgAAAAIFAAAACGd1ZXNzRW5kBQAAAARyYW5kCQAAZgAAAAIFAAAABHJhbmQFAAAACmd1ZXNzU3RhcnQHCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAANd3JpdGVMYXN0UGxheQkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAADaW52AAAABmNhbGxlcgkAAGkAAAACCQAAaAAAAAIIBQAAAAdwYXltZW50AAAABmFtb3VudAAAAAAAAAAAvgAAAAAAAAAAZAUAAAAEdW5pdAUAAAADbmlsCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAANd3JpdGVMYXN0UGxheQkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsAAAAAQAAAANpbnYBAAAACXplcm8yaGVybwAAAAIAAAAKZ3Vlc3NTdGFydAAAAAhndWVzc0VuZAkBAAAACnN0YXJ0TG90dG8AAAADBQAAAANpbnYFAAAACmd1ZXNzU3RhcnQFAAAACGd1ZXNzRW5kAAAAAO0o94Y=", "height": 1746144, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: B6kGHJmrdVdYLRkUJzwMZLfGKhhCHJ963oUkmQUR8BM2 Next: 3xQfeiWp54XmH3v7wLVBVUivtM9AM9DZFametgosYMeV Diff:
OldNewDifferences
1515 }
1616
1717
18-func startLotto (inv) = {
18+func startLotto (inv,guessStart,guessEnd) = {
1919 let playLimit = (wavesBalance(this) / 100)
2020 let payment = extract(inv.payment)
2121 if (!(isDefined(inv.payment)))
2424 then throw("Payment should be in Waves")
2525 else if ((payment.amount > playLimit))
2626 then throw(("Payment should be less than " + toString(playLimit)))
27- else {
28- let randhash = randomizer(inv)
29- let winTransfer = TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])
30- let writeLastPlay = WriteSet([DataEntry("lastPlay", randhash)])
31- if ((500 > (toInt(randhash) % 1000)))
32- then ScriptResult(writeLastPlay, winTransfer)
33- else ScriptResult(writeLastPlay, TransferSet(nil))
34- }
27+ else if ((0 > guessStart))
28+ then throw("guessStart and guessEnd Must be in between 0-100")
29+ else if ((guessEnd > 100))
30+ then throw("guessStart and guessEnd Must be in between 0-100")
31+ else if ((guessStart > guessEnd))
32+ then throw("guessStart and guessEnd Must be in between 0-100")
33+ else {
34+ let randhash = randomizer(inv)
35+ let writeLastPlay = WriteSet([DataEntry("lastPlay", randhash)])
36+ let rand = (toInt(randhash) % 1000)
37+ if (if ((guessEnd > rand))
38+ then (rand > guessStart)
39+ else false)
40+ then ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)]))
41+ else ScriptResult(writeLastPlay, TransferSet(nil))
42+ }
3543 }
3644
3745
3846 @Callable(inv)
39-func lotto () = startLotto(inv)
40-
41-
42-
43-@Callable(inv)
44-func default () = startLotto(inv)
47+func zero2hero (guessStart,guessEnd) = startLotto(inv, guessStart, guessEnd)
4548
4649
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 func randomizer (inv) = {
55 let lastPlay = match getBinary(this, "lastPlay") {
66 case s: ByteVector =>
77 s
88 case _: Unit =>
99 base58'2ee4oFDYriWJ9EMeR'
1010 case _ =>
1111 throw("Match error")
1212 }
1313 let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))
1414 sha256(rand)
1515 }
1616
1717
18-func startLotto (inv) = {
18+func startLotto (inv,guessStart,guessEnd) = {
1919 let playLimit = (wavesBalance(this) / 100)
2020 let payment = extract(inv.payment)
2121 if (!(isDefined(inv.payment)))
2222 then throw("Should be with Payment in Waves")
2323 else if (isDefined(payment.assetId))
2424 then throw("Payment should be in Waves")
2525 else if ((payment.amount > playLimit))
2626 then throw(("Payment should be less than " + toString(playLimit)))
27- else {
28- let randhash = randomizer(inv)
29- let winTransfer = TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)])
30- let writeLastPlay = WriteSet([DataEntry("lastPlay", randhash)])
31- if ((500 > (toInt(randhash) % 1000)))
32- then ScriptResult(writeLastPlay, winTransfer)
33- else ScriptResult(writeLastPlay, TransferSet(nil))
34- }
27+ else if ((0 > guessStart))
28+ then throw("guessStart and guessEnd Must be in between 0-100")
29+ else if ((guessEnd > 100))
30+ then throw("guessStart and guessEnd Must be in between 0-100")
31+ else if ((guessStart > guessEnd))
32+ then throw("guessStart and guessEnd Must be in between 0-100")
33+ else {
34+ let randhash = randomizer(inv)
35+ let writeLastPlay = WriteSet([DataEntry("lastPlay", randhash)])
36+ let rand = (toInt(randhash) % 1000)
37+ if (if ((guessEnd > rand))
38+ then (rand > guessStart)
39+ else false)
40+ then ScriptResult(writeLastPlay, TransferSet([ScriptTransfer(inv.caller, ((payment.amount * 190) / 100), unit)]))
41+ else ScriptResult(writeLastPlay, TransferSet(nil))
42+ }
3543 }
3644
3745
3846 @Callable(inv)
39-func lotto () = startLotto(inv)
40-
41-
42-
43-@Callable(inv)
44-func default () = startLotto(inv)
47+func zero2hero (guessStart,guessEnd) = startLotto(inv, guessStart, guessEnd)
4548
4649

github/deemru/w8io/169f3d6 
40.27 ms