tx · GsizKh7j4ggip5T1gJgTWa6ZCXBZiJ7cAAwJrQvE8Qx8 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.00200000 Waves 2022.09.14 18:09 [2228935] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{ "type": 13, "id": "GsizKh7j4ggip5T1gJgTWa6ZCXBZiJ7cAAwJrQvE8Qx8", "fee": 200000, "feeAssetId": null, "timestamp": 1663168194011, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "4Kczgq1VYuGWx4PJyh1BGuLYv48wXWhAMt3VRykAkQMdsiiNxtJrtTgrJrJqBQZxtPyY9hXagE3z8fZ7ZvZcH7Ke" ], "script": "base64:BgIKCAISBAoCAggSAAQADGtVc2VyUGF5bWVudAIHUGF5bWVudAAEa1dvbgIDV29uAAlzZXBhcmF0b3ICAS8BCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQEFBGhhc2gJAGoCBQVpbmRleAUFcmFuZ2UCAWkBCGNvdW50aW5nAgVieXRlcwZjYWxsZXIDCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgpPbmx5IG93bmVyBAVjb3VudAkBCXJhbmRvbWl6ZQIJAMkBAgUFYnl0ZXMJAGkCCQDIAQEFBWJ5dGVzAAIACgMJAGcCBQVjb3VudAADCQDMCAIJAQxCb29sZWFuRW50cnkCCQCsAgIJAKwCAgUEa1dvbgUJc2VwYXJhdG9yBQZjYWxsZXIHBQNuaWwJAMwIAgkBDEJvb2xlYW5FbnRyeQIJAKwCAgkArAICBQRrV29uBQlzZXBhcmF0b3IFBmNhbGxlcgYFA25pbAFpAQlzdGFydEdhbWUABAZhbW91bnQJAQV2YWx1ZQEICQCRAwII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yaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAOplpGo=", "height": 2228935, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: E1t2f8ivUBNzS5n4anzwnXF4M5X19xqNydmrgtkxfHFW Next: ATsU1m5FkF1XgRi25BpbYtVX5ExNu2Wz23Mgyja5zCwH Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let kUserPayment = "Payment" | |
5 | 5 | ||
6 | 6 | let kWon = "Won" | |
7 | + | ||
8 | + | let separator = "/" | |
7 | 9 | ||
8 | 10 | func randomize (bytes,range) = { | |
9 | 11 | let hash = sha256(bytes) | |
12 | 14 | } | |
13 | 15 | ||
14 | 16 | ||
15 | - | func counting (bytes) = { | |
16 | - | let count = randomize(bytes, 10) | |
17 | - | if ((count >= 4)) | |
18 | - | then BooleanEntry(kWon, false) | |
19 | - | else BooleanEntry(kWon, true) | |
20 | - | } | |
21 | - | ||
22 | - | ||
23 | 17 | @Callable(i) | |
24 | - | func | |
18 | + | func counting (bytes,caller) = if ((i.caller != this)) | |
25 | 19 | then throw("Only owner") | |
26 | 20 | else { | |
27 | - | let winnerStruct = counting(i.transactionId) | |
28 | - | [winnerStruct] | |
21 | + | let count = randomize(take(bytes, (size(bytes) / 2)), 10) | |
22 | + | if ((count >= 3)) | |
23 | + | then [BooleanEntry(((kWon + separator) + caller), false)] | |
24 | + | else [BooleanEntry(((kWon + separator) + caller), true)] | |
29 | 25 | } | |
30 | 26 | ||
31 | 27 | ||
35 | 31 | let amount = value(i.payments[0].amount) | |
36 | 32 | if ((i.payments[0].assetId != unit)) | |
37 | 33 | then throw("Pay in waves") | |
38 | - | else { | |
39 | - | let nullInitStore = invoke(this, "parseStruct", nil, nil) | |
40 | - | if ((nullInitStore == nullInitStore)) | |
41 | - | then { | |
42 | - | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") | |
43 | - | if (won) | |
44 | - | then [ScriptTransfer(i.caller, (amount * 2), unit)] | |
45 | - | else nil | |
46 | - | } | |
47 | - | else throw("Strict value is not equal to itself.") | |
48 | - | } | |
34 | + | else if ((amount > 10)) | |
35 | + | then throw("Maximum bet 10 waves") | |
36 | + | else { | |
37 | + | let nullInitStore = invoke(this, "counting", [i.transactionId, toString(i.caller)], nil) | |
38 | + | if ((nullInitStore == nullInitStore)) | |
39 | + | then { | |
40 | + | let won = valueOrErrorMessage(getBoolean(this, ((kWon + separator) + toString(i.caller))), "Storage read error") | |
41 | + | if (won) | |
42 | + | then [ScriptTransfer(i.caller, (amount * 2), unit), DeleteEntry(((kWon + separator) + toString(i.caller))), BooleanEntry(((((kWon + separator) + toString(i.caller)) + separator) + toString(randomize(i.transactionId, 1000))), true)] | |
43 | + | else [DeleteEntry(((kWon + separator) + toString(i.caller))), BooleanEntry(((((kWon + separator) + toString(i.caller)) + separator) + toString(randomize(i.transactionId, 1000))), false)] | |
44 | + | } | |
45 | + | else throw("Strict value is not equal to itself.") | |
46 | + | } | |
49 | 47 | } | |
50 | 48 | ||
51 | 49 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let kUserPayment = "Payment" | |
5 | 5 | ||
6 | 6 | let kWon = "Won" | |
7 | + | ||
8 | + | let separator = "/" | |
7 | 9 | ||
8 | 10 | func randomize (bytes,range) = { | |
9 | 11 | let hash = sha256(bytes) | |
10 | 12 | let index = toInt(hash) | |
11 | 13 | (index % range) | |
12 | 14 | } | |
13 | 15 | ||
14 | 16 | ||
15 | - | func counting (bytes) = { | |
16 | - | let count = randomize(bytes, 10) | |
17 | - | if ((count >= 4)) | |
18 | - | then BooleanEntry(kWon, false) | |
19 | - | else BooleanEntry(kWon, true) | |
20 | - | } | |
21 | - | ||
22 | - | ||
23 | 17 | @Callable(i) | |
24 | - | func | |
18 | + | func counting (bytes,caller) = if ((i.caller != this)) | |
25 | 19 | then throw("Only owner") | |
26 | 20 | else { | |
27 | - | let winnerStruct = counting(i.transactionId) | |
28 | - | [winnerStruct] | |
21 | + | let count = randomize(take(bytes, (size(bytes) / 2)), 10) | |
22 | + | if ((count >= 3)) | |
23 | + | then [BooleanEntry(((kWon + separator) + caller), false)] | |
24 | + | else [BooleanEntry(((kWon + separator) + caller), true)] | |
29 | 25 | } | |
30 | 26 | ||
31 | 27 | ||
32 | 28 | ||
33 | 29 | @Callable(i) | |
34 | 30 | func startGame () = { | |
35 | 31 | let amount = value(i.payments[0].amount) | |
36 | 32 | if ((i.payments[0].assetId != unit)) | |
37 | 33 | then throw("Pay in waves") | |
38 | - | else { | |
39 | - | let nullInitStore = invoke(this, "parseStruct", nil, nil) | |
40 | - | if ((nullInitStore == nullInitStore)) | |
41 | - | then { | |
42 | - | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") | |
43 | - | if (won) | |
44 | - | then [ScriptTransfer(i.caller, (amount * 2), unit)] | |
45 | - | else nil | |
46 | - | } | |
47 | - | else throw("Strict value is not equal to itself.") | |
48 | - | } | |
34 | + | else if ((amount > 10)) | |
35 | + | then throw("Maximum bet 10 waves") | |
36 | + | else { | |
37 | + | let nullInitStore = invoke(this, "counting", [i.transactionId, toString(i.caller)], nil) | |
38 | + | if ((nullInitStore == nullInitStore)) | |
39 | + | then { | |
40 | + | let won = valueOrErrorMessage(getBoolean(this, ((kWon + separator) + toString(i.caller))), "Storage read error") | |
41 | + | if (won) | |
42 | + | then [ScriptTransfer(i.caller, (amount * 2), unit), DeleteEntry(((kWon + separator) + toString(i.caller))), BooleanEntry(((((kWon + separator) + toString(i.caller)) + separator) + toString(randomize(i.transactionId, 1000))), true)] | |
43 | + | else [DeleteEntry(((kWon + separator) + toString(i.caller))), BooleanEntry(((((kWon + separator) + toString(i.caller)) + separator) + toString(randomize(i.transactionId, 1000))), false)] | |
44 | + | } | |
45 | + | else throw("Strict value is not equal to itself.") | |
46 | + | } | |
49 | 47 | } | |
50 | 48 | ||
51 | 49 |
github/deemru/w8io/169f3d6 58.02 ms ◑