tx · 3LJEkDYjQP13K4hbaG8schQnWPWigTSTCukiDpHmiftJ 3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx: -0.01000000 Waves 2022.04.03 19:14 [1992622] smart account 3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx > SELF 0.00000000 Waves
{ "type": 13, "id": "3LJEkDYjQP13K4hbaG8schQnWPWigTSTCukiDpHmiftJ", "fee": 1000000, "feeAssetId": null, "timestamp": 1649002455962, "version": 2, "chainId": 84, "sender": "3Mvjrd9jd9BEQvHoiHnPKR2WqtZnvxopDcx", "senderPublicKey": "B37Jiw5CgfjxqxYgkAGeJpTmiCa4Cb6a9mh9fynZppFR", "proofs": [ "2iN8H6v6FLvc58KpVxpFi86ENxr7f8H9YQJBirYUiRANkQHFJxNTuYsEdGqnyrdv7b8dhKgKnuffr7Q9vYJHSGEy" ], "script": "base64:AAIFAAAAAAAAAAYIAhIAEgAAAAAEAAAAAAVvd25lcgkBAAAAB0FkZHJlc3MAAAABAQAAABoBVIxWe3zo2WPdJvaZ/FYhrveeShfFdKOL0AAAAAAHcGxheWVycwUAAAADbmlsAQAAAApyYW5kb21pemVyAAAAAQAAAANpbnYEAAAABHJhbmQJAADLAAAAAggFAAAAA2ludgAAAA10cmFuc2FjdGlvbklkCAUAAAADaW52AAAAD2NhbGxlclB1YmxpY0tleQkAAfcAAAABBQAAAARyYW5kAQAAABBhZGRQbGF5ZXJzVG9MaXN0AAAAAQAAAAFpCQAETQAAAAIFAAAAB3BsYXllcnMIBQAAAAFpAAAABmNhbGxlcgAAAAIAAAABaQEAAAAFZW50ZXIAAAAABAAAAAFhCQEAAAAQYWRkUGxheWVyc1RvTGlzdAAAAAEFAAAAAWkJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAEdGhpcwgJAAGRAAAAAggFAAAAAWkAAAAIcGF5bWVudHMAAAAAAAAAAAAAAAAGYW1vdW50BQAAAAR1bml0BQAAAANuaWwAAAABaQEAAAAKcGlja1dpbm5lcgAAAAADCQAAAAAAAAIIBQAAAAFpAAAABmNhbGxlcgUAAAAFb3duZXIEAAAAD251bWJlck9mUGxheWVycwkAAZAAAAABBQAAAAdwbGF5ZXJzBAAAAARyYW5kCQAEsQAAAAEJAQAAAApyYW5kb21pemVyAAAAAQUAAAABaQQAAAAOc2VsZWN0ZWRQbGF5ZXIJAAGRAAAAAgUAAAAHcGxheWVycwkAAGoAAAACBQAAAARyYW5kBQAAAA9udW1iZXJPZlBsYXllcnMJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAOc2VsZWN0ZWRQbGF5ZXIJAABpAAAAAgkAAGgAAAACCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQAAAAAAAAAAFAAAAAAAAAAAGQFAAAABHVuaXQJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwUAAAAFb3duZXIJAABpAAAAAgkAAGgAAAACCAkAAZEAAAACCAUAAAABaQAAAAhwYXltZW50cwAAAAAAAAAAAAAAAAZhbW91bnQAAAAAAAAAABQAAAAAAAAAAGQFAAAABHVuaXQFAAAAA25pbAkAAAIAAAABAgAAABZZb3UgaGF2ZW50IHBlcm1pc3Npb25zAAAAAQAAAAJ0eAEAAAAGdmVyaWZ5AAAAAAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkuBpwy", "height": 1992622, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8kfuxeZDrfay4hTwuabCkr38tbrwXWgN5nAnAP4J8JNq Next: BUkATxQA4GqH7itNNGhY8V4HnggxEkofvX1uAa8KFxpe Full:
Old | New | Differences | |
---|---|---|---|
1 | - | {-# STDLIB_VERSION | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let owner = Address(base58'3N2i7ygFVfQLEoupDNpBT7FLcjh4Sb38wm9') | |
5 | 5 | ||
6 | - | let | |
6 | + | let players = nil | |
7 | 7 | ||
8 | - | func getAnswer (question,previousAnswer) = { | |
9 | - | let hash = sha256(toBytes((question + previousAnswer))) | |
10 | - | let index = toInt(hash) | |
11 | - | answers[(index % answersCount)] | |
8 | + | func randomizer (inv) = { | |
9 | + | let rand = (inv.transactionId + inv.callerPublicKey) | |
10 | + | sha256(rand) | |
12 | 11 | } | |
13 | 12 | ||
14 | 13 | ||
15 | - | func getPreviousAnswer (address) = match getString(this, (address + "_a")) { | |
16 | - | case a: String => | |
17 | - | a | |
18 | - | case _ => | |
19 | - | address | |
20 | - | } | |
14 | + | func addPlayersToList (i) = (players :+ i.caller) | |
21 | 15 | ||
22 | 16 | ||
23 | 17 | @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)]) | |
18 | + | func enter () = { | |
19 | + | let a = addPlayersToList(i) | |
20 | + | [ScriptTransfer(this, i.payments[0].amount, unit)] | |
28 | 21 | } | |
29 | 22 | ||
23 | + | ||
24 | + | ||
25 | + | @Callable(i) | |
26 | + | func pickWinner () = if ((i.caller == owner)) | |
27 | + | then { | |
28 | + | let numberOfPlayers = size(players) | |
29 | + | let rand = toInt(randomizer(i)) | |
30 | + | let selectedPlayer = players[(rand % numberOfPlayers)] | |
31 | + | [ScriptTransfer(selectedPlayer, ((i.payments[0].amount * 80) / 100), unit), ScriptTransfer(owner, ((i.payments[0].amount * 20) / 100), unit)] | |
32 | + | } | |
33 | + | else throw("You havent permissions") | |
34 | + | ||
35 | + | ||
36 | + | @Verifier(tx) | |
37 | + | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
30 | 38 |
github/deemru/w8io/026f985 29.76 ms ◑