tx · AeRLF5VgPooFZGhsQVYouBCkrSsCfjPTFyytP7jt7rVj

3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv:  -0.00700000 Waves

2022.07.23 21:22 [2152776] smart account 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv > SELF 0.00000000 Waves

{ "type": 13, "id": "AeRLF5VgPooFZGhsQVYouBCkrSsCfjPTFyytP7jt7rVj", "fee": 700000, "feeAssetId": null, "timestamp": 1658600616565, "version": 2, "chainId": 84, "sender": "3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv", "senderPublicKey": "6pUz5KTgi8pySNF2EuYHUMBkXbTyxL7R7YWGgb2PkhgU", "proofs": [ "y7kkkzFTDeFdwhY2x6cMP8FdVqqzkcnwNffurv7xtoi4BwxKxqDRTmQ9k28aFCZYt3Uaew5PiwHcDBfcE65UMBa" ], "script": "base64:AAIFAAAAAAAAAAcIAhIDCgEBAAAACgAAAAAKZWdnQXNzZXRJZAEAAAAgF/4YCdBeNnPXi9mYwFve9iIGEZ5QZQVegfUQpkcQUdwAAAAAEGNvbGxlY3RvckFkZHJlc3MBAAAAGgFUAqwIk+AYdvRW0p5bt95mLATeRN8JIV7TAAAAAAVkZWxheQAAAAAAAAAFoAAAAAALbWF4RXhjaGFuZ2UAAAAAADuaygAAAAAADGV4Y2hhbmdlUmF0ZQAAAAAAAAAAAgAAAAAMd2F2ZURlY2ltYWxzAAAAAAAAAAAIAAAAAA10b2tlbkRlY2ltYWxzAAAAAAAAAAAIAQAAAA10cnlHZXRJbnRlZ2VyAAAAAQAAAANrZXkEAAAAA3ZhbAQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYgUAAAAHJG1hdGNoMAUAAAABYgAAAAAAAAAAAAUAAAADdmFsAQAAAAx0cnlHZXRTdHJpbmcAAAABAAAAA2tleQQAAAADdmFsBAAAAAckbWF0Y2gw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A25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5DlzsVg==", "height": 2152776, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9zSY659oHNi928rcGVZtGpudVui6ENEr61EceouzzUXW Next: 6abPacCV6SA8LQ8MYnRuta7yg1yqt373HVgSkWBL9cHE Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
4+let eggAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
55
6-let delayForAdoption = 2
6+let collectorAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU'
77
8-let discountCoefficient = 10
8+let delay = 1440
99
10-let typesAmount = 9
10+let maxExchange = 1000000000
1111
12-let RefererReward = 5
12+let exchangeRate = 2
1313
14-let AdoptionStarted = "ADOPTION_STARTED"
14+let waveDecimals = 8
1515
16-let AdoptionFinished = "ADOPTION_FINISHED"
17-
18-func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
19-
20-
21-func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
22-
23-
24-func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di")
25-
26-
27-func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount")
28-
16+let tokenDecimals = 8
2917
3018 func tryGetInteger (key) = {
3119 let val = match getInteger(this, key) {
3826 }
3927
4028
41-func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = {
42- let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1)))
43- let randomHash = sha256((txId + value(randomSeedBlock.vrf)))
44- (toInt(randomHash, (offset * 8)) % variants)
29+func tryGetString (key) = {
30+ let val = match getString(this, key) {
31+ case b: String =>
32+ b
33+ case _ =>
34+ ""
35+ }
36+ val
4537 }
4638
4739
48-func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen))
49-
50-
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)
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) + "-") + color), "PANDA")
66- }
67-
68-
69-func countEggsNeededAmount (totalDucksAmount) = {
70- let n = totalDucksAmount
71- let g = discountCoefficient
72- let t = typesAmount
73- let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN)
74- (price * 1000000)
75- }
40+func tryGetBoolean (key) = match getBoolean(this, key) {
41+ case b: Boolean =>
42+ b
43+ case _ =>
44+ false
45+}
7646
7747
7848 @Callable(i)
79-func startPandaAdoption () = {
80- let totalDucksAmount = tryGetInteger("ducks_amount")
81- let eggsNeeded = countEggsNeededAmount(totalDucksAmount)
82- let firstPayment = value(i.payments[0])
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))]
84- if ((firstPayment.assetId != eggsAssetId))
85- then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId)))
86- else if ((eggsNeeded > firstPayment.amount))
87- then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded)))
88- else (results ++ [ScriptTransfer(i.caller, (firstPayment.amount - eggsNeeded), eggsAssetId)])
89- }
90-
91-
92-
93-@Callable(i)
94-func finishPandaAdoption (txIdStr) = {
95- let txId = fromBase58String(txIdStr)
96- let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId)
97- let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId)
98- let duckIdKey = getDuckIdKey(toString(i.caller), txId)
99- let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) {
100- case t: Boolean =>
101- t
102- case _ =>
103- false
104- }
105- let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey)
106- let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey)
107- if ((AdoptionTxStatus == AdoptionFinished))
108- then {
109- let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId))
110- throw(("The duck was hatched and claimed already, here is the folowing: " + duckId))
111- }
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"))
114- else {
115- let nameData = getRandomName(txId, AdoptionFinishHeight)
116- let duckGen = nameData._1
117- let farmGen = nameData._2
118- let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}")
119- let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight)
120- let assetId = calculateAssetId(asset)
121- let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1)
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)]
123- }
49+func exchangeToken (amount) = {
50+ let transactionId = toBase58String(i.transactionId)
51+ let totalExchangedAmount = (amount / exchangeRate)
52+ let lastTransferedDay = tryGetInteger((("receiver_" + toString(i.originCaller)) + "_lastDay"))
53+ let totalAmountInDay = tryGetInteger((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"))
54+ if ((height > (lastTransferedDay + delay)))
55+ then if ((totalAmountInDay > maxExchange))
56+ then throw("Max exchange limit reached. Please try after 24 hours.")
57+ else if (((totalAmountInDay + amount) > maxExchange))
58+ then throw("Max exchange crossed. Please try with lower value.")
59+ else [IntegerEntry((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"), (totalAmountInDay + amount)), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_waveAmount"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_tokenAmount"), totalExchangedAmount), ScriptTransfer(Address(collectorAddress), amount, unit), ScriptTransfer(i.originCaller, totalExchangedAmount, eggAssetId)]
60+ else [IntegerEntry((("receiver_" + toString(i.originCaller)) + "_lastDay"), height), IntegerEntry((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_waveAmount"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_tokenAmount"), totalExchangedAmount), ScriptTransfer(Address(collectorAddress), amount, unit), ScriptTransfer(i.originCaller, totalExchangedAmount, eggAssetId)]
12461 }
12562
12663
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
4+let eggAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB'
55
6-let delayForAdoption = 2
6+let collectorAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU'
77
8-let discountCoefficient = 10
8+let delay = 1440
99
10-let typesAmount = 9
10+let maxExchange = 1000000000
1111
12-let RefererReward = 5
12+let exchangeRate = 2
1313
14-let AdoptionStarted = "ADOPTION_STARTED"
14+let waveDecimals = 8
1515
16-let AdoptionFinished = "ADOPTION_FINISHED"
17-
18-func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status")
19-
20-
21-func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh")
22-
23-
24-func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di")
25-
26-
27-func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount")
28-
16+let tokenDecimals = 8
2917
3018 func tryGetInteger (key) = {
3119 let val = match getInteger(this, key) {
3220 case b: Int =>
3321 b
3422 case _ =>
3523 0
3624 }
3725 val
3826 }
3927
4028
41-func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = {
42- let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1)))
43- let randomHash = sha256((txId + value(randomSeedBlock.vrf)))
44- (toInt(randomHash, (offset * 8)) % variants)
29+func tryGetString (key) = {
30+ let val = match getString(this, key) {
31+ case b: String =>
32+ b
33+ case _ =>
34+ ""
35+ }
36+ val
4537 }
4638
4739
48-func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen))
49-
50-
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)
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) + "-") + color), "PANDA")
66- }
67-
68-
69-func countEggsNeededAmount (totalDucksAmount) = {
70- let n = totalDucksAmount
71- let g = discountCoefficient
72- let t = typesAmount
73- let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN)
74- (price * 1000000)
75- }
40+func tryGetBoolean (key) = match getBoolean(this, key) {
41+ case b: Boolean =>
42+ b
43+ case _ =>
44+ false
45+}
7646
7747
7848 @Callable(i)
79-func startPandaAdoption () = {
80- let totalDucksAmount = tryGetInteger("ducks_amount")
81- let eggsNeeded = countEggsNeededAmount(totalDucksAmount)
82- let firstPayment = value(i.payments[0])
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))]
84- if ((firstPayment.assetId != eggsAssetId))
85- then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId)))
86- else if ((eggsNeeded > firstPayment.amount))
87- then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded)))
88- else (results ++ [ScriptTransfer(i.caller, (firstPayment.amount - eggsNeeded), eggsAssetId)])
89- }
90-
91-
92-
93-@Callable(i)
94-func finishPandaAdoption (txIdStr) = {
95- let txId = fromBase58String(txIdStr)
96- let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId)
97- let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId)
98- let duckIdKey = getDuckIdKey(toString(i.caller), txId)
99- let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) {
100- case t: Boolean =>
101- t
102- case _ =>
103- false
104- }
105- let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey)
106- let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey)
107- if ((AdoptionTxStatus == AdoptionFinished))
108- then {
109- let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId))
110- throw(("The duck was hatched and claimed already, here is the folowing: " + duckId))
111- }
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"))
114- else {
115- let nameData = getRandomName(txId, AdoptionFinishHeight)
116- let duckGen = nameData._1
117- let farmGen = nameData._2
118- let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}")
119- let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight)
120- let assetId = calculateAssetId(asset)
121- let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1)
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)]
123- }
49+func exchangeToken (amount) = {
50+ let transactionId = toBase58String(i.transactionId)
51+ let totalExchangedAmount = (amount / exchangeRate)
52+ let lastTransferedDay = tryGetInteger((("receiver_" + toString(i.originCaller)) + "_lastDay"))
53+ let totalAmountInDay = tryGetInteger((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"))
54+ if ((height > (lastTransferedDay + delay)))
55+ then if ((totalAmountInDay > maxExchange))
56+ then throw("Max exchange limit reached. Please try after 24 hours.")
57+ else if (((totalAmountInDay + amount) > maxExchange))
58+ then throw("Max exchange crossed. Please try with lower value.")
59+ else [IntegerEntry((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"), (totalAmountInDay + amount)), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_waveAmount"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_tokenAmount"), totalExchangedAmount), ScriptTransfer(Address(collectorAddress), amount, unit), ScriptTransfer(i.originCaller, totalExchangedAmount, eggAssetId)]
60+ else [IntegerEntry((("receiver_" + toString(i.originCaller)) + "_lastDay"), height), IntegerEntry((("receiver_" + toString(i.originCaller)) + "_totalAmountInDay"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_waveAmount"), amount), IntegerEntry((((("receiver_" + toString(i.originCaller)) + "_transactionId_") + transactionId) + "_tokenAmount"), totalExchangedAmount), ScriptTransfer(Address(collectorAddress), amount, unit), ScriptTransfer(i.originCaller, totalExchangedAmount, eggAssetId)]
12461 }
12562
12663
12764 @Verifier(tx)
12865 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
12966

github/deemru/w8io/169f3d6 
35.44 ms