tx · 6MjK6a8hGxdYsfthntDygKdDQHemsf7ZmNC7B3zz26xs 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs: -0.01400000 Waves 2019.09.06 20:03 [664482] smart account 3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs > SELF 0.00000000 Waves
{ "type": 13, "id": "6MjK6a8hGxdYsfthntDygKdDQHemsf7ZmNC7B3zz26xs", "fee": 1400000, "feeAssetId": null, "timestamp": 1567789439748, "version": 1, "sender": "3N2Z6EjzrzaCpD8ypDYLWDKe2PPVU8y9dJs", "senderPublicKey": "HSTmdhPrJF81ozDBaqVn8QVtV76oD7gzDfcHPQRdxdwW", "proofs": [ "RZqvmLj13akfNxF7x8MH518i7BzScxE21hPi6Trf8GBmTb4NjviWTzsUYaRbFY4JzcGD6ewQ54AKqnTNmszwvX6" ], "script": "base64:AAIDAAAAAAAAAAAAAAAKAAAAAA9TZXJ2ZXJQdWJsaWNLZXkJAAJZAAAAAQIAAAAsN2ltOWNhaUNtRTRTTDZqVG00S1RpY0hINGJHUGY1djU5cm5mVUEzY0NSRGoAAAAAElNlcnZlckJldFB1YmxpY0tleQkAAlkAAAABAgAAACw3aW05Y2FpQ21FNFNMNmpUbTRLVGljSEg0YkdQZjV2NTlybmZVQTNjQ1JEagAAAAAHV0FWRUxFVAkAAGgAAAACCQAAaAAAAAIAAAAAAAAAAGQAAAAAAAAAA+gAAAAAAAAAA+gAAAAACkNPTU1JU1NJT04JAABpAAAAAgkAAGgAAAACAAAAAAAAAAAFBQAAAAdXQVZFTEVUAAAAAAAAAAPoAQAAAA9HZW5lcmF0ZVJhbmRJbnQAAAADAAAABmdhbWVJZAAAAAdyc2FTaWduAAAACmxhc3RUaWNrZXQEAAAAC3JzYVNpZ1ZhbGlkCQAB9AAAAAMJAAGbAAAAAQUAAAAGZ2FtZUlkBQAAAAdyc2FTaWduBQAAAA9TZXJ2ZXJQdWJsaWNLZXkDBQAAAAtyc2FTaWdWYWxpZAQAAAA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ACXdpbm5lck51bQUAAAAEdW5pdAUAAAADbmlsBAAAAApnYW1lUmVzdWx0CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQABLAAAAAIFAAAABmdhbWVJZAIAAAAHX3Jlc3VsdAkAAaQAAAABBQAAAAl3aW5UaWNrZXQJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAdfd2lubmVyCQABkQAAAAIFAAAAC3BsYXllcnNMaXN0BQAAAAl3aW5uZXJOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAAEsAAAAAgUAAAAGZ2FtZUlkAgAAAAdfd2luQW10CQABkQAAAAIFAAAADndpbkFtb3VudHNMaXN0BQAAAAl3aW5uZXJOdW0FAAAAA25pbAkBAAAADFNjcmlwdFJlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEFAAAACmdhbWVSZXN1bHQJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAABXdpblRYAAAAAIOrGsA=", "chainId": 84, "height": 664482, "spentComplexity": 0 } View: original | compacted Prev: 4m21MpLuugmVJucmk6mwDGaahTC8cXFgsBiTeFoGu7qD Next: 5tEKP6aVwiDYZSB1sW2Zrrn2cjuUeEa1W1bxU51MuT2W Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let d = ((5 * c) / 1000) | |
11 | 11 | ||
12 | - | let e = 100 | |
13 | - | ||
14 | - | func f (g,h,i) = { | |
15 | - | let j = sigVerify(toBytes(g), h, a) | |
16 | - | if (j) | |
12 | + | func e (f,g,h) = { | |
13 | + | let i = sigVerify(toBytes(f), g, a) | |
14 | + | if (i) | |
17 | 15 | then { | |
18 | - | let | |
19 | - | if ((0 > | |
20 | - | then ((-1 * | |
21 | - | else ( | |
16 | + | let j = (toInt(sha256(g)) % h) | |
17 | + | if ((0 > j)) | |
18 | + | then ((-1 * j) + 1) | |
19 | + | else (j + 1) | |
22 | 20 | } | |
23 | 21 | else throw("Invalid RSA signature") | |
24 | 22 | } | |
25 | 23 | ||
26 | 24 | ||
27 | - | func l (g) = { | |
28 | - | let m = { | |
29 | - | let n = getString(this, g) | |
30 | - | if ($isInstanceOf(n, "String")) | |
31 | - | then { | |
32 | - | let o = n | |
33 | - | o | |
34 | - | } | |
35 | - | else throw(("Couldn't find game by " + g)) | |
36 | - | } | |
37 | - | split(m, "_") | |
25 | + | func k (f,l) = { | |
26 | + | let m = (((f + "_") + l) + "_tickets") | |
27 | + | let n = getStringValue(this, m) | |
28 | + | n | |
38 | 29 | } | |
39 | 30 | ||
40 | 31 | ||
41 | - | func | |
42 | - | let | |
43 | - | | |
44 | - | | |
45 | - | | |
46 | - | ||
47 | - | | |
48 | - | | |
49 | - | ||
50 | - | } | |
51 | - | | |
32 | + | func o (p) = { | |
33 | + | let q = size(p) | |
34 | + | if ((q > 0)) | |
35 | + | then { | |
36 | + | let r = parseIntValue(take(p, 2)) | |
37 | + | let s = take(drop(p, 2), r) | |
38 | + | let t = drop(p, (r + 2)) | |
39 | + | let u = t | |
40 | + | [s, u] | |
41 | + | } | |
42 | + | else throw("Empty string was passed into parseNextAttribute func") | |
52 | 43 | } | |
53 | 44 | ||
54 | 45 | ||
55 | - | @Callable(s) | |
56 | - | func bet (g,t,u) = { | |
57 | - | let v = extract(s.payment) | |
58 | - | let w = isDefined(v.assetId) | |
59 | - | let x = isDefined(v.assetId) | |
60 | - | let y = toBase58String(s.callerPublicKey) | |
61 | - | let z = addressFromPublicKey(fromBase58String(y)) | |
62 | - | if (w) | |
63 | - | then throw("Bet amount must be in Waves") | |
64 | - | else if (x) | |
65 | - | then throw("Transaction's fee must be in Waves") | |
66 | - | else { | |
67 | - | let j = sigVerify(toBytes(g), t, b) | |
68 | - | if (j) | |
69 | - | then { | |
70 | - | let A = toString(z) | |
71 | - | let B = [DataEntry((A + "_tickets"), u)] | |
72 | - | WriteSet(B) | |
73 | - | } | |
74 | - | else throw("Invalid RSA signature") | |
75 | - | } | |
46 | + | func v (m) = ["1", "100", "101", "300", "0", "0", "0", "0"] | |
47 | + | ||
48 | + | ||
49 | + | func w (f,l,x) = { | |
50 | + | let y = k(f, l) | |
51 | + | let z = v(y) | |
52 | + | if (if ((x >= parseIntValue(z[0]))) | |
53 | + | then (parseIntValue(z[1]) >= x) | |
54 | + | else false) | |
55 | + | then true | |
56 | + | else if (if ((x >= parseIntValue(z[2]))) | |
57 | + | then (parseIntValue(z[3]) >= x) | |
58 | + | else false) | |
59 | + | then true | |
60 | + | else if (if ((x >= parseIntValue(z[4]))) | |
61 | + | then (parseIntValue(z[5]) >= x) | |
62 | + | else false) | |
63 | + | then true | |
64 | + | else if (if ((x >= parseIntValue(z[6]))) | |
65 | + | then (parseIntValue(z[7]) >= x) | |
66 | + | else false) | |
67 | + | then true | |
68 | + | else false | |
69 | + | } | |
70 | + | ||
71 | + | ||
72 | + | func A (f,B,C,x) = { | |
73 | + | let D = split(B, "_") | |
74 | + | let E = split(C, "_") | |
75 | + | if (w(f, D[0], x)) | |
76 | + | then 0 | |
77 | + | else if (w(f, D[1], x)) | |
78 | + | then 1 | |
79 | + | else if (w(f, D[2], x)) | |
80 | + | then 2 | |
81 | + | else if (w(f, D[3], x)) | |
82 | + | then 3 | |
83 | + | else if (w(f, D[4], x)) | |
84 | + | then 4 | |
85 | + | else if (w(f, D[5], x)) | |
86 | + | then 5 | |
87 | + | else throw("Error with defining winner") | |
88 | + | } | |
89 | + | ||
90 | + | ||
91 | + | @Callable(F) | |
92 | + | func bet (f,G,H) = { | |
93 | + | let I = fromBase58String(G) | |
94 | + | let J = extract(F.payment) | |
95 | + | let K = isDefined(J.assetId) | |
96 | + | let L = isDefined(J.assetId) | |
97 | + | let M = toBase58String(F.callerPublicKey) | |
98 | + | let N = addressFromPublicKey(fromBase58String(M)) | |
99 | + | let O = isDefined(getString(this, (f + "_result"))) | |
100 | + | if (!(O)) | |
101 | + | then if (K) | |
102 | + | then throw("Bet amount must be in Waves") | |
103 | + | else if (L) | |
104 | + | then throw("Transaction's fee must be in Waves") | |
105 | + | else { | |
106 | + | let i = sigVerify(toBytes(f), I, b) | |
107 | + | if (i) | |
108 | + | then { | |
109 | + | let P = toString(N) | |
110 | + | let Q = [DataEntry((((f + "_") + P) + "_tickets"), H)] | |
111 | + | WriteSet(Q) | |
112 | + | } | |
113 | + | else throw("Invalid RSA signature") | |
114 | + | } | |
115 | + | else throw("This game already end, try make bet again") | |
76 | 116 | } | |
77 | 117 | ||
78 | 118 | ||
79 | 119 | ||
80 | - | @Callable(s) | |
81 | - | func generateResult (g,C,i) = { | |
82 | - | let h = fromBase58String(C) | |
83 | - | let D = f(g, h, i) | |
84 | - | let E = [DataEntry((g + "_result"), toString(D))] | |
85 | - | let F = l(g) | |
86 | - | let G = p(g, F[0]) | |
87 | - | let H = parseIntValue(G[0]) | |
88 | - | let I = parseIntValue(G[1]) | |
89 | - | if (if ((D >= H)) | |
90 | - | then (I >= D) | |
91 | - | else false) | |
92 | - | then { | |
93 | - | let J = 100000000 | |
94 | - | ScriptResult(WriteSet(E), TransferSet([ScriptTransfer(addressFromStringValue(F[0]), J, unit)])) | |
95 | - | } | |
96 | - | else throw("Player1 not the Winner") | |
120 | + | @Callable(F) | |
121 | + | func generateResult (f,R,h,B,C) = { | |
122 | + | let g = fromBase58String(R) | |
123 | + | let x = e(f, g, h) | |
124 | + | let D = split(B, "_") | |
125 | + | let E = split(C, "_") | |
126 | + | let S = A(f, B, C, x) | |
127 | + | let T = [ScriptTransfer(addressFromStringValue(D[S]), parseIntValue(E[S]), unit)] | |
128 | + | let U = [DataEntry((f + "_result"), toString(x)), DataEntry((f + "_winner"), D[S]), DataEntry((f + "_winAmt"), E[S])] | |
129 | + | ScriptResult(WriteSet(U), TransferSet(T)) | |
97 | 130 | } | |
98 | 131 | ||
99 | 132 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
5 | 5 | ||
6 | 6 | let b = fromBase58String("7im9caiCmE4SL6jTm4KTicHH4bGPf5v59rnfUA3cCRDj") | |
7 | 7 | ||
8 | 8 | let c = ((100 * 1000) * 1000) | |
9 | 9 | ||
10 | 10 | let d = ((5 * c) / 1000) | |
11 | 11 | ||
12 | - | let e = 100 | |
13 | - | ||
14 | - | func f (g,h,i) = { | |
15 | - | let j = sigVerify(toBytes(g), h, a) | |
16 | - | if (j) | |
12 | + | func e (f,g,h) = { | |
13 | + | let i = sigVerify(toBytes(f), g, a) | |
14 | + | if (i) | |
17 | 15 | then { | |
18 | - | let | |
19 | - | if ((0 > | |
20 | - | then ((-1 * | |
21 | - | else ( | |
16 | + | let j = (toInt(sha256(g)) % h) | |
17 | + | if ((0 > j)) | |
18 | + | then ((-1 * j) + 1) | |
19 | + | else (j + 1) | |
22 | 20 | } | |
23 | 21 | else throw("Invalid RSA signature") | |
24 | 22 | } | |
25 | 23 | ||
26 | 24 | ||
27 | - | func l (g) = { | |
28 | - | let m = { | |
29 | - | let n = getString(this, g) | |
30 | - | if ($isInstanceOf(n, "String")) | |
31 | - | then { | |
32 | - | let o = n | |
33 | - | o | |
34 | - | } | |
35 | - | else throw(("Couldn't find game by " + g)) | |
36 | - | } | |
37 | - | split(m, "_") | |
25 | + | func k (f,l) = { | |
26 | + | let m = (((f + "_") + l) + "_tickets") | |
27 | + | let n = getStringValue(this, m) | |
28 | + | n | |
38 | 29 | } | |
39 | 30 | ||
40 | 31 | ||
41 | - | func | |
42 | - | let | |
43 | - | | |
44 | - | | |
45 | - | | |
46 | - | ||
47 | - | | |
48 | - | | |
49 | - | ||
50 | - | } | |
51 | - | | |
32 | + | func o (p) = { | |
33 | + | let q = size(p) | |
34 | + | if ((q > 0)) | |
35 | + | then { | |
36 | + | let r = parseIntValue(take(p, 2)) | |
37 | + | let s = take(drop(p, 2), r) | |
38 | + | let t = drop(p, (r + 2)) | |
39 | + | let u = t | |
40 | + | [s, u] | |
41 | + | } | |
42 | + | else throw("Empty string was passed into parseNextAttribute func") | |
52 | 43 | } | |
53 | 44 | ||
54 | 45 | ||
55 | - | @Callable(s) | |
56 | - | func bet (g,t,u) = { | |
57 | - | let v = extract(s.payment) | |
58 | - | let w = isDefined(v.assetId) | |
59 | - | let x = isDefined(v.assetId) | |
60 | - | let y = toBase58String(s.callerPublicKey) | |
61 | - | let z = addressFromPublicKey(fromBase58String(y)) | |
62 | - | if (w) | |
63 | - | then throw("Bet amount must be in Waves") | |
64 | - | else if (x) | |
65 | - | then throw("Transaction's fee must be in Waves") | |
66 | - | else { | |
67 | - | let j = sigVerify(toBytes(g), t, b) | |
68 | - | if (j) | |
69 | - | then { | |
70 | - | let A = toString(z) | |
71 | - | let B = [DataEntry((A + "_tickets"), u)] | |
72 | - | WriteSet(B) | |
73 | - | } | |
74 | - | else throw("Invalid RSA signature") | |
75 | - | } | |
46 | + | func v (m) = ["1", "100", "101", "300", "0", "0", "0", "0"] | |
47 | + | ||
48 | + | ||
49 | + | func w (f,l,x) = { | |
50 | + | let y = k(f, l) | |
51 | + | let z = v(y) | |
52 | + | if (if ((x >= parseIntValue(z[0]))) | |
53 | + | then (parseIntValue(z[1]) >= x) | |
54 | + | else false) | |
55 | + | then true | |
56 | + | else if (if ((x >= parseIntValue(z[2]))) | |
57 | + | then (parseIntValue(z[3]) >= x) | |
58 | + | else false) | |
59 | + | then true | |
60 | + | else if (if ((x >= parseIntValue(z[4]))) | |
61 | + | then (parseIntValue(z[5]) >= x) | |
62 | + | else false) | |
63 | + | then true | |
64 | + | else if (if ((x >= parseIntValue(z[6]))) | |
65 | + | then (parseIntValue(z[7]) >= x) | |
66 | + | else false) | |
67 | + | then true | |
68 | + | else false | |
69 | + | } | |
70 | + | ||
71 | + | ||
72 | + | func A (f,B,C,x) = { | |
73 | + | let D = split(B, "_") | |
74 | + | let E = split(C, "_") | |
75 | + | if (w(f, D[0], x)) | |
76 | + | then 0 | |
77 | + | else if (w(f, D[1], x)) | |
78 | + | then 1 | |
79 | + | else if (w(f, D[2], x)) | |
80 | + | then 2 | |
81 | + | else if (w(f, D[3], x)) | |
82 | + | then 3 | |
83 | + | else if (w(f, D[4], x)) | |
84 | + | then 4 | |
85 | + | else if (w(f, D[5], x)) | |
86 | + | then 5 | |
87 | + | else throw("Error with defining winner") | |
88 | + | } | |
89 | + | ||
90 | + | ||
91 | + | @Callable(F) | |
92 | + | func bet (f,G,H) = { | |
93 | + | let I = fromBase58String(G) | |
94 | + | let J = extract(F.payment) | |
95 | + | let K = isDefined(J.assetId) | |
96 | + | let L = isDefined(J.assetId) | |
97 | + | let M = toBase58String(F.callerPublicKey) | |
98 | + | let N = addressFromPublicKey(fromBase58String(M)) | |
99 | + | let O = isDefined(getString(this, (f + "_result"))) | |
100 | + | if (!(O)) | |
101 | + | then if (K) | |
102 | + | then throw("Bet amount must be in Waves") | |
103 | + | else if (L) | |
104 | + | then throw("Transaction's fee must be in Waves") | |
105 | + | else { | |
106 | + | let i = sigVerify(toBytes(f), I, b) | |
107 | + | if (i) | |
108 | + | then { | |
109 | + | let P = toString(N) | |
110 | + | let Q = [DataEntry((((f + "_") + P) + "_tickets"), H)] | |
111 | + | WriteSet(Q) | |
112 | + | } | |
113 | + | else throw("Invalid RSA signature") | |
114 | + | } | |
115 | + | else throw("This game already end, try make bet again") | |
76 | 116 | } | |
77 | 117 | ||
78 | 118 | ||
79 | 119 | ||
80 | - | @Callable(s) | |
81 | - | func generateResult (g,C,i) = { | |
82 | - | let h = fromBase58String(C) | |
83 | - | let D = f(g, h, i) | |
84 | - | let E = [DataEntry((g + "_result"), toString(D))] | |
85 | - | let F = l(g) | |
86 | - | let G = p(g, F[0]) | |
87 | - | let H = parseIntValue(G[0]) | |
88 | - | let I = parseIntValue(G[1]) | |
89 | - | if (if ((D >= H)) | |
90 | - | then (I >= D) | |
91 | - | else false) | |
92 | - | then { | |
93 | - | let J = 100000000 | |
94 | - | ScriptResult(WriteSet(E), TransferSet([ScriptTransfer(addressFromStringValue(F[0]), J, unit)])) | |
95 | - | } | |
96 | - | else throw("Player1 not the Winner") | |
120 | + | @Callable(F) | |
121 | + | func generateResult (f,R,h,B,C) = { | |
122 | + | let g = fromBase58String(R) | |
123 | + | let x = e(f, g, h) | |
124 | + | let D = split(B, "_") | |
125 | + | let E = split(C, "_") | |
126 | + | let S = A(f, B, C, x) | |
127 | + | let T = [ScriptTransfer(addressFromStringValue(D[S]), parseIntValue(E[S]), unit)] | |
128 | + | let U = [DataEntry((f + "_result"), toString(x)), DataEntry((f + "_winner"), D[S]), DataEntry((f + "_winAmt"), E[S])] | |
129 | + | ScriptResult(WriteSet(U), TransferSet(T)) | |
97 | 130 | } | |
98 | 131 | ||
99 | 132 |
github/deemru/w8io/026f985 32.21 ms ◑