tx · 6abPacCV6SA8LQ8MYnRuta7yg1yqt373HVgSkWBL9cHE 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv: -0.01100000 Waves 2022.07.23 21:26 [2152781] smart account 3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv > SELF 0.00000000 Waves
{ "type": 13, "id": "6abPacCV6SA8LQ8MYnRuta7yg1yqt373HVgSkWBL9cHE", "fee": 1100000, "feeAssetId": null, "timestamp": 1658600752825, "version": 2, "chainId": 84, "sender": "3N4uWa2T9W2p4WgDwLPo3kWRp8eXRatp4vv", "senderPublicKey": "6pUz5KTgi8pySNF2EuYHUMBkXbTyxL7R7YWGgb2PkhgU", "proofs": [ "5rm9uPeFPQkexWRkahv3WRu88R8uJXRbeADrtjrbDXzfECCxpD7vJS6dCDag4PejRPE6aR3oeshsbTxfaYUehczA" ], "script": "base64:AAIFAAAAAAAAAAkIAhIAEgMKAQgAAAARAAAAAAtlZ2dzQXNzZXRJZAEAAAAgF/4YCdBeNnPXi9mYwFve9iIGEZ5QZQVegfUQpkcQUdwAAAAAEGNvbGxlY3RvckFkZHJlc3MBAAAAGgFUAqwIk+AYdvRW0p5bt95mLATeRN8JIV7TAAAAABBkZWxheUZvckFkb3B0aW9uAAAAAAAAAAACAAAAABNkaXNjb3VudENvZWZmaWNpZW50AAAAAAAAAAAKAAAAAAt0eXBlc0Ftb3VudAAAAAAAAAAACQAAAAANUmVmZXJlclJld2FyZAAAAAAAAAAABQAAAAAPQWRvcHRpb25TdGFydGVkAgAAABBBRE9QVElPTl9TVEFSVEVEAAAAABBBZG9wdGlvbkZpbmlzaGVkAgAAABFBRE9QVElPTl9GSU5JU0hFRAEAAAAUZ2V0QWRvcHRpb25TdGF0dXNLZXkAAAACAAAAB2FkZHJlc3MAAAAEdHhJZAkAASwAAAACCQABLAAAAAIJAAEsAAAAAgUAAAAHYWRkcmVzcwIAAAABXwkAAlgAAAABBQAAAAR0eElkAgAAAAdfc3RhdHVzAQAAABpnZXR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AACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5Sgj6bw==", "height": 2152781, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: AeRLF5VgPooFZGhsQVYouBCkrSsCfjPTFyytP7jt7rVj Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB' | |
5 | 5 | ||
6 | 6 | let collectorAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU' | |
7 | 7 | ||
8 | - | let | |
8 | + | let delayForAdoption = 2 | |
9 | 9 | ||
10 | - | let | |
10 | + | let discountCoefficient = 10 | |
11 | 11 | ||
12 | - | let | |
12 | + | let typesAmount = 9 | |
13 | 13 | ||
14 | - | let | |
14 | + | let RefererReward = 5 | |
15 | 15 | ||
16 | - | let tokenDecimals = 8 | |
16 | + | let AdoptionStarted = "ADOPTION_STARTED" | |
17 | + | ||
18 | + | let AdoptionFinished = "ADOPTION_FINISHED" | |
19 | + | ||
20 | + | func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status") | |
21 | + | ||
22 | + | ||
23 | + | func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh") | |
24 | + | ||
25 | + | ||
26 | + | func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di") | |
27 | + | ||
28 | + | ||
29 | + | func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount") | |
30 | + | ||
17 | 31 | ||
18 | 32 | func tryGetInteger (key) = { | |
19 | 33 | let val = match getInteger(this, key) { | |
26 | 40 | } | |
27 | 41 | ||
28 | 42 | ||
29 | - | func tryGetString (key) = { | |
30 | - | let val = match getString(this, key) { | |
31 | - | case b: String => | |
32 | - | b | |
33 | - | case _ => | |
34 | - | "" | |
35 | - | } | |
36 | - | val | |
43 | + | func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = { | |
44 | + | let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1))) | |
45 | + | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
46 | + | (toInt(randomHash, (offset * 8)) % variants) | |
37 | 47 | } | |
38 | 48 | ||
39 | 49 | ||
40 | - | func tryGetBoolean (key) = match getBoolean(this, key) { | |
41 | - | case b: Boolean => | |
42 | - | b | |
43 | - | case _ => | |
44 | - | false | |
45 | - | } | |
50 | + | func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen)) | |
51 | + | ||
52 | + | ||
53 | + | func getRandomName (txId,AdoptionFinishHeight) = { | |
54 | + | let hatId = toString(getRandomNumber(6, txId, AdoptionFinishHeight, 0)) | |
55 | + | let eyeglassId = toString(getRandomNumber(5, txId, AdoptionFinishHeight, 0)) | |
56 | + | let chainId = toString(getRandomNumber(3, txId, AdoptionFinishHeight, 0)) | |
57 | + | let lefthandId = toString(getRandomNumber(43, txId, AdoptionFinishHeight, 0)) | |
58 | + | let righthandId = toString(getRandomNumber(34, txId, AdoptionFinishHeight, 0)) | |
59 | + | let colorRandom = getRandomNumber(4, txId, AdoptionFinishHeight, 1) | |
60 | + | let color = if ((colorRandom == 0)) | |
61 | + | then "R" | |
62 | + | else if ((colorRandom == 1)) | |
63 | + | then "G" | |
64 | + | else if ((colorRandom == 2)) | |
65 | + | then "B" | |
66 | + | else "Y" | |
67 | + | $Tuple2(((((((("PANDA-" + hatId) + eyeglassId) + chainId) + lefthandId) + righthandId) + "-") + color), "PANDA") | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | func countEggsNeededAmount (totalDucksAmount) = { | |
72 | + | let n = totalDucksAmount | |
73 | + | let g = discountCoefficient | |
74 | + | let t = typesAmount | |
75 | + | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
76 | + | (price * 1000000) | |
77 | + | } | |
46 | 78 | ||
47 | 79 | ||
48 | 80 | @Callable(i) | |
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)] | |
81 | + | func startPandaAdoption () = { | |
82 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
83 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
84 | + | let firstPayment = value(i.payments[0]) | |
85 | + | 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))] | |
86 | + | if ((firstPayment.assetId != eggsAssetId)) | |
87 | + | then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId))) | |
88 | + | else if ((eggsNeeded > firstPayment.amount)) | |
89 | + | then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded))) | |
90 | + | else (results ++ [ScriptTransfer(Address(collectorAddress), (firstPayment.amount - eggsNeeded), eggsAssetId)]) | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | @Callable(i) | |
96 | + | func finishPandaAdoption (txIdStr) = { | |
97 | + | let txId = fromBase58String(txIdStr) | |
98 | + | let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId) | |
99 | + | let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId) | |
100 | + | let duckIdKey = getDuckIdKey(toString(i.caller), txId) | |
101 | + | let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) { | |
102 | + | case t: Boolean => | |
103 | + | t | |
104 | + | case _ => | |
105 | + | false | |
106 | + | } | |
107 | + | let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey) | |
108 | + | let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey) | |
109 | + | if ((AdoptionTxStatus == AdoptionFinished)) | |
110 | + | then { | |
111 | + | let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId)) | |
112 | + | throw(("The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
113 | + | } | |
114 | + | else if ((AdoptionFinishHeight > height)) | |
115 | + | then throw((((("Adoption is not finished yet " + toString((AdoptionFinishHeight - height))) + " blocks remaining, it will take around ") + toString((AdoptionFinishHeight - height))) + " minutes")) | |
116 | + | else { | |
117 | + | let nameData = getRandomName(txId, AdoptionFinishHeight) | |
118 | + | let duckGen = nameData._1 | |
119 | + | let farmGen = nameData._2 | |
120 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
121 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight) | |
122 | + | let assetId = calculateAssetId(asset) | |
123 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
124 | + | [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(Address(collectorAddress), 1, assetId)] | |
125 | + | } | |
61 | 126 | } | |
62 | 127 | ||
63 | 128 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let eggsAssetId = base58'2cf6jyVG19oHU79R8iHfqFEesjstr3e7nSYEUhb2WagB' | |
5 | 5 | ||
6 | 6 | let collectorAddress = base58'3MpADDQFqadaCADNH9JDMQAGw9WEaMcymVU' | |
7 | 7 | ||
8 | - | let | |
8 | + | let delayForAdoption = 2 | |
9 | 9 | ||
10 | - | let | |
10 | + | let discountCoefficient = 10 | |
11 | 11 | ||
12 | - | let | |
12 | + | let typesAmount = 9 | |
13 | 13 | ||
14 | - | let | |
14 | + | let RefererReward = 5 | |
15 | 15 | ||
16 | - | let tokenDecimals = 8 | |
16 | + | let AdoptionStarted = "ADOPTION_STARTED" | |
17 | + | ||
18 | + | let AdoptionFinished = "ADOPTION_FINISHED" | |
19 | + | ||
20 | + | func getAdoptionStatusKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_status") | |
21 | + | ||
22 | + | ||
23 | + | func getAdoptionFinishHeightKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_fh") | |
24 | + | ||
25 | + | ||
26 | + | func getDuckIdKey (address,txId) = (((address + "_") + toBase58String(txId)) + "_di") | |
27 | + | ||
28 | + | ||
29 | + | func getDuckStatsKey (genString) = (("stats_" + genString) + "_amount") | |
30 | + | ||
17 | 31 | ||
18 | 32 | func tryGetInteger (key) = { | |
19 | 33 | let val = match getInteger(this, key) { | |
20 | 34 | case b: Int => | |
21 | 35 | b | |
22 | 36 | case _ => | |
23 | 37 | 0 | |
24 | 38 | } | |
25 | 39 | val | |
26 | 40 | } | |
27 | 41 | ||
28 | 42 | ||
29 | - | func tryGetString (key) = { | |
30 | - | let val = match getString(this, key) { | |
31 | - | case b: String => | |
32 | - | b | |
33 | - | case _ => | |
34 | - | "" | |
35 | - | } | |
36 | - | val | |
43 | + | func getRandomNumber (variants,txId,AdoptionFinishHeight,offset) = { | |
44 | + | let randomSeedBlock = value(blockInfoByHeight((AdoptionFinishHeight - 1))) | |
45 | + | let randomHash = sha256((txId + value(randomSeedBlock.vrf))) | |
46 | + | (toInt(randomHash, (offset * 8)) % variants) | |
37 | 47 | } | |
38 | 48 | ||
39 | 49 | ||
40 | - | func tryGetBoolean (key) = match getBoolean(this, key) { | |
41 | - | case b: Boolean => | |
42 | - | b | |
43 | - | case _ => | |
44 | - | false | |
45 | - | } | |
50 | + | func wasUniqueBorn (gen) = tryGetInteger(getDuckStatsKey(gen)) | |
51 | + | ||
52 | + | ||
53 | + | func getRandomName (txId,AdoptionFinishHeight) = { | |
54 | + | let hatId = toString(getRandomNumber(6, txId, AdoptionFinishHeight, 0)) | |
55 | + | let eyeglassId = toString(getRandomNumber(5, txId, AdoptionFinishHeight, 0)) | |
56 | + | let chainId = toString(getRandomNumber(3, txId, AdoptionFinishHeight, 0)) | |
57 | + | let lefthandId = toString(getRandomNumber(43, txId, AdoptionFinishHeight, 0)) | |
58 | + | let righthandId = toString(getRandomNumber(34, txId, AdoptionFinishHeight, 0)) | |
59 | + | let colorRandom = getRandomNumber(4, txId, AdoptionFinishHeight, 1) | |
60 | + | let color = if ((colorRandom == 0)) | |
61 | + | then "R" | |
62 | + | else if ((colorRandom == 1)) | |
63 | + | then "G" | |
64 | + | else if ((colorRandom == 2)) | |
65 | + | then "B" | |
66 | + | else "Y" | |
67 | + | $Tuple2(((((((("PANDA-" + hatId) + eyeglassId) + chainId) + lefthandId) + righthandId) + "-") + color), "PANDA") | |
68 | + | } | |
69 | + | ||
70 | + | ||
71 | + | func countEggsNeededAmount (totalDucksAmount) = { | |
72 | + | let n = totalDucksAmount | |
73 | + | let g = discountCoefficient | |
74 | + | let t = typesAmount | |
75 | + | let price = pow((100 + ((n * g) / (10 * t))), 2, 5, 1, 2, DOWN) | |
76 | + | (price * 1000000) | |
77 | + | } | |
46 | 78 | ||
47 | 79 | ||
48 | 80 | @Callable(i) | |
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)] | |
81 | + | func startPandaAdoption () = { | |
82 | + | let totalDucksAmount = tryGetInteger("ducks_amount") | |
83 | + | let eggsNeeded = countEggsNeededAmount(totalDucksAmount) | |
84 | + | let firstPayment = value(i.payments[0]) | |
85 | + | 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))] | |
86 | + | if ((firstPayment.assetId != eggsAssetId)) | |
87 | + | then throw(("You can attach only EGG tokens with the following asset id: " + toBase58String(eggsAssetId))) | |
88 | + | else if ((eggsNeeded > firstPayment.amount)) | |
89 | + | then throw(("To hatch a duck you currently need the following amount of EGGlets: " + toString(eggsNeeded))) | |
90 | + | else (results ++ [ScriptTransfer(Address(collectorAddress), (firstPayment.amount - eggsNeeded), eggsAssetId)]) | |
91 | + | } | |
92 | + | ||
93 | + | ||
94 | + | ||
95 | + | @Callable(i) | |
96 | + | func finishPandaAdoption (txIdStr) = { | |
97 | + | let txId = fromBase58String(txIdStr) | |
98 | + | let AdoptionStatusKey = getAdoptionStatusKey(toString(i.caller), txId) | |
99 | + | let finishHeightKey = getAdoptionFinishHeightKey(toString(i.caller), txId) | |
100 | + | let duckIdKey = getDuckIdKey(toString(i.caller), txId) | |
101 | + | let duckFromBaby = match getBoolean((("Adoption_" + txIdStr) + "_babyDuck")) { | |
102 | + | case t: Boolean => | |
103 | + | t | |
104 | + | case _ => | |
105 | + | false | |
106 | + | } | |
107 | + | let AdoptionTxStatus = getStringValue(this, AdoptionStatusKey) | |
108 | + | let AdoptionFinishHeight = getIntegerValue(this, finishHeightKey) | |
109 | + | if ((AdoptionTxStatus == AdoptionFinished)) | |
110 | + | then { | |
111 | + | let duckId = getStringValue(this, getDuckIdKey(toString(i.caller), txId)) | |
112 | + | throw(("The duck was hatched and claimed already, here is the folowing: " + duckId)) | |
113 | + | } | |
114 | + | else if ((AdoptionFinishHeight > height)) | |
115 | + | then throw((((("Adoption is not finished yet " + toString((AdoptionFinishHeight - height))) + " blocks remaining, it will take around ") + toString((AdoptionFinishHeight - height))) + " minutes")) | |
116 | + | else { | |
117 | + | let nameData = getRandomName(txId, AdoptionFinishHeight) | |
118 | + | let duckGen = nameData._1 | |
119 | + | let farmGen = nameData._2 | |
120 | + | let description = (("{\"genotype\": \"" + duckGen) + "\", \"crossbreeding\": true}") | |
121 | + | let asset = Issue(duckGen, description, 1, 0, false, unit, AdoptionFinishHeight) | |
122 | + | let assetId = calculateAssetId(asset) | |
123 | + | let amount = (tryGetInteger(getDuckStatsKey(duckGen)) + 1) | |
124 | + | [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(Address(collectorAddress), 1, assetId)] | |
125 | + | } | |
61 | 126 | } | |
62 | 127 | ||
63 | 128 | ||
64 | 129 | @Verifier(tx) | |
65 | 130 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
66 | 131 |
github/deemru/w8io/169f3d6 45.06 ms ◑