tx · GZdtS2Lx7B8ZKHimU6Joos35qyhTsShn2W5RE6Vk1NSU 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT: -0.01400000 Waves 2019.06.24 18:44 [556367] smart account 3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT > SELF 0.00000000 Waves
{ "type": 13, "id": "GZdtS2Lx7B8ZKHimU6Joos35qyhTsShn2W5RE6Vk1NSU", "fee": 1400000, "feeAssetId": null, "timestamp": 1561391066088, "version": 1, "sender": "3N8M61KCm8G72mK8PjacFbnnxdbFsyqQDeT", "senderPublicKey": "Bhyvkx4xdbEi4KPJNZSzx9gZgzgyLEsavuj2kYSt7SST", "proofs": [ "5Dc7c6BYCzokt1BPpNSPpyGM2m8sehUf9xDCTQkJgxCU6cwcC4qUqEiZGdundinbhdDfwYw6BAV2boPxJsHv2Pgi" ], "script": "base64:AAIDAAAAAAAAAAAAAAAPAAAAAA9TZXJ2ZXJQdWJsaWNLZXkBAAAAIAQ1/gW4L6VUuKyMox3deX07Tu0dL8x1obg+vYqfUuwTAAAAABBSb3VsZXR0ZVNlY3Rpb25zAAAAAAAAAAAVAAAAABFEYXRhR2FtZU51bWJlcktleQIAAAALQVBQX0dBTUVfSUQAAAAADURhdGFBbW91bnRLZXkCAAAABkFNT1VOVAAAAAAORGF0YVNlY3Rpb25LZXkCAAAAB1NFQ1RJT04AAAAADURhdGFTdGF0dXNLZXkCAAAABlNUQVRVUwAAAAANRGF0YVN0YXR1c05ldwIAAAADTkVXAAAAABZFcnJvck9ubHlXYXZlc0FjY2VwdGVkAgAAABllcnJvcl9vbmx5X3dhdmVzX2FjY2VwdGVkAAAAABVFcnJvck11c3RHcmVhdGVyVGhhbjACAAAAJVBhcmFtZXRlciBzaXplIG11c3QgYmUgZ3JlYXRlciB0aGFuIDAAAAAAFEVycm9yTXVzdExlc3NUaGFuMTAwAgAAACRQYXJhbWV0ZXIgc2l6ZSBtdXN0IGJlIGxlc3MgdGhhbiAxMDAAAAAAFUVycm9y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U2NyaXB0VHJhbnNhY3Rpb24EAAAAA3N0eAUAAAAHJG1hdGNoMAYHB1jraV8=", "chainId": 84, "height": 556367, "spentComplexity": 0 } View: original | compacted Prev: 7mVp76F4UpMeDWKvdDEYANqpQt8Ve2z29SWPoeifPe8m Next: 56smDaFiP2ABtobgZiYiF3esvnAKwFVZ5PCKPMQCLwuU Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | then throw(ErrorTransactionMustBeInWaves) | |
71 | 71 | else if (txIdUsed) | |
72 | 72 | then throw(ErrorTransactionUsed) | |
73 | - | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, | |
73 | + | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreData(gameTransactionId, DataAmountKey, toString(amount)), StoreData(gameTransactionId, DataSectionKey, toString(expectedResult)), StoreData(gameTransactionId, DataStatusKey, DataStatusNew)]) | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 |
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 ErrorOnlyWavesAccepted = "error_only_waves_accepted" | |
19 | 19 | ||
20 | 20 | let ErrorMustGreaterThan0 = "Parameter size must be greater than 0" | |
21 | 21 | ||
22 | 22 | let ErrorMustLessThan100 = "Parameter size must be less than 100" | |
23 | 23 | ||
24 | 24 | let ErrorBetMustBeInWaves = "Bet amount must be in Waves" | |
25 | 25 | ||
26 | 26 | let ErrorTransactionMustBeInWaves = "Transaction's fee must be in Waves" | |
27 | 27 | ||
28 | 28 | let ErrorTransactionUsed = "Passed txId had been used before. Game aborted." | |
29 | 29 | ||
30 | 30 | func StoreData (transactionId,key,value) = DataEntry(((transactionId + "_") + key), value) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func NewGameId () = { | |
34 | 34 | let gameNum = match getInteger(this, DataGameNumberKey) { | |
35 | 35 | case num: Int => | |
36 | 36 | num | |
37 | 37 | case _ => | |
38 | 38 | 0 | |
39 | 39 | } | |
40 | 40 | (gameNum + 1) | |
41 | 41 | } | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | @Callable(i) | |
45 | 45 | func GenerateRandInt (gameId,rsaSign) = { | |
46 | 46 | let rsaSigValid = sigVerify(fromBase58String(gameId), fromBase58String(rsaSign), ServerPublicKey) | |
47 | 47 | if (rsaSigValid) | |
48 | 48 | then { | |
49 | 49 | let rand = (toInt(sha256(toBytes(rsaSign))) % RouletteSections) | |
50 | 50 | WriteSet([DataEntry("orig", toInt(sha256(toBytes(rsaSign)))), DataEntry("rand", rand)]) | |
51 | 51 | } | |
52 | 52 | else throw("Invalid RSA signature") | |
53 | 53 | } | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | 57 | @Callable(i) | |
58 | 58 | func bet (expectedResult) = { | |
59 | 59 | let gameNumber = NewGameId() | |
60 | 60 | let gameTransactionId = toBase58String(i.transactionId) | |
61 | 61 | let address = toBase58String(i.caller.bytes) | |
62 | 62 | let pmt = extract(i.payment) | |
63 | 63 | let txIdUsed = isDefined(getString(this, gameTransactionId)) | |
64 | 64 | let betNotInWaves = isDefined(pmt.assetId) | |
65 | 65 | let feeNotInWaves = isDefined(pmt.assetId) | |
66 | 66 | let amount = pmt.amount | |
67 | 67 | if (betNotInWaves) | |
68 | 68 | then throw(ErrorBetMustBeInWaves) | |
69 | 69 | else if (feeNotInWaves) | |
70 | 70 | then throw(ErrorTransactionMustBeInWaves) | |
71 | 71 | else if (txIdUsed) | |
72 | 72 | then throw(ErrorTransactionUsed) | |
73 | - | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, | |
73 | + | else WriteSet([DataEntry(gameTransactionId, address), DataEntry(DataGameNumberKey, gameNumber), StoreData(gameTransactionId, DataAmountKey, toString(amount)), StoreData(gameTransactionId, DataSectionKey, toString(expectedResult)), StoreData(gameTransactionId, DataStatusKey, DataStatusNew)]) | |
74 | 74 | } | |
75 | 75 | ||
76 | 76 | ||
77 | 77 | ||
78 | 78 | @Callable(i) | |
79 | 79 | func bet111 (expectedResult) = { | |
80 | 80 | let lastAuctionIdKey = "last_auction_id" | |
81 | 81 | let lastAuctionId = match getInteger(this, lastAuctionIdKey) { | |
82 | 82 | case a: Int => | |
83 | 83 | a | |
84 | 84 | case _ => | |
85 | 85 | 0 | |
86 | 86 | } | |
87 | 87 | let id = (lastAuctionId + 1) | |
88 | 88 | let newAuctionId = toString(id) | |
89 | 89 | let ownerWallet = toBase58String(i.caller.bytes) | |
90 | 90 | let pmt = value(i.payment) | |
91 | 91 | if (isDefined(pmt.assetId)) | |
92 | 92 | then throw(ErrorOnlyWavesAccepted) | |
93 | 93 | else { | |
94 | 94 | let assetId = toBase58String(value(pmt.assetId)) | |
95 | 95 | let auctionDurationKey = (("auction_" + newAuctionId) + "_duration") | |
96 | 96 | let auctionMinBidKey = (("auction_" + newAuctionId) + "_min_bid") | |
97 | 97 | let auctionLastBidKey = (("auction_" + newAuctionId) + "_last_bid") | |
98 | 98 | let auctionLastBidOwnerKey = (("auction_" + newAuctionId) + "_last_bid_owner") | |
99 | 99 | let auctionOwnerKey = (("auction_" + newAuctionId) + "_owner") | |
100 | 100 | let auctionAmountKey = (("auction_" + newAuctionId) + "_amount") | |
101 | 101 | let auctionAssetIdKey = (("auction_" + newAuctionId) + "_asset_id") | |
102 | 102 | let auctionIsActiveKey = (("auction_" + newAuctionId) + "_is_active") | |
103 | 103 | let userBalanceKey = ((("balance_" + ownerWallet) + "_") + assetId) | |
104 | 104 | let currentAmount = match getInteger(this, userBalanceKey) { | |
105 | 105 | case a: Int => | |
106 | 106 | a | |
107 | 107 | case _ => | |
108 | 108 | 0 | |
109 | 109 | } | |
110 | 110 | let newAmount = (currentAmount + pmt.amount) | |
111 | 111 | WriteSet([DataEntry(auctionLastBidKey, 0), DataEntry(auctionOwnerKey, ownerWallet), DataEntry(auctionAmountKey, pmt.amount), DataEntry(auctionAssetIdKey, assetId), DataEntry(userBalanceKey, newAmount), DataEntry(auctionIsActiveKey, true), DataEntry(auctionLastBidOwnerKey, ""), DataEntry(lastAuctionIdKey, id)]) | |
112 | 112 | } | |
113 | 113 | } | |
114 | 114 | ||
115 | 115 | ||
116 | 116 | @Verifier(tx) | |
117 | 117 | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
118 | 118 | then match tx { | |
119 | 119 | case stx: SetScriptTransaction => | |
120 | 120 | true | |
121 | 121 | case _ => | |
122 | 122 | false | |
123 | 123 | } | |
124 | 124 | else false | |
125 | 125 |
github/deemru/w8io/026f985 53.95 ms ◑