tx · 9zSY659oHNi928rcGVZtGpudVui6ENEr61EceouzzUXW

3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv:  -0.01400000 Waves

2022.02.06 16:19 [1911799] smart account 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv > SELF 0.00000000 Waves

{ "type": 13, "id": "9zSY659oHNi928rcGVZtGpudVui6ENEr61EceouzzUXW", "fee": 1400000, "feeAssetId": null, "timestamp": 1644153605934, "version": 2, "chainId": 84, "sender": "3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv", "senderPublicKey": "6pUz5KTgi8pySNF2EuYHUMBkXbTyxL7R7YWGgb2PkhgU", "proofs": [ "2kUfTjbhb2jGvwoupAtUmPHWSq7dA4tVmfntAd1EeedX3yMVJgHCqfdD1v7oDo3uBDSEahkyorB5wwAguHs9G9BH" ], "script": "base64:AAIFAAAAAAAAAAkIAhIAEgMKAQgAAAAQAAAAAAtlZ2dzQXNzZXRJZAEAAAAgF/4YCdBeNnPXi9mYwFve9iIGEZ5QZQVegfUQpkcQUdwAAAAAEGRlbGF5Rm9yQWRvcHRpb24AAAAAAAAAAAIAAAAAE2Rpc2NvdW50Q29lZmZpY2llbnQAAAAAAAAAAAoAAAAAC3R5cGVzQW1vdW50AAAAAAAAAAAJAAAAAA1SZWZlcmVyUmV3YXJkAAAAAAAAAAAFAAAAAA9BZG9wdGlvblN0YXJ0ZWQCAAAAEEFET1BUSU9OX1NUQVJURUQAAAAAEEFkb3B0aW9uRmluaXNoZWQCAAAAEUFET1BUSU9OX0ZJTklTSEVEAQAAABRnZXRBZG9wdGlvblN0YXR1c0tleQAAAAIAAAAHYWRkcmVzcwAAAAR0eElkCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAdhZGRyZXNzAgAAAAFfCQACWAAAAAEFAAAABHR4SWQCAAAAB19zdGF0dXMBAAAAGmdldEFkb3B0aW9uRmluaXNoSGVpZ2h0S2V5AAAAAgAAAAdhZGRyZXNzAAAABHR4S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Complexity": 0 } View: original | compacted Prev: CrhBvqsRNous5GskzWkxB4W38Lwg9g3f4j421dheyAfY Next: AeRLF5VgPooFZGhsQVYouBCkrSsCfjPTFyytP7jt7rVj Diff:
OldNewDifferences
33 {-# CONTENT_TYPE DAPP #-}
44 let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
55
6-let delayForHatching = 2
6+let delayForAdoption = 2
77
88 let discountCoefficient = 10
99
1515
1616 let AdoptionFinished = "ADOPTION_FINISHED"
1717
18-func getHatchingStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
18+func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
1919
2020
21-func getHatchingFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
21+func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
2222
2323
2424 func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di")
3838 }
3939
4040
41-func getRandomNumber (variants,txId,hatchingFinishHeight,offset) = {
42- let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1)))
41+func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = {
42+ let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1)))
4343 let randomHash = sha256((txId + value(randomSeedBlock.vrf)))
4444 (toInt(randomHash, (offset * 8)) % variants)
4545 }
4848 func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen))
4949
5050
51-func getRandomName (txId,hatchingFinishHeight) = {
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)
51+func getRandomName (txId,AdoptionFinishHeight) = {
52+ let hatId = toString(getRandomNumber(6, txId, AdoptionFinishHeight, 0))
53+ let eyeglassId = toString(getRandomNumber(5, txId, AdoptionFinishHeight, 0))
54+ let chainId = toString(getRandomNumber(3, txId, AdoptionFinishHeight, 0))
55+ let lefthandId = toString(getRandomNumber(43, txId, AdoptionFinishHeight, 0))
56+ let righthandId = toString(getRandomNumber(34, txId, AdoptionFinishHeight, 0))
57+ let colorRandom = getRandomNumber(4, txId, AdoptionFinishHeight, 1)
5858 let color = if ((colorRandom == 0))
5959 then "R"
6060 else if ((colorRandom == 1))
7676
7777
7878 @Callable(i)
79-func startDuckHatching () = {
79+func startPandaAdoption () = {
8080 let totalDucksAmount = tryGetInteger("ducks_amount")
8181 let eggsNeeded = countEggsNeededAmount(totalDucksAmount)
8282 let firstPayment = value(i.payments[0])
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))]
83+ let results = [StringEntry(getAdoptionStatusKey(toString(i.originCaller), i.transactionId), AdoptionStarted), IntegerEntry(getAdoptionFinishHeightKey(toString(i.originCaller), i.transactionId), (height + delayForAdoption)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000))]
8484 if ((firstPayment.assetId != eggsAssetId))
8585 then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId)))
8686 else if ((eggsNeeded > firstPayment.amount))
9191
9292
9393 @Callable(i)
94-func finishDuckHatching (txIdStr) = {
94+func finishPandaAdoption (txIdStr) = {
9595 let txId = fromBase58String(txIdStr)
96- let hatchingStatusKey = getHatchingStatusKey(toString(i.caller), txId)
97- let finishHeightKey = getHatchingFinishHeightKey(toString(i.caller), txId)
96+ let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId)
97+ let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId)
9898 let duckIdKey = getDuckIdKey(toString(i.caller), txId)
99- let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) {
99+ let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) {
100100 case t: Boolean =>
101101 t
102102 case _ =>
103103 false
104104 }
105- let hatchingTxStatus = getStringValue(this, hatchingStatusKey)
106- let hatchingFinishHeight = getIntegerValue(this, finishHeightKey)
107- if ((hatchingTxStatus == AdoptionFinished))
105+ let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey)
106+ let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey)
107+ if ((AdoptionTxStatus == AdoptionFinished))
108108 then {
109109 let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId))
110110 throw(("The duck was hatched and claimed already, here is the folowing: " + duckId))
111111 }
112- else if ((hatchingFinishHeight > height))
113- then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes"))
112+ else if ((AdoptionFinishHeight > height))
113+ then throw((((("Adoption is not finished yet " + toString((AdoptionFinishHeight - height))) + " blocks remaining, it will take around ") + toString((AdoptionFinishHeight - height))) + " minutes"))
114114 else {
115- let nameData = getRandomName(txId, hatchingFinishHeight)
115+ let nameData = getRandomName(txId, AdoptionFinishHeight)
116116 let duckGen = nameData._1
117117 let farmGen = nameData._2
118118 let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}")
119- let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight)
119+ let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight)
120120 let assetId = calculateAssetId(asset)
121121 let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1)
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)]
122+[StringEntry(AdoptionStatusKey, 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)]
123123 }
124124 }
125125
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
55
6-let delayForHatching = 2
6+let delayForAdoption = 2
77
88 let discountCoefficient = 10
99
1010 let typesAmount = 9
1111
1212 let RefererReward = 5
1313
1414 let AdoptionStarted = "ADOPTION_STARTED"
1515
1616 let AdoptionFinished = "ADOPTION_FINISHED"
1717
18-func getHatchingStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
18+func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
1919
2020
21-func getHatchingFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
21+func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
2222
2323
2424 func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di")
2525
2626
2727 func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount")
2828
2929
3030 func tryGetInteger (key) = {
3131 let val = match getInteger(this, key) {
3232 case b: Int =>
3333 b
3434 case _ =>
3535 0
3636 }
3737 val
3838 }
3939
4040
41-func getRandomNumber (variants,txId,hatchingFinishHeight,offset) = {
42- let randomSeedBlock = value(blockInfoByHeight((hatchingFinishHeight - 1)))
41+func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = {
42+ let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1)))
4343 let randomHash = sha256((txId + value(randomSeedBlock.vrf)))
4444 (toInt(randomHash, (offset * 8)) % variants)
4545 }
4646
4747
4848 func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen))
4949
5050
51-func getRandomName (txId,hatchingFinishHeight) = {
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)
51+func getRandomName (txId,AdoptionFinishHeight) = {
52+ let hatId = toString(getRandomNumber(6, txId, AdoptionFinishHeight, 0))
53+ let eyeglassId = toString(getRandomNumber(5, txId, AdoptionFinishHeight, 0))
54+ let chainId = toString(getRandomNumber(3, txId, AdoptionFinishHeight, 0))
55+ let lefthandId = toString(getRandomNumber(43, txId, AdoptionFinishHeight, 0))
56+ let righthandId = toString(getRandomNumber(34, txId, AdoptionFinishHeight, 0))
57+ let colorRandom = getRandomNumber(4, txId, AdoptionFinishHeight, 1)
5858 let color = if ((colorRandom == 0))
5959 then "R"
6060 else if ((colorRandom == 1))
6161 then "G"
6262 else if ((colorRandom == 2))
6363 then "B"
6464 else "Y"
6565 $Tuple2(((((((("PANDA-" + hatId) + eyeglassId) + chainId) + lefthandId) + righthandId) + "-") + color), "PANDA")
6666 }
6767
6868
6969 func countEggsNeededAmount (totalDucksAmount) = {
7070 let n = totalDucksAmount
7171 let g = discountCoefficient
7272 let t = typesAmount
7373 let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN)
7474 (price * 1000000)
7575 }
7676
7777
7878 @Callable(i)
79-func startDuckHatching () = {
79+func startPandaAdoption () = {
8080 let totalDucksAmount = tryGetInteger("ducks_amount")
8181 let eggsNeeded = countEggsNeededAmount(totalDucksAmount)
8282 let firstPayment = value(i.payments[0])
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))]
83+ let results = [StringEntry(getAdoptionStatusKey(toString(i.originCaller), i.transactionId), AdoptionStarted), IntegerEntry(getAdoptionFinishHeightKey(toString(i.originCaller), i.transactionId), (height + delayForAdoption)), IntegerEntry("ducks_amount", (totalDucksAmount + 1)), IntegerEntry("ducks_last_price", (eggsNeeded / 1000000))]
8484 if ((firstPayment.assetId != eggsAssetId))
8585 then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId)))
8686 else if ((eggsNeeded > firstPayment.amount))
8787 then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded)))
8888 else (results ++ [ScriptTransfer(i.caller, (firstPayment.amount - eggsNeeded), eggsAssetId)])
8989 }
9090
9191
9292
9393 @Callable(i)
94-func finishDuckHatching (txIdStr) = {
94+func finishPandaAdoption (txIdStr) = {
9595 let txId = fromBase58String(txIdStr)
96- let hatchingStatusKey = getHatchingStatusKey(toString(i.caller), txId)
97- let finishHeightKey = getHatchingFinishHeightKey(toString(i.caller), txId)
96+ let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId)
97+ let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId)
9898 let duckIdKey = getDuckIdKey(toString(i.caller), txId)
99- let duckFromBaby = match getBoolean((("hatching_" + txIdStr) + "_babyDuck")) {
99+ let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) {
100100 case t: Boolean =>
101101 t
102102 case _ =>
103103 false
104104 }
105- let hatchingTxStatus = getStringValue(this, hatchingStatusKey)
106- let hatchingFinishHeight = getIntegerValue(this, finishHeightKey)
107- if ((hatchingTxStatus == AdoptionFinished))
105+ let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey)
106+ let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey)
107+ if ((AdoptionTxStatus == AdoptionFinished))
108108 then {
109109 let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId))
110110 throw(("The duck was hatched and claimed already, here is the folowing: " + duckId))
111111 }
112- else if ((hatchingFinishHeight > height))
113- then throw((((("Hatching is not finished yet " + toString((hatchingFinishHeight - height))) + " blocks remaining, it will take around ") + toString((hatchingFinishHeight - height))) + " minutes"))
112+ else if ((AdoptionFinishHeight > height))
113+ then throw((((("Adoption is not finished yet " + toString((AdoptionFinishHeight - height))) + " blocks remaining, it will take around ") + toString((AdoptionFinishHeight - height))) + " minutes"))
114114 else {
115- let nameData = getRandomName(txId, hatchingFinishHeight)
115+ let nameData = getRandomName(txId, AdoptionFinishHeight)
116116 let duckGen = nameData._1
117117 let farmGen = nameData._2
118118 let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}")
119- let asset = Issue(duckGen, description, 1, 0, false, unit, hatchingFinishHeight)
119+ let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight)
120120 let assetId = calculateAssetId(asset)
121121 let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1)
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)]
122+[StringEntry(AdoptionStatusKey, 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)]
123123 }
124124 }
125125
126126
127127 @Verifier(tx)
128128 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
129129

github/deemru/w8io/169f3d6 
52.67 ms