tx · C9dqVAdzvnoKxh1hkB3A6LKonAUh48xmwyj6hPFkqyuA 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT: -0.01400000 Waves 2019.06.30 12:07 [564663] smart account 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT > SELF 0.00000000 Waves
{ "type": 13, "id": "C9dqVAdzvnoKxh1hkB3A6LKonAUh48xmwyj6hPFkqyuA", "fee": 1400000, "feeAssetId": null, "timestamp": 1561885630088, "version": 1, "sender": "3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT", "senderPublicKey": "Bhyvkx4xdbEi4KPJNZSzx9gZgzgyLEsavuj2kYSt7SST", "proofs": [ "5pqoXP9669yNZn7FokSKpAUPndi6TEMCaquvE7BqCapEH3PJtTWwhxYvpNdxgM61yUgAnbvbT2HtLJaNZBcbyrwe" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIL79hxhmqWX34iA/RS9p36FY3qCJjLclClmAz4vj6GlBAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAADURhdGFBbW91bnRLZXkCAAAABkFNT1VOVAAAAAAORGF0YVNlY3Rpb25LZXkCAAAAB1NFQ1RJT04AAAAADURhdGFTdGF0dXNLZXkCAAAABlNUQVRVUwAAAAANRGF0YVN0YXR1c05ldwIAAAADTkVXAAAAAA1EYXRhU3RhdHVzV2luAgAAAANXSU4AAAAAD0RhdGFTdGF0dXNMb29zZQIAAAAFTE9PU0UAAAAAFkVycm9yT25seVdhdmVzQWNjZXB0ZWQCAAAAE09ubHkgd2F2ZXMgYWNjZXB0ZWQAAAAAFUVycm9yTXVzdEdyZWF0ZXJUaGFuMAIAAAAlUGFyYW1ldGVyIHNpemUgbXVzdCBiZSBncmVhdGVyIHRoYW4gMAAAAAAURXJyb3JNdXN0TGVzc1RoYW4xMDACAAA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AAEAAAACdHgBAAAABnZlcmlmeQAAAAADCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAANzdHgFAAAAByRtYXRjaDAGBwfp2fh8", "chainId": 84, "height": 564663, "spentComplexity": 0 } View: original | compacted Prev: EQmRYfRJEkdKHeCwRLAM7L82dHUe9dW8ZCqNnrkGQZjL Next: 4B8RqB1MKxCxzkzbi3iy4zr4WFq2PFsahEiXreSF8M82 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerPublicKey = base58' | |
4 | + | let ServerPublicKey = base58'DrYgfD7j6AKD1iXtn9uhMka95ATZB42B1kGKCUATP2UG' | |
5 | 5 | ||
6 | 6 | let RouletteSections = 21 | |
7 | 7 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let ServerPublicKey = base58' | |
4 | + | let ServerPublicKey = base58'DrYgfD7j6AKD1iXtn9uhMka95ATZB42B1kGKCUATP2UG' | |
5 | 5 | ||
6 | 6 | let RouletteSections = 21 | |
7 | 7 | ||
8 | 8 | let DataGameNumberKey = "APP_GAME_ID" | |
9 | 9 | ||
10 | 10 | let DataAmountKey = "AMOUNT" | |
11 | 11 | ||
12 | 12 | let DataSectionKey = "SECTION" | |
13 | 13 | ||
14 | 14 | let DataStatusKey = "STATUS" | |
15 | 15 | ||
16 | 16 | let DataStatusNew = "NEW" | |
17 | 17 | ||
18 | 18 | let DataStatusWin = "WIN" | |
19 | 19 | ||
20 | 20 | let DataStatusLoose = "LOOSE" | |
21 | 21 | ||
22 | 22 | let ErrorOnlyWavesAccepted = "Only waves accepted" | |
23 | 23 | ||
24 | 24 | let ErrorMustGreaterThan0 = "Parameter size must be greater than 0" | |
25 | 25 | ||
26 | 26 | let ErrorMustLessThan100 = "Parameter size must be less than 100" | |
27 | 27 | ||
28 | 28 | let ErrorBetMustBeInWaves = "Bet amount must be in Waves" | |
29 | 29 | ||
30 | 30 | let ErrorTransactionMustBeInWaves = "Transaction's fee must be in Waves" | |
31 | 31 | ||
32 | 32 | let ErrorTransactionUsed = "Passed txId had been used before. Game aborted." | |
33 | 33 | ||
34 | 34 | let ErrorKeyNotFound = "Key not found: " | |
35 | 35 | ||
36 | 36 | let ErrorGameOver = "Game already is over" | |
37 | 37 | ||
38 | 38 | func StoreData (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func StoreDataInt (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func GetDataString (transactionId,key) = { | |
45 | 45 | let fullKey = ((transactionId + "_") + key) | |
46 | 46 | match getString(this, fullKey) { | |
47 | 47 | case str: String => | |
48 | 48 | str | |
49 | 49 | case _ => | |
50 | 50 | throw((ErrorKeyNotFound + fullKey)) | |
51 | 51 | } | |
52 | 52 | } | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func GetDataInt (transactionId,key) = { | |
56 | 56 | let fullKey = ((transactionId + "_") + key) | |
57 | 57 | match getInteger(this, fullKey) { | |
58 | 58 | case str: Int => | |
59 | 59 | str | |
60 | 60 | case _ => | |
61 | 61 | throw((ErrorKeyNotFound + fullKey)) | |
62 | 62 | } | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func NewGameId () = { | |
67 | 67 | let gameNum = match getInteger(this, DataGameNumberKey) { | |
68 | 68 | case num: Int => | |
69 | 69 | num | |
70 | 70 | case _ => | |
71 | 71 | 0 | |
72 | 72 | } | |
73 | 73 | (gameNum + 1) | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | func GenerateRandInt (gameId,rsaSign) = { | |
78 | 78 | let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey) | |
79 | 79 | if (rsaSigValid) | |
80 | 80 | then { | |
81 | 81 | let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections) | |
82 | 82 | if ((0 > rand)) | |
83 | 83 | then (-1 * rand) | |
84 | 84 | else rand | |
85 | 85 | } | |
86 | 86 | else throw("Invalid RSA signature") | |
87 | 87 | } | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(i) | |
91 | 91 | func bet (expectedResult) = { | |
92 | 92 | let gameNumber = NewGameId() | |
93 | 93 | let gameTransactionId = toBase58String(i.transactionId) | |
94 | 94 | let address = toBase58String(i.caller.bytes) | |
95 | 95 | let pmt = extract(i.payment) | |
96 | 96 | let txIdUsed = isDefined(getString(this, gameTransactionId)) | |
97 | 97 | let betNotInWaves = isDefined(pmt.assetId) | |
98 | 98 | let feeNotInWaves = isDefined(pmt.assetId) | |
99 | 99 | let amount = pmt.amount | |
100 | 100 | if (betNotInWaves) | |
101 | 101 | then throw(ErrorBetMustBeInWaves) | |
102 | 102 | else if (feeNotInWaves) | |
103 | 103 | then throw(ErrorTransactionMustBeInWaves) | |
104 | 104 | else if (txIdUsed) | |
105 | 105 | then throw(ErrorTransactionUsed) | |
106 | 106 | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreDataInt(gameTransactionId, DataAmountKey, amount), StoreDataInt(gameTransactionId, DataSectionKey, expectedResult), StoreData(gameTransactionId, DataStatusKey, DataStatusNew)]) | |
107 | 107 | } | |
108 | 108 | ||
109 | 109 | ||
110 | 110 | ||
111 | 111 | @Callable(i) | |
112 | 112 | func result (gameTransactionId,rsa) = { | |
113 | 113 | let rand = GenerateRandInt(gameTransactionId, rsa) | |
114 | 114 | let selectedSection = GetDataInt(gameTransactionId, DataSectionKey) | |
115 | 115 | let status = GetDataString(gameTransactionId, DataStatusKey) | |
116 | 116 | if ((status == DataStatusNew)) | |
117 | 117 | then { | |
118 | 118 | let isWin = (rand == selectedSection) | |
119 | 119 | if (isWin) | |
120 | 120 | then WriteSet([StoreData(gameTransactionId, DataStatusKey, DataStatusWin)]) | |
121 | 121 | else WriteSet([StoreData(gameTransactionId, DataStatusKey, DataStatusLoose)]) | |
122 | 122 | } | |
123 | 123 | else throw((ErrorGameOver + status)) | |
124 | 124 | } | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | @Verifier(tx) | |
128 | 128 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
129 | 129 | then match tx { | |
130 | 130 | case stx: SetScriptTransaction => | |
131 | 131 | true | |
132 | 132 | case _ => | |
133 | 133 | false | |
134 | 134 | } | |
135 | 135 | else false | |
136 | 136 |
github/deemru/w8io/026f985 24.81 ms ◑