tx · DRyXAq4JA5fnrv16xUc1vE2iK9rqixipUqg1ZWgM3Pa7 3MqvjXotwuiF933mjQm5G9v1ER6BLhakd3f: -0.04000000 Waves 2020.10.30 22:06 [1243758] smart account 3MqvjXotwuiF933mjQm5G9v1ER6BLhakd3f > SELF 0.00000000 Waves
{ "type": 13, "id": "DRyXAq4JA5fnrv16xUc1vE2iK9rqixipUqg1ZWgM3Pa7", "fee": 4000000, "feeAssetId": null, "timestamp": 1604084826759, "version": 2, "chainId": 84, "sender": "3MqvjXotwuiF933mjQm5G9v1ER6BLhakd3f", "senderPublicKey": "7KWZVWSeHmn8VUNXWRRhrbjYaEqMnyWqk7UuEa9uMTW8", "proofs": [ "4JjZBnnvRbarrRkNvgRDVG1bshdWpVZABvdDZmZUuRa1eXpPwsrGdE6jQ4vnDmZf2RLV4JMev1jbzBV1AcbghZQY" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQgAAAADAQAAAAdpc093bmVyAAAAAQAAAAdhZGRyZXNzCQAAAAAAAAIFAAAAB2FkZHJlc3MFAAAABHRoaXMBAAAADmdldFN0cmluZ0J5S2V5AAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgIAAAAABQAAAAN2YWwBAAAAD2dldEludGVnZXJCeUtleQAAAAEAAAADa2V5BAAAAAN2YWwEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWIFAAAAByRtYXRjaDAFAAAAAWIAAAAAAAAAAAAFAAAAA3ZhbAAAAAIAAAABaQEAAAAJYWRkQW5zd2VyAAAAAQAAAAZBbnN3ZXIDCQEAAAABIQAAAAEJAQAAAAdpc093bmVyAAAAAQgFAAAAAWkAAAAGY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AAAAlEYXRhRW50cnkAAAACAgAAAAZ3aW5uZXIJAAQlAAAAAQgFAAAAAWkAAAAGY2FsbGVyCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIJAAJaAAAAAQkAAZsAAAABBQAAAAVHdWVzcwIAAAAHX3Jld2FyZAkAAGUAAAACBQAAAAZyZXdhcmQFAAAABnJld2FyZAUAAAADbmlsCQEAAAALVHJhbnNmZXJTZXQAAAABCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAGcmV3YXJkBQAAAAR1bml0BQAAAANuaWwJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAVmYWlsXwUAAAAGQW5zd2VyAgAAAAFfCQAEJQAAAAEIBQAAAAFpAAAABmNhbGxlcgIAAAABXwkAAlgAAAABCAUAAAABaQAAAA10cmFuc2FjdGlvbklkBQAAAAVHdWVzcwUAAAADbmlsAAAAAQAAAAJ0eAEAAAAQc3RhbmRhcmRWZXJpZmllcgAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5tGGWEg==", "height": 1243758, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9HQULWEHPdv5xqdv22QwgmLeh6PTgS8z559V1pzqb16D Next: none Diff:
Old | New | Differences | |
---|---|---|---|
46 | 46 | else if ((Answer == toBase64String(toBytes(Guess)))) | |
47 | 47 | then { | |
48 | 48 | let reward = getIntegerByKey((toBase64String(toBytes(Guess)) + "_reward")) | |
49 | - | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), | |
49 | + | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), (reward - reward))]), TransferSet([ScriptTransfer(i.caller, reward, unit)])) | |
50 | 50 | } | |
51 | 51 | else WriteSet([DataEntry(((((("fail_" + Answer) + "_") + toString(i.caller)) + "_") + toBase58String(i.transactionId)), Guess)]) | |
52 | 52 | } |
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)]) | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | ||
41 | 41 | @Callable(i) | |
42 | 42 | func guessAnswer (Guess) = { | |
43 | 43 | let Answer = getStringByKey("hash_answer") | |
44 | 44 | if ((getIntegerByKey((Answer + "_reward")) == 0)) | |
45 | 45 | then throw("sorry, game over") | |
46 | 46 | else if ((Answer == toBase64String(toBytes(Guess)))) | |
47 | 47 | then { | |
48 | 48 | let reward = getIntegerByKey((toBase64String(toBytes(Guess)) + "_reward")) | |
49 | - | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), | |
49 | + | ScriptResult(WriteSet([DataEntry("correct_answer", Guess), DataEntry("winner", toString(i.caller)), DataEntry((toBase64String(toBytes(Guess)) + "_reward"), (reward - reward))]), TransferSet([ScriptTransfer(i.caller, reward, unit)])) | |
50 | 50 | } | |
51 | 51 | else WriteSet([DataEntry(((((("fail_" + Answer) + "_") + toString(i.caller)) + "_") + toBase58String(i.transactionId)), Guess)]) | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | @Verifier(tx) | |
56 | 56 | func standardVerifier () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
57 | 57 |
github/deemru/w8io/169f3d6 26.14 ms ◑