tx · EWhxDghjf4nub9VR5wui8HgjXU49HmxQw9uYPpveuS4h 3NBYuiC6eFv2jT8DptUfiMDTbhXgFvn7NcK: -0.04000000 Waves 2020.10.30 00:41 [1242483] smart account 3NBYuiC6eFv2jT8DptUfiMDTbhXgFvn7NcK > SELF 0.00000000 Waves
{ "type": 13, "id": "EWhxDghjf4nub9VR5wui8HgjXU49HmxQw9uYPpveuS4h", "fee": 4000000, "feeAssetId": null, "timestamp": 1604007744046, "version": 2, "chainId": 84, "sender": "3NBYuiC6eFv2jT8DptUfiMDTbhXgFvn7NcK", "senderPublicKey": "BN5UNNa95ZrPJ8JGf9eweh6CLRZ618MuRsvqmxPX1yTR", "proofs": [ "2TuBGDWgNxRkhe9sWQFX41jD4bHaeJsHQ8cTrbPRvW2japmcddrw6tSFVnkUSCxw9BUKCgTB5NSzHGkZvddfBjAc" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQgAAAADAQAAAAdpc093bmVyAAAAAQAAAAdhZGRyZXNzCQAAAAAAAAIFAAAAB2FkZHJlc3MFAAAABHRoaXMBAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAABQAAAAN2YWwBAAAAD2dldEludGVnZXJCeUtleQAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIAAAAAAAAAAAAFAAAAA3ZhbAAAAAIAAAABaQEAAAAJYWRkQW5zd2VyAAAAAQAAAAZBbnN3ZXIDCQEAAAABIQAAAAEJAQAAAAdpc093bmVyAAAAAQgFAAAAAWkAAAAGY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YUVudHJ5AAAAAgkAASwAAAACCQACWgAAAAEJAAGbAAAAAQUAAAAFR3Vlc3MCAAAAB19yZXdhcmQAAAAAAAAAAAAFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABnJld2FyZAUAAAAEdW5pdAUAAAADbmlsCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAx3cm9uZ19ndWVzc18JAAQlAAAAAQgFAAAAAWkAAAAGY2FsbGVyAgAAAAFfCQACWAAAAAEIBQAAAAFpAAAADXRyYW5zYWN0aW9uSWQFAAAABUd1ZXNzBQAAAANuaWwAAAAArw7abQ==", "height": 1242483, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7LuiNFT1zC7SZmC16D4qvEJzBk6mqpU8zCFpWVJABCnB Next: JE3n4hdNK4yo2vwwzeGzmMSAZAsNDugyqsAuR35cq4y1 Diff:
Old | New | Differences | |
---|---|---|---|
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Callable(i) | |
42 | - | func guessAnswer (Guess) = if ((getStringByKey("hash_ | |
42 | + | func guessAnswer (Guess) = if ((getStringByKey("hash_answer") == toBase64String(toBytes(Guess)))) | |
43 | 43 | then { | |
44 | 44 | let reward = getIntegerByKey((toBase64String(toBytes(Guess)) + "_reward")) | |
45 | 45 | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), 0)]), TransferSet([ScriptTransfer(i.caller, reward, unit)])) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func isOwner (address) = (address == this) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func getStringByKey (key) = { | |
8 | 8 | let val = match getString(this, key) { | |
9 | 9 | case b: String => | |
10 | 10 | b | |
11 | 11 | case _ => | |
12 | 12 | "" | |
13 | 13 | } | |
14 | 14 | val | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | ||
18 | 18 | func getIntegerByKey (key) = { | |
19 | 19 | let val = match getInteger(this, key) { | |
20 | 20 | case b: Int => | |
21 | 21 | b | |
22 | 22 | case _ => | |
23 | 23 | 0 | |
24 | 24 | } | |
25 | 25 | val | |
26 | 26 | } | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | @Callable(i) | |
30 | 30 | func addAnswer (Answer) = if (!(isOwner(i.caller))) | |
31 | 31 | then throw("access only by the contract owner") | |
32 | 32 | else if ((getIntegerByKey((Answer + "_reward")) != 0)) | |
33 | 33 | then throw("the contest is already taken") | |
34 | 34 | else { | |
35 | 35 | let reward = extract(i.payment).amount | |
36 | 36 | WriteSet([DataEntry("hash_answer", Answer), DataEntry((Answer + "_reward"), reward), DataEntry("created_height", height)]) | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Callable(i) | |
42 | - | func guessAnswer (Guess) = if ((getStringByKey("hash_ | |
42 | + | func guessAnswer (Guess) = if ((getStringByKey("hash_answer") == toBase64String(toBytes(Guess)))) | |
43 | 43 | then { | |
44 | 44 | let reward = getIntegerByKey((toBase64String(toBytes(Guess)) + "_reward")) | |
45 | 45 | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), 0)]), TransferSet([ScriptTransfer(i.caller, reward, unit)])) | |
46 | 46 | } | |
47 | 47 | else WriteSet([DataEntry(((("wrong_guess_" + toString(i.caller)) + "_") + toBase58String(i.transactionId)), Guess)]) | |
48 | 48 | ||
49 | 49 |
github/deemru/w8io/026f985 21.05 ms ◑