tx · CY1zC1EEC1hPY7M8Bn62DaKGKX61pk4jg2Tt2NBbWmdw

3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H:  -0.00200000 Waves

2022.08.21 13:28 [2194095] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves

{ "type": 13, "id": "CY1zC1EEC1hPY7M8Bn62DaKGKX61pk4jg2Tt2NBbWmdw", "fee": 200000, "feeAssetId": null, "timestamp": 1661077764384, "version": 2, "chainId": 84, "sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H", "senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu", "proofs": [ "31upUMe63F9wHhC1tdFjHJBoPgnpaXJsfrbbFEVoGTViQUkZ2QXgPpyvipNnduZsa6rgakj3mZ8nYfBityX7Apdy" ], "script": "base64:BgIICAISABIAEgAGAAxrVXNlclBheW1lbnQCB1BheW1lbnQABGtXb24CA1dvbgAJc2VwYXJhdG9yAgEvAA9zZXBhcmF0b3JTZWNvbmQCAXwBCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQEFBGhhc2gJAGoCBQVpbmRleAUFcmFuZ2UBCGNvdW50aW5nAgVieXRlcwZjYWxsZXIEBWNvdW50CQEJcmFuZG9taXplAgUFYnl0ZXMACgMJAGcCBQVjb3VudAAECQELU3RyaW5nRW50cnkCBQRrV29uCQCsAgIJAKwCAgkArAICCQCsAgIJAKUIAQUGY2FsbGVyBQlzZXBhcmF0b3ICBWZhbHNlBQ9zZXBhcmF0b3JTZWNvbmQJARFAZXh0ck5hdGl2ZSgxMDUzKQIFBHRoaXMFBGtXb24JAQtTdHJpbmdFbnRyeQIFBGtXb24JAKwCAgkArAICCQCsAgIJAKwCAgkApQgBBQZjYWxsZXIFCXNlcGFyYXRvcgIEdHJ1ZQUPc2VwYXJhdG9yU2Vjb25kCQERQGV4dHJOYXRpdmUoMTA1MykCBQR0aGlzBQRrV29uAwFpAQlpbml0U3RvcmUACQDMCAIJAQtTdHJpbmdFbnRyeQIFBGtXb24CATAFA25pbAFpAQtwYXJzZVN0cnVjdAAEDW51bGxJbml0U3RvcmUJAP0HBAUEdGhpcwIJaW5pdFN0b3JlBQNuaWwFA25pbAMJAAACBQ1udWxsSW5pdFN0b3JlBQ1udWxsSW5pdFN0b3JlAwkBAiE9AggFAWkGY2FsbGVyBQR0aGlzCQACAQIKT25seSBvd25lcgQMd2lubmVyU3RydWN0CQEIY291bnRpbmcCCAUBaQ10cmFuc2FjdGlvbklkCAUBaQZjYWxsZXIJAMwIAgUMd2lubmVyU3RydWN0BQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BaQEJc3RhcnRHYW1lAAQGYW1vdW50CQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdW5pdAkAAgECDFBheSBpbiB3YXZlcwMJAGYCBQZhbW91bnQAFAkAAgECG1lvdSBjYW5ub3QgYmV0IG1vcmUgdGhhbiAyMAQNbnVsbEluaXRTdG9yZQkA/AcEBQR0aGlzAgtwYXJzZVN0cnVjdAUDbmlsBQNuaWwDCQAAAgUNbnVsbEluaXRTdG9yZQUNbnVsbEluaXRTdG9yZQQDd29uCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJsIAgUEdGhpcwUEa1dvbgISU3RvcmFnZSByZWFkIGVycm9yAwUDd29uCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgkAaAIFBmFtb3VudAACBQR1bml0BQNuaWwFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgDBLmj0", "height": 2194095, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G5HsWEG4PSvPz3RHYLs256AAF6n9Vgcnoesi12ECVouG Next: He1ntbKUnrKrALKpgj6xSt5nPfnjJX5ra5dKz9NEMZrL Diff:
OldNewDifferences
44 let kUserPayment = "Payment"
55
66 let kWon = "Won"
7+
8+let separator = "/"
9+
10+let separatorSecond = "|"
711
812 func randomize (bytes,range) = {
913 let hash = sha256(bytes)
1216 }
1317
1418
15-func counting (bytes) = {
19+func counting (bytes,caller) = {
1620 let count = randomize(bytes, 10)
1721 if ((count >= 4))
18- then BooleanEntry(kWon, false)
19- else BooleanEntry(kWon, true)
22+ then StringEntry(kWon, ((((toString(caller) + separator) + "false") + separatorSecond) + getStringValue(this, kWon)))
23+ else StringEntry(kWon, ((((toString(caller) + separator) + "true") + separatorSecond) + getStringValue(this, kWon)))
2024 }
2125
2226
2327 @Callable(i)
24-func parseStruct () = if ((i.caller != this))
25- then throw("Only owner")
26- else {
27- let winnerStruct = counting(i.transactionId)
28+func initStore () = [StringEntry(kWon, "0")]
29+
30+
31+
32+@Callable(i)
33+func parseStruct () = {
34+ let nullInitStore = reentrantInvoke(this, "initStore", nil, nil)
35+ if ((nullInitStore == nullInitStore))
36+ then if ((i.caller != this))
37+ then throw("Only owner")
38+ else {
39+ let winnerStruct = counting(i.transactionId, i.caller)
2840 [winnerStruct]
29- }
41+ }
42+ else throw("Strict value is not equal to itself.")
43+ }
3044
3145
3246
3549 let amount = value(i.payments[0].amount)
3650 if ((i.payments[0].assetId != unit))
3751 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 ((amount >= 10))
44- then nil
45- else if (won)
52+ else if ((amount > 20))
53+ then throw("You cannot bet more than 20")
54+ else {
55+ let nullInitStore = invoke(this, "parseStruct", nil, nil)
56+ if ((nullInitStore == nullInitStore))
57+ then {
58+ let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error")
59+ if (won)
4660 then [ScriptTransfer(i.caller, (amount * 2), unit)]
4761 else nil
48- }
49- else throw("Strict value is not equal to itself.")
50- }
62+ }
63+ else throw("Strict value is not equal to itself.")
64+ }
5165 }
5266
5367
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 = "/"
9+
10+let separatorSecond = "|"
711
812 func randomize (bytes,range) = {
913 let hash = sha256(bytes)
1014 let index = toInt(hash)
1115 (index % range)
1216 }
1317
1418
15-func counting (bytes) = {
19+func counting (bytes,caller) = {
1620 let count = randomize(bytes, 10)
1721 if ((count >= 4))
18- then BooleanEntry(kWon, false)
19- else BooleanEntry(kWon, true)
22+ then StringEntry(kWon, ((((toString(caller) + separator) + "false") + separatorSecond) + getStringValue(this, kWon)))
23+ else StringEntry(kWon, ((((toString(caller) + separator) + "true") + separatorSecond) + getStringValue(this, kWon)))
2024 }
2125
2226
2327 @Callable(i)
24-func parseStruct () = if ((i.caller != this))
25- then throw("Only owner")
26- else {
27- let winnerStruct = counting(i.transactionId)
28+func initStore () = [StringEntry(kWon, "0")]
29+
30+
31+
32+@Callable(i)
33+func parseStruct () = {
34+ let nullInitStore = reentrantInvoke(this, "initStore", nil, nil)
35+ if ((nullInitStore == nullInitStore))
36+ then if ((i.caller != this))
37+ then throw("Only owner")
38+ else {
39+ let winnerStruct = counting(i.transactionId, i.caller)
2840 [winnerStruct]
29- }
41+ }
42+ else throw("Strict value is not equal to itself.")
43+ }
3044
3145
3246
3347 @Callable(i)
3448 func startGame () = {
3549 let amount = value(i.payments[0].amount)
3650 if ((i.payments[0].assetId != unit))
3751 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 ((amount >= 10))
44- then nil
45- else if (won)
52+ else if ((amount > 20))
53+ then throw("You cannot bet more than 20")
54+ else {
55+ let nullInitStore = invoke(this, "parseStruct", nil, nil)
56+ if ((nullInitStore == nullInitStore))
57+ then {
58+ let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error")
59+ if (won)
4660 then [ScriptTransfer(i.caller, (amount * 2), unit)]
4761 else nil
48- }
49- else throw("Strict value is not equal to itself.")
50- }
62+ }
63+ else throw("Strict value is not equal to itself.")
64+ }
5165 }
5266
5367

github/deemru/w8io/169f3d6 
62.31 ms