tx · 3vwLZBXeXpbhppwPw7YWyWxpcZujg1Ssb4VhDAX628e2
3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H: -0.00100000 Waves
2022.08.21 16:06 [2194260] smart account 3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H > SELF 0.00000000 Waves
{
"type": 13,
"id": "3vwLZBXeXpbhppwPw7YWyWxpcZujg1Ssb4VhDAX628e2",
"fee": 100000,
"feeAssetId": null,
"timestamp": 1661087241231,
"version": 2,
"chainId": 84,
"sender": "3N4boZRUJ2LxY5jLyp6hmxGktqnawQidu6H",
"senderPublicKey": "BDeCphaaC4MZvfmbJqQZ78EvuEBZTJ1VEW7fbxue8BUu",
"proofs": [
"3QhRkf4i4QRv3qZ3tLgqRZ8UnoGtcRCZZc5dweZgKatn4r8U8gaZMM2gxN4qntso1Zyyb96g4t3aSrYMYboJPAa5"
],
"script": "base64:BgIGCAISABIABAAMa1VzZXJQYXltZW50AgdQYXltZW50AARrV29uAgNXb24BCXJhbmRvbWl6ZQIFYnl0ZXMFcmFuZ2UEBGhhc2gJAPcDAQUFYnl0ZXMEBWluZGV4CQCxCQEFBGhhc2gJAGoCBQVpbmRleAUFcmFuZ2UBCGNvdW50aW5nAQVieXRlcwQFY291bnQJAQlyYW5kb21pemUCBQVieXRlcwAKAwkAZwIFBWNvdW50AAQJAQxCb29sZWFuRW50cnkCBQRrV29uBwkBDEJvb2xlYW5FbnRyeQIFBGtXb24GAgFpAQtwYXJzZVN0cnVjdAADCQECIT0CCAUBaQZjYWxsZXIFBHRoaXMJAAIBAgpPbmx5IG93bmVyBAx3aW5uZXJTdHJ1Y3QJAQhjb3VudGluZwEIBQFpDXRyYW5zYWN0aW9uSWQJAMwIAgUMd2lubmVyU3RydWN0BQNuaWwBaQEJc3RhcnRHYW1lAAQGYW1vdW50CQEFdmFsdWUBCAkAkQMCCAUBaQhwYXltZW50cwAABmFtb3VudAMJAQIhPQIICQCRAwIIBQFpCHBheW1lbnRzAAAHYXNzZXRJZAUEdW5pdAkAAgECDFBheSBpbiB3YXZlcwMJAGYCBQZhbW91bnQAFAkAAgECG1lvdSBjYW5ub3QgYmV0IG1vcmUgdGhhbiAyMAQNbnVsbEluaXRTdG9yZQkA/AcEBQR0aGlzAgtwYXJzZVN0cnVjdAUDbmlsBQNuaWwDCQAAAgUNbnVsbEluaXRTdG9yZQUNbnVsbEluaXRTdG9yZQQDd29uCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJsIAgUEdGhpcwUEa1dvbgISU3RvcmFnZSByZWFkIGVycm9yAwUDd29uCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgkAaAIFBmFtb3VudAACBQR1bml0BQNuaWwFA25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgDDISRQ",
"height": 2194260,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: He1ntbKUnrKrALKpgj6xSt5nPfnjJX5ra5dKz9NEMZrL
Next: 6cVfMR5CzMZpHZJNrqFrMuh6t53wzkP7ho4pJCEs53QL
Diff:
Old | New | | Differences |
---|
4 | 4 | | let kUserPayment = "Payment" |
---|
5 | 5 | | |
---|
6 | 6 | | let kWon = "Won" |
---|
7 | | - | |
---|
8 | | - | let separator = "/" |
---|
9 | | - | |
---|
10 | | - | let separatorSecond = "|" |
---|
11 | 7 | | |
---|
12 | 8 | | func randomize (bytes,range) = { |
---|
13 | 9 | | let hash = sha256(bytes) |
---|
|
16 | 12 | | } |
---|
17 | 13 | | |
---|
18 | 14 | | |
---|
19 | | - | func counting (bytes,caller) = { |
---|
| 15 | + | func counting (bytes) = { |
---|
20 | 16 | | let count = randomize(bytes, 10) |
---|
21 | 17 | | if ((count >= 4)) |
---|
22 | | - | then StringEntry(kWon, ((((toString(caller) + separator) + "false") + separatorSecond) + getStringValue(this, kWon))) |
---|
23 | | - | else StringEntry(kWon, ((((toString(caller) + separator) + "true") + separatorSecond) + getStringValue(this, kWon))) |
---|
| 18 | + | then BooleanEntry(kWon, false) |
---|
| 19 | + | else BooleanEntry(kWon, true) |
---|
24 | 20 | | } |
---|
25 | 21 | | |
---|
26 | 22 | | |
---|
27 | 23 | | @Callable(i) |
---|
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) |
---|
| 24 | + | func parseStruct () = if ((i.caller != this)) |
---|
| 25 | + | then throw("Only owner") |
---|
| 26 | + | else { |
---|
| 27 | + | let winnerStruct = counting(i.transactionId) |
---|
40 | 28 | | [winnerStruct] |
---|
41 | | - | } |
---|
42 | | - | else throw("Strict value is not equal to itself.") |
---|
43 | | - | } |
---|
| 29 | + | } |
---|
44 | 30 | | |
---|
45 | 31 | | |
---|
46 | 32 | | |
---|
|
52 | 38 | | else if ((amount > 20)) |
---|
53 | 39 | | then throw("You cannot bet more than 20") |
---|
54 | 40 | | else { |
---|
55 | | - | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") |
---|
56 | | - | if (won) |
---|
57 | | - | then [ScriptTransfer(i.caller, (amount * 2), unit)] |
---|
58 | | - | else nil |
---|
| 41 | + | let nullInitStore = invoke(this, "parseStruct", nil, nil) |
---|
| 42 | + | if ((nullInitStore == nullInitStore)) |
---|
| 43 | + | then { |
---|
| 44 | + | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") |
---|
| 45 | + | if (won) |
---|
| 46 | + | then [ScriptTransfer(i.caller, (amount * 2), unit)] |
---|
| 47 | + | else nil |
---|
| 48 | + | } |
---|
| 49 | + | else throw("Strict value is not equal to itself.") |
---|
59 | 50 | | } |
---|
60 | 51 | | } |
---|
61 | 52 | | |
---|
Full:
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 = "/" |
---|
9 | | - | |
---|
10 | | - | let separatorSecond = "|" |
---|
11 | 7 | | |
---|
12 | 8 | | func randomize (bytes,range) = { |
---|
13 | 9 | | let hash = sha256(bytes) |
---|
14 | 10 | | let index = toInt(hash) |
---|
15 | 11 | | (index % range) |
---|
16 | 12 | | } |
---|
17 | 13 | | |
---|
18 | 14 | | |
---|
19 | | - | func counting (bytes,caller) = { |
---|
| 15 | + | func counting (bytes) = { |
---|
20 | 16 | | let count = randomize(bytes, 10) |
---|
21 | 17 | | if ((count >= 4)) |
---|
22 | | - | then StringEntry(kWon, ((((toString(caller) + separator) + "false") + separatorSecond) + getStringValue(this, kWon))) |
---|
23 | | - | else StringEntry(kWon, ((((toString(caller) + separator) + "true") + separatorSecond) + getStringValue(this, kWon))) |
---|
| 18 | + | then BooleanEntry(kWon, false) |
---|
| 19 | + | else BooleanEntry(kWon, true) |
---|
24 | 20 | | } |
---|
25 | 21 | | |
---|
26 | 22 | | |
---|
27 | 23 | | @Callable(i) |
---|
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) |
---|
| 24 | + | func parseStruct () = if ((i.caller != this)) |
---|
| 25 | + | then throw("Only owner") |
---|
| 26 | + | else { |
---|
| 27 | + | let winnerStruct = counting(i.transactionId) |
---|
40 | 28 | | [winnerStruct] |
---|
41 | | - | } |
---|
42 | | - | else throw("Strict value is not equal to itself.") |
---|
43 | | - | } |
---|
| 29 | + | } |
---|
44 | 30 | | |
---|
45 | 31 | | |
---|
46 | 32 | | |
---|
47 | 33 | | @Callable(i) |
---|
48 | 34 | | func startGame () = { |
---|
49 | 35 | | let amount = value(i.payments[0].amount) |
---|
50 | 36 | | if ((i.payments[0].assetId != unit)) |
---|
51 | 37 | | then throw("Pay in waves") |
---|
52 | 38 | | else if ((amount > 20)) |
---|
53 | 39 | | then throw("You cannot bet more than 20") |
---|
54 | 40 | | else { |
---|
55 | | - | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") |
---|
56 | | - | if (won) |
---|
57 | | - | then [ScriptTransfer(i.caller, (amount * 2), unit)] |
---|
58 | | - | else nil |
---|
| 41 | + | let nullInitStore = invoke(this, "parseStruct", nil, nil) |
---|
| 42 | + | if ((nullInitStore == nullInitStore)) |
---|
| 43 | + | then { |
---|
| 44 | + | let won = valueOrErrorMessage(getBoolean(this, kWon), "Storage read error") |
---|
| 45 | + | if (won) |
---|
| 46 | + | then [ScriptTransfer(i.caller, (amount * 2), unit)] |
---|
| 47 | + | else nil |
---|
| 48 | + | } |
---|
| 49 | + | else throw("Strict value is not equal to itself.") |
---|
59 | 50 | | } |
---|
60 | 51 | | } |
---|
61 | 52 | | |
---|
62 | 53 | | |
---|