tx · 6d77RbPSXSqwXUdHk2bKgv6MwHqT8jXEzUYvq5NsFTY9 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv: -0.01400000 Waves 2021.12.28 13:28 [1853971] smart account 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv > SELF 0.00000000 Waves
{ "type": 13, "id": "6d77RbPSXSqwXUdHk2bKgv6MwHqT8jXEzUYvq5NsFTY9", "fee": 1400000, "feeAssetId": null, "timestamp": 1640687374875, "version": 2, "chainId": 84, "sender": "3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv", "senderPublicKey": "6pUz5KTgi8pySNF2EuYHUMBkXbTyxL7R7YWGgb2PkhgU", "proofs": [ "4BXmeWzvup4XoMssBbGejb2BnhZBQVtes4CdKCLZLekunxrJpyx7ZyTjaFTpKb76FomTqten2JTod8ap7aipRsz5" ], "script": "base64:AAIFAAAAAAAAA88IAhIAEgMKAQgaCAoBQRIDZ2VuGhIKAUISDWdldFJhbmRvbU5hbWUaDQoBQxIIcmFuZG9tTm8aCQoBRBIEdHlwZRoPCgFFEgpnZW5lcmF0aW9uGhoKAUYSFWNvdW50RWdnc05lZWRlZEFtb3VudBoVCgFHEhB0b3RhbER1Y2tzQW1vdW50GgYKAUgSAW4aBgoBSRIBZxoGCgFKEgF0GgoKAUsSBXByaWNlGgYKAUwSAWkaDwoBTRIKZWdnc05lZWRlZBoRCgFOEgxmaXJzdFBheW1lbnQaDAoBTxIHcmVzdWx0cxoMCgFQEgd0eElkU3RyGhYKAVESEWhhdGNoaW5nU3RhdHVzS2V5GhQKAVISD2ZpbmlzaEhlaWdodEtleRoOCgFTEglkdWNrSWRLZXkaEQoBVBIMZHVja0Zyb21CYWJ5GhUKAVUSEGhhdGNoaW5nVHhTdGF0dXMaCwoBVhIGZHVja0lkGg0KAVcSCG5hbWVEYXRhGgwKAVgSB2R1Y2tHZW4aDAoBWRIHZmFybUdlbhoQCgFaEgtkZXNjcmlwdGlvbhoQCgFhEgtlZ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QACWAAAAAEFAAAAAmFiBQAAAAFTCQAETAAAAAIJAQAAAAxCb29sZWFuRW50cnkAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAFZHVja18JAAJYAAAAAQUAAAACYWICAAAABl9ncm93bgUAAAABVAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAW0AAAABBQAAAAFYBQAAAAJhYwkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkAASwAAAACCQABLAAAAAICAAAABnN0YXRzXwUAAAABWQIAAAAJX3F1YW50aXR5CQAAZAAAAAIJAQAAAAFvAAAAAQkAASwAAAACCQABLAAAAAICAAAABnN0YXRzXwUAAAABWQIAAAAJX3F1YW50aXR5AAAAAAAAAAABCQAETAAAAAIFAAAAAmFhCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFMAAAABmNhbGxlcgAAAAAAAAAAAQUAAAACYWIFAAAAA25pbAAAAAEAAAACYWQBAAAAAmFlAAAAAAkAAfQAAAADCAUAAAACYWQAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJhZAAAAAZwcm9vZnMAAAAAAAAAAAAIBQAAAAJhZAAAAA9zZW5kZXJQdWJsaWNLZXk2gaq7", "height": 1853971, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3NHwcZZ1t57S5W2ZdovYAvqq8z4AeiPKZVjJ6L1PWw7S Next: GyaaqetgF6XnsNAow43fASKab58SKajemYtbDYvBiYcC Diff:
Old | New | Differences | |
---|---|---|---|
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getRandomName (txId,hatchingFinishHeight) = { | |
52 | - | let jackpotRandom = getRandomNumber(500, txId, hatchingFinishHeight, 0) | |
53 | - | if (if ((jackpotRandom == 111)) | |
54 | - | then (wasUniqueBorn("DUCK-WWWWWWWM-JU") == 0) | |
55 | - | else false) | |
56 | - | then $Tuple2("DUCK-WWWWWWWM-JU", "8W-J") | |
57 | - | else { | |
58 | - | let typeRandom = getRandomNumber(4, txId, hatchingFinishHeight, 0) | |
59 | - | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 1) | |
60 | - | let color = if ((colorRandom == 0)) | |
61 | - | then "Y" | |
62 | - | else if ((colorRandom == 1)) | |
63 | - | then "G" | |
64 | - | else if ((colorRandom == 2)) | |
65 | - | then "B" | |
66 | - | else "R" | |
67 | - | if ((typeRandom == 0)) | |
68 | - | then $Tuple2(("DUCK-FFFFFFFF-G" + color), "8F-G") | |
69 | - | else if ((typeRandom == 1)) | |
70 | - | then $Tuple2(("DUCK-HHHHHHHH-G" + color), "8H-G") | |
71 | - | else if ((typeRandom == 2)) | |
72 | - | then $Tuple2(("DUCK-GGGGGGGG-G" + color), "8G-G") | |
73 | - | else $Tuple2(("DUCK-IIIIIIII-G" + color), "8I-G") | |
74 | - | } | |
52 | + | let randomNo = getRandomNumber(4000, txId, hatchingFinishHeight, 0) | |
53 | + | let type = if ((randomNo > 2000)) | |
54 | + | then "DOG" | |
55 | + | else "DRAGON" | |
56 | + | let generation = (randomNo % 2000) | |
57 | + | if ((generation > 1800)) | |
58 | + | then $Tuple2(((type + "-WW-") + toString(randomNo)), (type + "-WW")) | |
59 | + | else if ((generation > 1600)) | |
60 | + | then $Tuple2(((type + "-TG-") + toString(randomNo)), (type + "-TG")) | |
61 | + | else if ((generation > 1400)) | |
62 | + | then $Tuple2(((type + "-T-") + toString(randomNo)), (type + "-T")) | |
63 | + | else if ((generation > 1200)) | |
64 | + | then $Tuple2(((type + "-ST-") + toString(randomNo)), (type + "-ST")) | |
65 | + | else if ((generation > 1000)) | |
66 | + | then $Tuple2(((type + "-SD-") + toString(randomNo)), (type + "-SD")) | |
67 | + | else if ((generation > 800)) | |
68 | + | then $Tuple2(((type + "-SG-") + toString(randomNo)), (type + "-SG")) | |
69 | + | else if ((generation > 600)) | |
70 | + | then $Tuple2(((type + "-PE-") + toString(randomNo)), (type + "-PE")) | |
71 | + | else if ((generation > 400)) | |
72 | + | then $Tuple2(((type + "-M-") + toString(randomNo)), (type + "-M")) | |
73 | + | else if ((generation > 200)) | |
74 | + | then $Tuple2(((type + "-LOG-") + toString(randomNo)), (type + "-LOG")) | |
75 | + | else if ((generation > 0)) | |
76 | + | then $Tuple2(((type + "-D-") + toString(randomNo)), (type + "-D")) | |
77 | + | else $Tuple2((type + "-D-1"), (type + "-D")) | |
75 | 78 | } | |
76 | 79 | ||
77 | 80 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB' | |
5 | 5 | ||
6 | 6 | let delayForHatching = 2 | |
7 | 7 | ||
8 | 8 | let discountCoefficient = 10 | |
9 | 9 | ||
10 | 10 | let typesAmount = 9 | |
11 | 11 | ||
12 | 12 | let RefererReward = 5 | |
13 | 13 | ||
14 | 14 | let AdoptionStarted = "ADOPTION_STARTED" | |
15 | 15 | ||
16 | 16 | let AdoptionFinished = "ADOPTION_FINISHED" | |
17 | 17 | ||
18 | 18 | func getHatchingStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status") | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func getHatchingFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh") | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di") | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount") | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func tryGetInteger (key) = { | |
31 | 31 | let val = match getInteger(this, key) { | |
32 | 32 | case b: Int => | |
33 | 33 | b | |
34 | 34 | case _ => | |
35 | 35 | 0 | |
36 | 36 | } | |
37 | 37 | val | |
38 | 38 | } | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func getRandomNumber (variants,txId,hatchingFinishHeight,offset) = { | |
42 | 42 | let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1))) | |
43 | 43 | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
44 | 44 | (toInt(randomHash, (offset * 8)) % variants) | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen)) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getRandomName (txId,hatchingFinishHeight) = { | |
52 | - | let jackpotRandom = getRandomNumber(500, txId, hatchingFinishHeight, 0) | |
53 | - | if (if ((jackpotRandom == 111)) | |
54 | - | then (wasUniqueBorn("DUCK-WWWWWWWM-JU") == 0) | |
55 | - | else false) | |
56 | - | then $Tuple2("DUCK-WWWWWWWM-JU", "8W-J") | |
57 | - | else { | |
58 | - | let typeRandom = getRandomNumber(4, txId, hatchingFinishHeight, 0) | |
59 | - | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 1) | |
60 | - | let color = if ((colorRandom == 0)) | |
61 | - | then "Y" | |
62 | - | else if ((colorRandom == 1)) | |
63 | - | then "G" | |
64 | - | else if ((colorRandom == 2)) | |
65 | - | then "B" | |
66 | - | else "R" | |
67 | - | if ((typeRandom == 0)) | |
68 | - | then $Tuple2(("DUCK-FFFFFFFF-G" + color), "8F-G") | |
69 | - | else if ((typeRandom == 1)) | |
70 | - | then $Tuple2(("DUCK-HHHHHHHH-G" + color), "8H-G") | |
71 | - | else if ((typeRandom == 2)) | |
72 | - | then $Tuple2(("DUCK-GGGGGGGG-G" + color), "8G-G") | |
73 | - | else $Tuple2(("DUCK-IIIIIIII-G" + color), "8I-G") | |
74 | - | } | |
52 | + | let randomNo = getRandomNumber(4000, txId, hatchingFinishHeight, 0) | |
53 | + | let type = if ((randomNo > 2000)) | |
54 | + | then "DOG" | |
55 | + | else "DRAGON" | |
56 | + | let generation = (randomNo % 2000) | |
57 | + | if ((generation > 1800)) | |
58 | + | then $Tuple2(((type + "-WW-") + toString(randomNo)), (type + "-WW")) | |
59 | + | else if ((generation > 1600)) | |
60 | + | then $Tuple2(((type + "-TG-") + toString(randomNo)), (type + "-TG")) | |
61 | + | else if ((generation > 1400)) | |
62 | + | then $Tuple2(((type + "-T-") + toString(randomNo)), (type + "-T")) | |
63 | + | else if ((generation > 1200)) | |
64 | + | then $Tuple2(((type + "-ST-") + toString(randomNo)), (type + "-ST")) | |
65 | + | else if ((generation > 1000)) | |
66 | + | then $Tuple2(((type + "-SD-") + toString(randomNo)), (type + "-SD")) | |
67 | + | else if ((generation > 800)) | |
68 | + | then $Tuple2(((type + "-SG-") + toString(randomNo)), (type + "-SG")) | |
69 | + | else if ((generation > 600)) | |
70 | + | then $Tuple2(((type + "-PE-") + toString(randomNo)), (type + "-PE")) | |
71 | + | else if ((generation > 400)) | |
72 | + | then $Tuple2(((type + "-M-") + toString(randomNo)), (type + "-M")) | |
73 | + | else if ((generation > 200)) | |
74 | + | then $Tuple2(((type + "-LOG-") + toString(randomNo)), (type + "-LOG")) | |
75 | + | else if ((generation > 0)) | |
76 | + | then $Tuple2(((type + "-D-") + toString(randomNo)), (type + "-D")) | |
77 | + | else $Tuple2((type + "-D-1"), (type + "-D")) | |
75 | 78 | } | |
76 | 79 | ||
77 | 80 | ||
78 | 81 | func countEggsNeededAmount (totalDucksAmount) = { | |
79 | 82 | let n = totalDucksAmount | |
80 | 83 | let g = discountCoefficient | |
81 | 84 | let t = typesAmount | |
82 | 85 | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
83 | 86 | (price * 1000000) | |
84 | 87 | } | |
85 | 88 | ||
86 | 89 | ||
87 | 90 | @Callable(i) | |
88 | 91 | func startDuckHatching () = { | |
89 | 92 | let totalDucksAmount = tryGetInteger("ducks_amount") | |
90 | 93 | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
91 | 94 | let firstPayment = value(i.payments[0]) | |
92 | 95 | let results = [StringEntry(getHatchingStatusKey(toString(i.originCaller), i.transactionId), AdoptionStarted), IntegerEntry(getHatchingFinishHeightKey(toString(i.originCaller), i.transactionId), (height + delayForHatching)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000))] | |
93 | 96 | if ((firstPayment.assetId != eggsAssetId)) | |
94 | 97 | then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId))) | |
95 | 98 | else if ((eggsNeeded > firstPayment.amount)) | |
96 | 99 | then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded))) | |
97 | 100 | else (results ++ [ScriptTransfer(i.caller, (firstPayment.amount - eggsNeeded), eggsAssetId)]) | |
98 | 101 | } | |
99 | 102 | ||
100 | 103 | ||
101 | 104 | ||
102 | 105 | @Callable(i) | |
103 | 106 | func finishDuckHatching (txIdStr) = { | |
104 | 107 | let txId = fromBase58String(txIdStr) | |
105 | 108 | let hatchingStatusKey = getHatchingStatusKey(toString(i.caller), txId) | |
106 | 109 | let finishHeightKey = getHatchingFinishHeightKey(toString(i.caller), txId) | |
107 | 110 | let duckIdKey = getDuckIdKey(toString(i.caller), txId) | |
108 | 111 | let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) { | |
109 | 112 | case t: Boolean => | |
110 | 113 | t | |
111 | 114 | case _ => | |
112 | 115 | false | |
113 | 116 | } | |
114 | 117 | let hatchingTxStatus = getStringValue(this, hatchingStatusKey) | |
115 | 118 | let hatchingFinishHeight = getIntegerValue(this, finishHeightKey) | |
116 | 119 | if ((hatchingTxStatus == AdoptionFinished)) | |
117 | 120 | then { | |
118 | 121 | let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId)) | |
119 | 122 | throw(("The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
120 | 123 | } | |
121 | 124 | else if ((hatchingFinishHeight > height)) | |
122 | 125 | then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes")) | |
123 | 126 | else { | |
124 | 127 | let nameData = getRandomName(txId, hatchingFinishHeight) | |
125 | 128 | let duckGen = nameData._1 | |
126 | 129 | let farmGen = nameData._2 | |
127 | 130 | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
128 | 131 | let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight) | |
129 | 132 | let assetId = calculateAssetId(asset) | |
130 | 133 | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
131 | 134 | [StringEntry(hatchingStatusKey, AdoptionFinished), StringEntry(duckIdKey, toBase58String(assetId)), StringEntry(toBase58String(assetId), duckIdKey), BooleanEntry((("duck_" + toBase58String(assetId)) + "_grown"), duckFromBaby), IntegerEntry(getDuckStatsKey(duckGen), amount), IntegerEntry((("stats_" + farmGen) + "_quantity"), (tryGetInteger((("stats_" + farmGen) + "_quantity")) + 1)), asset, ScriptTransfer(i.caller, 1, assetId)] | |
132 | 135 | } | |
133 | 136 | } | |
134 | 137 | ||
135 | 138 | ||
136 | 139 | @Verifier(tx) | |
137 | 140 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
138 | 141 |
github/deemru/w8io/169f3d6 52.35 ms ◑