tx · FqTcP3grSEKD4mt7Ty3hVR2uqhe3yExPYTAX8BNcQjur 3N9AyhDkGcMusujZTk6zGTswZ3ubzvZtzDo: -0.01400000 Waves 2019.09.07 20:27 [665963] smart account 3N9AyhDkGcMusujZTk6zGTswZ3ubzvZtzDo > SELF 0.00000000 Waves
{ "type": 13, "id": "FqTcP3grSEKD4mt7Ty3hVR2uqhe3yExPYTAX8BNcQjur", "fee": 1400000, "feeAssetId": null, "timestamp": 1567877321755, "version": 1, "sender": "3N9AyhDkGcMusujZTk6zGTswZ3ubzvZtzDo", "senderPublicKey": "BK7BG4WB6fH1cw6jwHd5EditXDSkVR7W1CjmVf5RMEVx", "proofs": [ "4KFa24Y8Tu3uzgCSd3qK59EY5pNLEQkg7gAPpEeh6GZkxdxQV52fDStkihTqis8uAxEnKsC9WFaHdQLcLJ4NVrSi" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAAAAAAxhbnN3ZXJzQ291bnQAAAAAAAAAABQAAAAAB2Fuc3dlcnMJAARMAAAAAgIAAAAOSXQgaXMgY2VydGFpbi4JAARMAAAAAgIAAAATSXQgaXMgZGVjaWRlZGx5IHNvLgkABEwAAAACAgAAABBXaXRob3V0IGEgZG91YnQuCQAETAAAAAICAAAAEVllcyAtIGRlZmluaXRlbHkuCQAETAAAAAICAAAAE1lvdSBtYXkgcmVseSBvbiBpdC4JAARMAAAAAgIAAAARQXMgSSBzZWUgaXQsIHllcy4JAARMAAAAAgIAAAAMTW9zdCBsaWtlbHkuCQAETAAAAAICAAAADU91dGxvb2sgZ29vZC4JAARMAAAAAgIAAAAEWWVzLgkABEwAAAACAgAAABNTaWducyBwb2ludCB0byB5ZXMuCQAETAAAAAICAAAAFlJlcGx5IGhhenksIHRyeSBhZ2Fpbi4JAARMAAAAAgIAAAAQQXNrIGFnYWluIGxhdGVyLgkABEwAAAACAgAAABhCZXR0ZXIgbm90IHRlbGwgeW91IG5vdy4JAARMAAAAAgIAAAATQ2Fubm90IHByZWRpY3Qgbm93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AACX3EFAAAACHF1ZXN0aW9uCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAADWNhbGxlckFkZHJlc3MCAAAAAl9hBQAAAAZhbnN3ZXIFAAAAA25pbAAAAACOjDZR", "chainId": 84, "height": 665963, "spentComplexity": 0 } View: original | compacted Prev: Cf9eeUpsHU2UFFkt3fWEXyjCgA55ru8X2K1hWU96te6C Next: 6SewSQZ5Q1hxSgFNuhTHCaSDbXGiAAycr1tDc6BYoWqz Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | func randomizer (inv) = { | |
5 | - | let lastPlay = match getBinary(this, "lastPlay") { | |
6 | - | case s: ByteVector => | |
7 | - | s | |
8 | - | case a: Unit => | |
9 | - | base58'2ee4oFDYriWJ9EMeR' | |
10 | - | case _ => | |
11 | - | throw() | |
12 | - | } | |
13 | - | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
14 | - | sha256(rand) | |
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)] | |
15 | 12 | } | |
16 | 13 | ||
17 | 14 | ||
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 | - | } | |
15 | + | func getPreviousAnswer (address) = match getString(this, (address + "_a")) { | |
16 | + | case a: String => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | address | |
20 | + | } | |
36 | 21 | ||
37 | 22 | ||
38 | - | @Callable(inv) | |
39 | - | func lotto () = startLotto(inv) | |
40 | - | ||
41 | - | ||
42 | - | ||
43 | - | @Callable(inv) | |
44 | - | func default () = startLotto(inv) | |
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 | + | } | |
45 | 29 | ||
46 | 30 |
github/deemru/w8io/169f3d6 60.54 ms ◑