tx · Aivg1Wp6LLHpwm2JKBzb7JCjFCT2czkqnQ2b8bvTQXyt 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT: -0.01400000 Waves 2019.06.27 17:42 [560668] smart account 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT > SELF 0.00000000 Waves
{ "type": 13, "id": "Aivg1Wp6LLHpwm2JKBzb7JCjFCT2czkqnQ2b8bvTQXyt", "fee": 1400000, "feeAssetId": null, "timestamp": 1561646499588, "version": 1, "sender": "3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT", "senderPublicKey": "Bhyvkx4xdbEi4KPJNZSzx9gZgzgyLEsavuj2kYSt7SST", "proofs": [ "2RZTtXtchHgicDuncmJJ1Wihw5YuAkEryKd3kbQdBQmPBf7SPJXh2xo6hoZCVC3fjpnBuec4txTBCrg2V5GSRrJK" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIAQ1/gW4L6VUuKyMox3deX07Tu0dL8x1obg+vYqfUuwTAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAADURhdGFBbW91bnRLZXkCAAAABkFNT1VOVAAAAAAORGF0YVNlY3Rpb25LZXkCAAAAB1NFQ1RJT04AAAAADURhdGFTdGF0dXNLZXkCAAAABlNUQVRVUwAAAAANRGF0YVN0YXR1c05ldwIAAAADTkVXAAAAAA1EYXRhU3RhdHVzV2luAgAAAANXSU4AAAAAD0RhdGFTdGF0dXNMb29zZQIAAAAFTE9PU0UAAAAAFkVycm9yT25seVdhdmVzQWNjZXB0ZWQCAAAAE09ubHkgd2F2ZXMgYWNjZXB0ZWQAAAAAFUVycm9yTXVzdEdyZWF0ZXJUaGFuMAIAAAAlUGFyYW1ldGVyIHNpemUgbXVzdCBiZSBncmVhdGVyIHRoYW4gMAAAAAAURXJyb3JNdXN0TGVzc1R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ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleQQAAAAHJG1hdGNoMAUAAAACdHgDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAFFNldFNjcmlwdFRyYW5zYWN0aW9uBAAAAANzdHgFAAAAByRtYXRjaDAGBweNtrWi", "chainId": 84, "height": 560668, "spentComplexity": 0 } View: original | compacted Prev: 56smDaFiP2ABtobgZiYiF3esvnAKwFVZ5PCKPMQCLwuU Next: CNeGrtgke9Jb2pNsBGqVuUKoEnfjKYnqGFTP1dhCkdx9 Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ServerPublicKey = base58'HSP9V7edVKjfLJUfRkEF6vfV9Tyz4Us4yqH9rkwqnHY' | |
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) = match getString(this, ((transactionId + "_") + key)) { | |
45 | 45 | case str: String => | |
46 | 46 | str | |
47 | 47 | case _ => | |
48 | 48 | throw((ErrorKeyNotFound + transactionId)) | |
49 | 49 | } | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func GetDataInt (transactionId,key) = match getInteger(this, ((transactionId + "_") + key)) { | |
53 | 53 | case str: Int => | |
54 | 54 | str | |
55 | 55 | case _ => | |
56 | 56 | throw((ErrorKeyNotFound + transactionId)) | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func NewGameId () = { | |
61 | 61 | let gameNum = match getInteger(this, DataGameNumberKey) { | |
62 | 62 | case num: Int => | |
63 | 63 | num | |
64 | 64 | case _ => | |
65 | 65 | 0 | |
66 | 66 | } | |
67 | 67 | (gameNum + 1) | |
68 | 68 | } | |
69 | 69 | ||
70 | 70 | ||
71 | 71 | func GenerateRandInt (gameId,rsaSign) = { | |
72 | 72 | let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey) | |
73 | 73 | if (rsaSigValid) | |
74 | 74 | then { | |
75 | 75 | let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections) | |
76 | 76 | if ((0 > rand)) | |
77 | 77 | then (-1 * rand) | |
78 | 78 | else rand | |
79 | 79 | } | |
80 | 80 | else throw("Invalid RSA signature") | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func bet (expectedResult) = { | |
86 | 86 | let gameNumber = NewGameId() | |
87 | 87 | let gameTransactionId = toBase58String(i.transactionId) | |
88 | 88 | let address = toBase58String(i.caller.bytes) | |
89 | 89 | let pmt = extract(i.payment) | |
90 | 90 | let txIdUsed = isDefined(getString(this, gameTransactionId)) | |
91 | 91 | let betNotInWaves = isDefined(pmt.assetId) | |
92 | 92 | let feeNotInWaves = isDefined(pmt.assetId) | |
93 | 93 | let amount = pmt.amount | |
94 | 94 | if (betNotInWaves) | |
95 | 95 | then throw(ErrorBetMustBeInWaves) | |
96 | 96 | else if (feeNotInWaves) | |
97 | 97 | then throw(ErrorTransactionMustBeInWaves) | |
98 | 98 | else if (txIdUsed) | |
99 | 99 | then throw(ErrorTransactionUsed) | |
100 | 100 | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreDataInt(gameTransactionId, DataAmountKey, amount), StoreDataInt(gameTransactionId, DataSectionKey, expectedResult), StoreData(gameTransactionId, DataStatusKey, DataStatusNew)]) | |
101 | 101 | } | |
102 | 102 | ||
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func result (gameTransactionId,rsa) = { | |
107 | 107 | let rand = GenerateRandInt(gameTransactionId, rsa) | |
108 | 108 | let selectedSection = GetDataInt(gameTransactionId, DataSectionKey) | |
109 | 109 | let status = GetDataString(gameTransactionId, DataStatusKey) | |
110 | 110 | if ((status != DataStatusNew)) | |
111 | 111 | then { | |
112 | 112 | let isWin = (rand == selectedSection) | |
113 | 113 | if (isWin) | |
114 | 114 | then WriteSet([StoreData(gameTransactionId, DataStatusKey, DataStatusWin)]) | |
115 | 115 | else WriteSet([StoreData(gameTransactionId, DataStatusKey, DataStatusLoose)]) | |
116 | 116 | } | |
117 | 117 | else throw(ErrorGameOver) | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Verifier(tx) | |
122 | 122 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
123 | 123 | then match tx { | |
124 | 124 | case stx: SetScriptTransaction => | |
125 | 125 | true | |
126 | 126 | case _ => | |
127 | 127 | false | |
128 | 128 | } | |
129 | 129 | else false | |
130 | 130 |
github/deemru/w8io/169f3d6 47.46 ms ◑