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:BgIKCAISBAoCAggSAAQADGtVc2VyUGF5bWVudAIHUGF5bWVudAAEa1dvbgIDV29uAAlzZXBhcmF0b3ICAS8BCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQEFBGhhc2gJAGoCBQVpbmRleAUFcmFuZ2UCAWkBCGNvdW50aW5nAgVieXRlcwZjYWxsZXIDCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgpPbmx5IG93bmVyBAVjb3VudAkBCXJhbmRvbWl6ZQIJAMkBAgUFYnl0ZXMJAGkCCQDIAQEFBWJ5dGVzAAIACgMJAGcCBQVjb3VudAADCQDMCAIJAQxCb29sZWFuRW50cnkCCQCsAgIJAKwCAgUEa1dvbgUJc2VwYXJhdG9yBQZjYWxsZXIHBQNuaWwJAMwIAgkBDEJvb2xlYW5FbnRyeQIJAKwCAgkArAICBQRrV29uBQlzZXBhcmF0b3IFBmNhbGxlcgYFA25pbAFpAQlzdGFydEdhbWUABAZhbW91bnQJAQV2YWx1ZQEICQCRAwI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RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAOplpGo=", "height": 2228935, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: E1t2f8ivUBNzS5n4anzwnXF4M5X19xqNydmrgtkxfHFW Next: ATsU1m5FkF1XgRi25BpbYtVX5ExNu2Wz23Mgyja5zCwH Diff:
OldNewDifferences
44 let kUserPayment = "Payment"
55
66 let kWon = "Won"
7+
8+let separator = "/"
79
810 func randomize (bytes,range) = {
911 let hash = sha256(bytes)
1214 }
1315
1416
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-
2317 @Callable(i)
24-func parseStruct () = if ((i.caller != this))
18+func counting (bytes,caller) = if ((i.caller != this))
2519 then throw("Only owner")
2620 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)]
2925 }
3026
3127
3531 let amount = value(i.payments[0].amount)
3632 if ((i.payments[0].assetId != unit))
3733 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+ }
4947 }
5048
5149
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let kUserPayment = "Payment"
55
66 let kWon = "Won"
7+
8+let separator = "/"
79
810 func randomize (bytes,range) = {
911 let hash = sha256(bytes)
1012 let index = toInt(hash)
1113 (index % range)
1214 }
1315
1416
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-
2317 @Callable(i)
24-func parseStruct () = if ((i.caller != this))
18+func counting (bytes,caller) = if ((i.caller != this))
2519 then throw("Only owner")
2620 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)]
2925 }
3026
3127
3228
3329 @Callable(i)
3430 func startGame () = {
3531 let amount = value(i.payments[0].amount)
3632 if ((i.payments[0].assetId != unit))
3733 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+ }
4947 }
5048
5149

github/deemru/w8io/169f3d6 
58.02 ms