tx · JDqoErKzh5gqXAcs2XHujyaJ9HqiB9XjcZBEjEasJdsK

3N1ksYzG4hPLmuDtkW14TUQ37XXPhhW4Lv6:  -0.01000000 Waves

2021.05.28 12:02 [1545310] smart account 3N1ksYzG4hPLmuDtkW14TUQ37XXPhhW4Lv6 > SELF 0.00000000 Waves

{ "type": 13, "id": "JDqoErKzh5gqXAcs2XHujyaJ9HqiB9XjcZBEjEasJdsK", "fee": 1000000, "feeAssetId": null, "timestamp": 1622192534369, "version": 2, "chainId": 84, "sender": "3N1ksYzG4hPLmuDtkW14TUQ37XXPhhW4Lv6", "senderPublicKey": "CbJW2q8kSE3DK1o9ofZb1nEqNk6NVCKXahRuCwnDCcGv", "proofs": [ "2bNUpELZk6Fw1Bq7NcNHt8TEqYKUouh9VoLykLaamqFCcJaPwZuya5FeEjvHkAoJoHtSBeTg4fEa9H691ubdyyDu" ], "script": "base64:AAIDAAAAAAAAAAYIARIAEgAAAAACAQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAACGxhc3RQbGF5BAAAAAckbWF0Y2gwCQAEHAAAAAIFAAAABHRoaXMCAAAACGxhc3RQbGF5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApCeXRlVmVjdG9yBAAAAAFzBQAAAAckbWF0Y2gwBQAAAAFzAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAARVbml0AQAAAAxXYXZlc0xvdHRvVjIJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IEAAAABHJhbmQJAADLAAAAAgkAAMsAAAACCQAAywAAAAIJAADLAAAAAgkAAMsAAAACBQAAAAhsYXN0UGxheQgFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQgFAAAACWxhc3RCbG9jawAAABNnZW5lcmF0aW9uU2lnbmF0dXJlCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAAAAJdGltZXN0YW1wCQABmgAAAAEIBQAAAAlsYXN0QmxvY2sAA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AD6AkBAAAADFNjcmlwdFJlc3VsdAAAAAIFAAAADXdyaXRlTGFzdFBsYXkFAAAAC3dpblRyYW5zZmVyCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAANd3JpdGVMYXN0UGxheQkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsAAAAAgAAAANpbnYBAAAABWxvdHRvAAAAAAkBAAAACnN0YXJ0TG90dG8AAAABBQAAAANpbnYAAAADaW52AQAAAAdkZWZhdWx0AAAAAAkBAAAACnN0YXJ0TG90dG8AAAABBQAAAANpbnYAAAAAPNtCCA==", "height": 1545310, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: HqWS8Ar4zssxhyNTTc1EeUvNUy8qGbwn6Lg9ofMTkDEg Next: none Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let answersCount = 20
5-
6-let answers = ["It is certain.", "It is decidedly so.", "Without a doubt.", "Yes - definitely.", "You may rely on it.", "As I see it, yes.", "Most likely.", "Outlook good.", "Yes.", "Signs point to yes.", "Reply hazy, try again.", "Ask again later.", "Better not tell you now.", "Cannot predict now.", "Concentrate and ask again.", "Don't count on it.", "My reply is no.", "My sources say no.", "Outlook not so good.", "Very doubtful."]
7-
8-func getAnswer (question,previousAnswer) = {
9- let hash = sha256(toBytes((question + previousAnswer)))
10- let index = toInt(hash)
11-answers[(index % answersCount)]
4+func randomizer (inv) = {
5+ let lastPlay = match getBinary(this, "lastPlay") {
6+ case s: ByteVector =>
7+ s
8+ case _: Unit =>
9+ base58'2ee4oFDYriWJ9EMeR'
10+ case _ =>
11+ throw("Match error")
12+ }
13+ let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height))
14+ sha256(rand)
1215 }
1316
1417
15-func getPreviousAnswer (address) = match getString(this, (address + "_a")) {
16- case a: String =>
17- a
18- case _ =>
19- address
20-}
18+func startLotto (inv) = {
19+ let playLimit = (wavesBalance(this) / 100)
20+ let payment = extract(inv.payment)
21+ if (!(isDefined(inv.payment)))
22+ then throw("Should be with Payment in Waves")
23+ else if (isDefined(payment.assetId))
24+ then throw("Payment should be in Waves")
25+ else if ((payment.amount > playLimit))
26+ 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+ }
35+ }
2136
2237
23-@Callable(i)
24-func tellme (question) = {
25- let callerAddress = toBase58String(i.caller.bytes)
26- let answer = getAnswer(question, getPreviousAnswer(callerAddress))
27- WriteSet([DataEntry((callerAddress + "_q"), question), DataEntry((callerAddress + "_a"), answer)])
28- }
38+@Callable(inv)
39+func lotto () = startLotto(inv)
40+
41+
42+
43+@Callable(inv)
44+func default () = startLotto(inv)
2945
3046

github/deemru/w8io/169f3d6 
354.05 ms