tx · H2XAGzEi2vaUK4nfaDQkby4c4yiDvzggvhngZKfnuHnB 3NA3LRSigk6knLZ16uTzcdLNow2EQZtXTaJ: -0.01400000 Waves 2022.05.17 11:36 [2055433] smart account 3NA3LRSigk6knLZ16uTzcdLNow2EQZtXTaJ > SELF 0.00000000 Waves
{ "type": 13, "id": "H2XAGzEi2vaUK4nfaDQkby4c4yiDvzggvhngZKfnuHnB", "fee": 1400000, "feeAssetId": null, "timestamp": 1652776597270, "version": 2, "chainId": 84, "sender": "3NA3LRSigk6knLZ16uTzcdLNow2EQZtXTaJ", "senderPublicKey": "ApEZSyUFWsckB3mZSWm3spfm6UPyDhMdrpxNhydohYs1", "proofs": [ "jRQpnaKkWYax6edrCHpVqEwDo5fKU9qZanuRPTWBnns2EU7LVMtw2asRYf1SkJ9CcQMSWn4RkMy2NbjeNBZ5TSM" ], "script": "base64:AAIFAAAAAAAAAAQIAhIAAAAAGAAAAAAJc2VwYXJhdG9yAgAAAAFfAAAAAA1rZXlDaGFyc0NvdW50AgAAAAtjaGFyc19jb3VudAAAAAAHa2V5Q2hhcgIAAAAEY2hhcgAAAAAIa2V5T3duZXICAAAABW93bmVyAAAAAA1rZXlBcHBlYXJhbmNlAgAAAAphcHBlYXJhbmNlAAAAAAxrZXlQeXJvQm9udXMCAAAACnB5cm9fYm9udXMAAAAADGtleUFxdWFCb251cwIAAAAKYXF1YV9ib251cwAAAAANa2V5VGVycmFCb251cwIAAAALdGVycmFfYm9udXMAAAAADGtleUFlcm9Cb251cwIAAAAKYWVyb19ib251cwAAAAANa2V5TG9vdHNCb251cwIAAAALbG9vdHNfYm9udXMAAAAAEmtleUdlbmVyYXRpbmdCb251cwIAAAAQZ2VuZXJhdGluZ19ib251cwAAAAAHZ292QWRkcgkBAAAAEUBleHRyTmF0aXZlKDEwNjIpAAAAAQIAAAAjM015eGZ3dmJ1ZVVCeW5ZSGZRc3V0TlhaTnFOb3pHaU1uc0cAAAAAFWtleUVjb3N5c3RlbUFkZHJlc3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B9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAgFAAAAAnR4AAAAD3NlbmRlclB1YmxpY0tleUg+tXE=", "height": 2055433, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: ARR6GVBCzn7uEUVQ5FLToEbq58X3TtzVuwt42ncVimpw Next: 77DuniQNft7TNSU2eHHgSWkYjWNYf2iSN789WS5kpaMG Diff:
Old | New | Differences | |
---|---|---|---|
52 | 52 | ||
53 | 53 | ||
54 | 54 | func randInt (min,max,txId,nonce) = { | |
55 | - | let hash = value(sha256_16Kb((value(value(blockInfoByHeight(height)).vrf) + txId))) | |
56 | - | value(((value(toInt(hash | |
55 | + | let hash = value(sha256_16Kb(((value(value(blockInfoByHeight(height)).vrf) + txId) + toBytes(nonce)))) | |
56 | + | value(((value(toInt(hash)) % ((max - min) + 1)) + min)) | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
116 | 116 | let generatingBonusRanges = split(getStringValue(govAddr, keyCharsNaturalGeneratingBonusRanges), separator) | |
117 | 117 | let appearance = makeString([toString(randInt(1, bodiesAmount, txId, 0)), toString(randInt(1, eyesAmount, txId, 1)), toString(randInt(1, mouthsAmount, txId, 2))], separator) | |
118 | 118 | let pyroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 3, txId) | |
119 | - | let aquaBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
120 | - | let terraBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
121 | - | let aeroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
122 | - | let generatingBonus = getRandomBonus(statsTiersRanges, generatingBonusRanges, | |
123 | - | let lootsBonus = getRandomBonus(statsTiersRanges, lootsBonusRanges, | |
119 | + | let aquaBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 10, txId) | |
120 | + | let terraBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 17, txId) | |
121 | + | let aeroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 24, txId) | |
122 | + | let generatingBonus = getRandomBonus(statsTiersRanges, generatingBonusRanges, 31, txId) | |
123 | + | let lootsBonus = getRandomBonus(statsTiersRanges, lootsBonusRanges, 38, txId) | |
124 | 124 | [StringEntry(cWith(keyOwner, charId), callerAddr), StringEntry(cWith(keyAppearance, charId), appearance), IntegerEntry(cWith(keyPyroBonus, charId), pyroBonus), IntegerEntry(cWith(keyAquaBonus, charId), aquaBonus), IntegerEntry(cWith(keyTerraBonus, charId), terraBonus), IntegerEntry(cWith(keyAeroBonus, charId), aeroBonus), IntegerEntry(cWith(keyLootsBonus, charId), lootsBonus), IntegerEntry(cWith(keyGeneratingBonus, charId), generatingBonus)] | |
125 | 125 | }) | |
126 | 126 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "_" | |
5 | 5 | ||
6 | 6 | let keyCharsCount = "chars_count" | |
7 | 7 | ||
8 | 8 | let keyChar = "char" | |
9 | 9 | ||
10 | 10 | let keyOwner = "owner" | |
11 | 11 | ||
12 | 12 | let keyAppearance = "appearance" | |
13 | 13 | ||
14 | 14 | let keyPyroBonus = "pyro_bonus" | |
15 | 15 | ||
16 | 16 | let keyAquaBonus = "aqua_bonus" | |
17 | 17 | ||
18 | 18 | let keyTerraBonus = "terra_bonus" | |
19 | 19 | ||
20 | 20 | let keyAeroBonus = "aero_bonus" | |
21 | 21 | ||
22 | 22 | let keyLootsBonus = "loots_bonus" | |
23 | 23 | ||
24 | 24 | let keyGeneratingBonus = "generating_bonus" | |
25 | 25 | ||
26 | 26 | let govAddr = addressFromStringValue("3MyxfwvbueUBynYHfQsutNXZNqNozGiMnsG") | |
27 | 27 | ||
28 | 28 | let keyEcosystemAddresses = "ecosystem_addresses" | |
29 | 29 | ||
30 | 30 | let keyCharsBodiesAmount = "chars_bodies_amount" | |
31 | 31 | ||
32 | 32 | let keyCharsEyesAmount = "chars_eyes_amount" | |
33 | 33 | ||
34 | 34 | let keyCharsMouthsAmount = "chars_mouths_amount" | |
35 | 35 | ||
36 | 36 | let keyCharsStatsTiersRanges = "chars_stats_tiers_ranges" | |
37 | 37 | ||
38 | 38 | let keyCharsNaturalElemBonusRanges = "chars_natural_elem_bonus_ranges" | |
39 | 39 | ||
40 | 40 | let keyCharsNaturalLootsBonusRanges = "chars_natural_loots_bonus_ranges" | |
41 | 41 | ||
42 | 42 | let keyCharsNaturalGeneratingBonusRanges = "chars_natural_generating_bonus_ranges" | |
43 | 43 | ||
44 | 44 | func invokChecks (callerAddr) = if ((isDataStorageUntouched(govAddr) != false)) | |
45 | 45 | then throw("Governing app not ready") | |
46 | 46 | else { | |
47 | 47 | let ecosystemAddresses = getStringValue(govAddr, keyEcosystemAddresses) | |
48 | 48 | if ((contains(ecosystemAddresses, toString(callerAddr)) != false)) | |
49 | 49 | then throw("Access denied") | |
50 | 50 | else unit | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func randInt (min,max,txId,nonce) = { | |
55 | - | let hash = value(sha256_16Kb((value(value(blockInfoByHeight(height)).vrf) + txId))) | |
56 | - | value(((value(toInt(hash | |
55 | + | let hash = value(sha256_16Kb(((value(value(blockInfoByHeight(height)).vrf) + txId) + toBytes(nonce)))) | |
56 | + | value(((value(toInt(hash)) % ((max - min) + 1)) + min)) | |
57 | 57 | } | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func cWith (a,b) = ((((keyChar + separator) + toString(b)) + separator) + a) | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getRandomBonus (statsTierRanges,bonusRanges,startingNonce,txId) = { | |
64 | 64 | let sT1 = parseIntValue(statsTierRanges[0]) | |
65 | 65 | let sT2 = parseIntValue(statsTierRanges[1]) | |
66 | 66 | let sT3 = parseIntValue(statsTierRanges[2]) | |
67 | 67 | let sT4 = parseIntValue(statsTierRanges[3]) | |
68 | 68 | let sT5 = parseIntValue(statsTierRanges[4]) | |
69 | 69 | let sT6 = parseIntValue(statsTierRanges[5]) | |
70 | 70 | let bT1 = parseIntValue(bonusRanges[0]) | |
71 | 71 | let bT2 = parseIntValue(bonusRanges[1]) | |
72 | 72 | let bT3 = parseIntValue(bonusRanges[2]) | |
73 | 73 | let bT4 = parseIntValue(bonusRanges[3]) | |
74 | 74 | let bT5 = parseIntValue(bonusRanges[4]) | |
75 | 75 | let bT6 = parseIntValue(bonusRanges[5]) | |
76 | 76 | let tierResult = randInt(0, 10000, txId, startingNonce) | |
77 | 77 | if (if ((tierResult >= 0)) | |
78 | 78 | then (sT1 >= tierResult) | |
79 | 79 | else false) | |
80 | 80 | then randInt(0, bT1, txId, (startingNonce + 1)) | |
81 | 81 | else if (if ((tierResult > sT1)) | |
82 | 82 | then (sT2 >= tierResult) | |
83 | 83 | else false) | |
84 | 84 | then randInt((bT1 + 1), bT2, txId, (startingNonce + 2)) | |
85 | 85 | else if (if ((tierResult > sT2)) | |
86 | 86 | then (sT3 >= tierResult) | |
87 | 87 | else false) | |
88 | 88 | then randInt((bT2 + 1), bT3, txId, (startingNonce + 3)) | |
89 | 89 | else if (if ((tierResult > sT3)) | |
90 | 90 | then (sT4 >= tierResult) | |
91 | 91 | else false) | |
92 | 92 | then randInt((bT3 + 1), bT4, txId, (startingNonce + 4)) | |
93 | 93 | else if (if ((tierResult > sT4)) | |
94 | 94 | then (sT5 >= tierResult) | |
95 | 95 | else false) | |
96 | 96 | then randInt((bT4 + 1), bT5, txId, (startingNonce + 5)) | |
97 | 97 | else if (if ((tierResult > sT5)) | |
98 | 98 | then (sT6 >= tierResult) | |
99 | 99 | else false) | |
100 | 100 | then randInt((bT5 + 1), bT6, txId, (startingNonce + 6)) | |
101 | 101 | else throw("Unexpected error") | |
102 | 102 | } | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | @Callable(i) | |
106 | 106 | func createChar () = valueOrElse(invokChecks(i.caller), { | |
107 | 107 | let txId = i.transactionId | |
108 | 108 | let callerAddr = toBase58String(i.caller.bytes) | |
109 | 109 | let charId = valueOrElse(getInteger(this, keyCharsCount), 1) | |
110 | 110 | let bodiesAmount = getIntegerValue(govAddr, keyCharsBodiesAmount) | |
111 | 111 | let eyesAmount = getIntegerValue(govAddr, keyCharsEyesAmount) | |
112 | 112 | let mouthsAmount = getIntegerValue(govAddr, keyCharsMouthsAmount) | |
113 | 113 | let statsTiersRanges = split(getStringValue(govAddr, keyCharsStatsTiersRanges), separator) | |
114 | 114 | let elemBonusRanges = split(getStringValue(govAddr, keyCharsNaturalElemBonusRanges), separator) | |
115 | 115 | let lootsBonusRanges = split(getStringValue(govAddr, keyCharsNaturalLootsBonusRanges), separator) | |
116 | 116 | let generatingBonusRanges = split(getStringValue(govAddr, keyCharsNaturalGeneratingBonusRanges), separator) | |
117 | 117 | let appearance = makeString([toString(randInt(1, bodiesAmount, txId, 0)), toString(randInt(1, eyesAmount, txId, 1)), toString(randInt(1, mouthsAmount, txId, 2))], separator) | |
118 | 118 | let pyroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 3, txId) | |
119 | - | let aquaBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
120 | - | let terraBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
121 | - | let aeroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, | |
122 | - | let generatingBonus = getRandomBonus(statsTiersRanges, generatingBonusRanges, | |
123 | - | let lootsBonus = getRandomBonus(statsTiersRanges, lootsBonusRanges, | |
119 | + | let aquaBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 10, txId) | |
120 | + | let terraBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 17, txId) | |
121 | + | let aeroBonus = getRandomBonus(statsTiersRanges, elemBonusRanges, 24, txId) | |
122 | + | let generatingBonus = getRandomBonus(statsTiersRanges, generatingBonusRanges, 31, txId) | |
123 | + | let lootsBonus = getRandomBonus(statsTiersRanges, lootsBonusRanges, 38, txId) | |
124 | 124 | [StringEntry(cWith(keyOwner, charId), callerAddr), StringEntry(cWith(keyAppearance, charId), appearance), IntegerEntry(cWith(keyPyroBonus, charId), pyroBonus), IntegerEntry(cWith(keyAquaBonus, charId), aquaBonus), IntegerEntry(cWith(keyTerraBonus, charId), terraBonus), IntegerEntry(cWith(keyAeroBonus, charId), aeroBonus), IntegerEntry(cWith(keyLootsBonus, charId), lootsBonus), IntegerEntry(cWith(keyGeneratingBonus, charId), generatingBonus)] | |
125 | 125 | }) | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | @Verifier(tx) | |
129 | 129 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
130 | 130 |
github/deemru/w8io/169f3d6 44.22 ms ◑