tx · GyaaqetgF6XnsNAow43fASKab58SKajemYtbDYvBiYcC 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv: -0.01400000 Waves 2022.02.06 16:02 [1911778] smart account 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv > SELF 0.00000000 Waves
{ "type": 13, "id": "GyaaqetgF6XnsNAow43fASKab58SKajemYtbDYvBiYcC", "fee": 1400000, "feeAssetId": null, "timestamp": 1644152502240, "version": 2, "chainId": 84, "sender": "3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv", "senderPublicKey": "6pUz5KTgi8pySNF2EuYHUMBkXbTyxL7R7YWGgb2PkhgU", "proofs": [ "3mtYTTptYmb2supzr9qZvMHDeQ917WBKgpW9tnaLiEVhQexQr6U2RdhXFSTNySqCFJ8dpSz9DkjmbSb6JT2XseJb" ], "script": "base64:AAIFAAAAAAAAAAkIAhIAEgMKAQgAAAAQAAAAAAtlZ2dzQXNzZXRJZAEAAAAgF/4YCdBeNnPXi9mYwFve9iIGEZ5QZQVegfUQpkcQUdwAAAAAEGRlbGF5Rm9ySGF0Y2hpbmcAAAAAAAAAAAIAAAAAE2Rpc2NvdW50Q29lZmZpY2llbnQAAAAAAAAAAAoAAAAAC3R5cGVzQW1vdW50AAAAAAAAAAAJAAAAAA1SZWZlcmVyUmV3YXJkAAAAAAAAAAAFAAAAAA9BZG9wdGlvblN0YXJ0ZWQCAAAAEEFET1BUSU9OX1NUQVJURUQAAAAAEEFkb3B0aW9uRmluaXNoZWQCAAAAEUFET1BUSU9OX0ZJTklTSEVEAQAAABRnZXRIYXRjaGluZ1N0YXR1c0tleQAAAAIAAAAHYWRkcmVzcwAAAAR0eElkCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAdhZGRyZXNzAgAAAAFfCQACWAAAAAEFAAAABHR4SWQCAAAAB19zdGF0dXMBAAAAGmdldEhhdGNoaW5nRmluaXNoSGVpZ2h0S2V5AAAAAgAAAAdhZGRyZXNzAAAABH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View: original | compacted Prev: 6d77RbPSXSqwXUdHk2bKgv6MwHqT8jXEzUYvq5NsFTY9 Next: CrhBvqsRNous5GskzWkxB4W38Lwg9g3f4j421dheyAfY Diff:
Old | New | Differences | |
---|---|---|---|
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getRandomName (txId,hatchingFinishHeight) = { | |
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")) | |
52 | + | let hatId = toString(getRandomNumber(6, txId, hatchingFinishHeight, 0)) | |
53 | + | let eyeglassId = toString(getRandomNumber(5, txId, hatchingFinishHeight, 0)) | |
54 | + | let chainId = toString(getRandomNumber(3, txId, hatchingFinishHeight, 0)) | |
55 | + | let lefthandId = toString(getRandomNumber(43, txId, hatchingFinishHeight, 0)) | |
56 | + | let righthandId = toString(getRandomNumber(34, txId, hatchingFinishHeight, 0)) | |
57 | + | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 1) | |
58 | + | let color = if ((colorRandom == 0)) | |
59 | + | then "R" | |
60 | + | else if ((colorRandom == 1)) | |
61 | + | then "G" | |
62 | + | else if ((colorRandom == 2)) | |
63 | + | then "B" | |
64 | + | else "Y" | |
65 | + | $Tuple2((((((("PANDA-" + hatId) + eyeglassId) + chainId) + lefthandId) + righthandId) + "-"), "PANDA") | |
78 | 66 | } | |
79 | 67 | ||
80 | 68 |
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 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")) | |
52 | + | let hatId = toString(getRandomNumber(6, txId, hatchingFinishHeight, 0)) | |
53 | + | let eyeglassId = toString(getRandomNumber(5, txId, hatchingFinishHeight, 0)) | |
54 | + | let chainId = toString(getRandomNumber(3, txId, hatchingFinishHeight, 0)) | |
55 | + | let lefthandId = toString(getRandomNumber(43, txId, hatchingFinishHeight, 0)) | |
56 | + | let righthandId = toString(getRandomNumber(34, txId, hatchingFinishHeight, 0)) | |
57 | + | let colorRandom = getRandomNumber(4, txId, hatchingFinishHeight, 1) | |
58 | + | let color = if ((colorRandom == 0)) | |
59 | + | then "R" | |
60 | + | else if ((colorRandom == 1)) | |
61 | + | then "G" | |
62 | + | else if ((colorRandom == 2)) | |
63 | + | then "B" | |
64 | + | else "Y" | |
65 | + | $Tuple2((((((("PANDA-" + hatId) + eyeglassId) + chainId) + lefthandId) + righthandId) + "-"), "PANDA") | |
78 | 66 | } | |
79 | 67 | ||
80 | 68 | ||
81 | 69 | func countEggsNeededAmount (totalDucksAmount) = { | |
82 | 70 | let n = totalDucksAmount | |
83 | 71 | let g = discountCoefficient | |
84 | 72 | let t = typesAmount | |
85 | 73 | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
86 | 74 | (price * 1000000) | |
87 | 75 | } | |
88 | 76 | ||
89 | 77 | ||
90 | 78 | @Callable(i) | |
91 | 79 | func startDuckHatching () = { | |
92 | 80 | let totalDucksAmount = tryGetInteger("ducks_amount") | |
93 | 81 | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
94 | 82 | let firstPayment = value(i.payments[0]) | |
95 | 83 | 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))] | |
96 | 84 | if ((firstPayment.assetId != eggsAssetId)) | |
97 | 85 | then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId))) | |
98 | 86 | else if ((eggsNeeded > firstPayment.amount)) | |
99 | 87 | then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded))) | |
100 | 88 | else (results ++ [ScriptTransfer(i.caller, (firstPayment.amount - eggsNeeded), eggsAssetId)]) | |
101 | 89 | } | |
102 | 90 | ||
103 | 91 | ||
104 | 92 | ||
105 | 93 | @Callable(i) | |
106 | 94 | func finishDuckHatching (txIdStr) = { | |
107 | 95 | let txId = fromBase58String(txIdStr) | |
108 | 96 | let hatchingStatusKey = getHatchingStatusKey(toString(i.caller), txId) | |
109 | 97 | let finishHeightKey = getHatchingFinishHeightKey(toString(i.caller), txId) | |
110 | 98 | let duckIdKey = getDuckIdKey(toString(i.caller), txId) | |
111 | 99 | let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) { | |
112 | 100 | case t: Boolean => | |
113 | 101 | t | |
114 | 102 | case _ => | |
115 | 103 | false | |
116 | 104 | } | |
117 | 105 | let hatchingTxStatus = getStringValue(this, hatchingStatusKey) | |
118 | 106 | let hatchingFinishHeight = getIntegerValue(this, finishHeightKey) | |
119 | 107 | if ((hatchingTxStatus == AdoptionFinished)) | |
120 | 108 | then { | |
121 | 109 | let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId)) | |
122 | 110 | throw(("The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
123 | 111 | } | |
124 | 112 | else if ((hatchingFinishHeight > height)) | |
125 | 113 | then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes")) | |
126 | 114 | else { | |
127 | 115 | let nameData = getRandomName(txId, hatchingFinishHeight) | |
128 | 116 | let duckGen = nameData._1 | |
129 | 117 | let farmGen = nameData._2 | |
130 | 118 | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
131 | 119 | let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight) | |
132 | 120 | let assetId = calculateAssetId(asset) | |
133 | 121 | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
134 | 122 | [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)] | |
135 | 123 | } | |
136 | 124 | } | |
137 | 125 | ||
138 | 126 | ||
139 | 127 | @Verifier(tx) | |
140 | 128 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
141 | 129 |
github/deemru/w8io/169f3d6 37.79 ms ◑