tx · 3X47SC5puiDbDG9fY1MKzSrqJwhB5pd9h61SfSfxpsPK 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV: -0.05000000 Waves 2024.10.24 19:20 [3341143] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves
{ "type": 13, "id": "3X47SC5puiDbDG9fY1MKzSrqJwhB5pd9h61SfSfxpsPK", "fee": 5000000, "feeAssetId": null, "timestamp": 1729786826032, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "49Ss9DoqWHvquLh99ePWDqFJQJByU9BzXYVzvSYzhjYHXdfFeFVuJA7mrEjsgKWxFHHLNLTd6pLN9XMRiLCPfJn5" ], "script": "base64:BgIbCAISBAoCCAgSBQoDCAgIEgQKAggIEgQKAggIDAARQUlfVE9LRU5fQVNTRVRfSUQBIJPhcjhxBJtq6JpjHwQkt2RTlyw+vGYLg3SvaLskjeJCAAtTVEFUVVNfT1BFTgIEb3BlbgASU1RBVFVTX0NIRUNLRURfT1VUAgtjaGVja2VkX291dAALU1RBVFVTX0RPTkUCBGRvbmUADkNIRUNLRURfT1VUX0JZAhBfY2hlY2tlZF9vdXRfYnlfABNTSU1QTEVfQ0hBVEdQVF9UQVNLAhNzaW1wbGVfQ2hhdEdQVF90YXNrABBDSEVDS19PVVRfSEVJR0hUAhJfY2hlY2tfb3V0X2hlaWdodF8AD1JFR0lTVEVSX0hFSUdIVAIRX3JlZ2lzdGVyX2hlaWdodF8ADUNPTU1JVF9IRUlHSFQCD19jb21taXRfaGVpZ2h0XwEPY2FuQmVDaGVja2VkT3V0AgZ0YXNrSWQEdHlwZQQGc3RhdHVzCQCdCAIFBHRoaXMJAKwCAgkArAICBQZ0YXNrSWQCCF9zdGF0dXNfBQR0eXBlCQAAAgUGc3RhdHVzBQtTVEFUV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lIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgkArAICBQZ0YXNrSWQCCF9zdGF0dXNfBQR0eXBlBQtTVEFUVVNfRE9ORQkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIJAKwCAgUGdGFza0lkAghfcmVzdWx0XwUEdHlwZQUIcmVzcG9uc2UJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgkArAICBQZ0YXNrSWQFDUNPTU1JVF9IRUlHSFQFBHR5cGUFBmhlaWdodAkAzAgCCQEMSW50ZWdlckVudHJ5AgkArAICCQCsAgIFBnRhc2tJZAISX2NvbW1pdF90aW1lc3RhbXBfBQR0eXBlBQl0aW1lc3RhbXAJAMwIAgkBC0RlbGV0ZUVudHJ5AQkArAICCQCsAgIJAKwCAgkArAICCQCsAgICD2NoZWNrZWRfb3V0X2J5XwUPY2FsbGVyUHVibGljS2V5AgFfBQR0eXBlAgFfBQZ0YXNrSWQFA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkmP4uL", "height": 3341143, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7PBVLoRMtRvSYqkXhfYG1u7KXimWbnLQQ2r8FtkekWjP Next: DwHkFLxNsAVbSrHcoLTHD2XBxAJnuVUaeVi8iiL3kvA1 Diff:
Old | New | Differences | |
---|---|---|---|
70 | 70 | else if ((minFee == -1)) | |
71 | 71 | then throw("Task type not supported!") | |
72 | 72 | else if ((minFee > fee)) | |
73 | - | then throw((("Payment needs to be at least " + toString(minFee)) + " | |
73 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " BAI Token!")) | |
74 | 74 | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), IntegerEntry("dao_sum", daoSum), IntegerEntry(("dao_user_" + callerPublicKey), daoUserValue)] | |
75 | 75 | } | |
76 | 76 | } | |
97 | 97 | else if ((minFee == -1)) | |
98 | 98 | then throw("Task type not supported!") | |
99 | 99 | else if ((minFee > fee)) | |
100 | - | then throw((("Payment needs to be at least " + toString(minFee)) + " | |
101 | - | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_callback_") + type), callback), StringEntry(((taskId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), StringEntry(((("callback_accounting_" + txId) + "_") + toString(height)), taskId)] | |
100 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " BAI Token!")) | |
101 | + | else $Tuple2([StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_callback_") + type), callback), StringEntry(((taskId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), StringEntry(((("callback_accounting_" + txId) + "_") + toString(height)), taskId)], taskId) | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 | ||
145 | 145 | then throw("Can not identify type of task id") | |
146 | 146 | else if ((callback != "no callback")) | |
147 | 147 | then { | |
148 | - | let result = invoke(Address(fromBase58String(caller)), callback, [response], nil) | |
148 | + | let result = invoke(Address(fromBase58String(caller)), callback, [taskId, response], nil) | |
149 | 149 | if ((result == result)) | |
150 | 150 | then [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
151 | 151 | else throw("Strict value is not equal to itself.") | |
152 | 152 | } | |
153 | 153 | else [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
154 | - | } | |
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | @Callable(i) | |
159 | - | func buy () = { | |
160 | - | let WAVES_USDT_ORACLE = addressFromStringValue("3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy") | |
161 | - | let WAVES_USDT_ORACLE_KEY = "%s%s__price__WAVES-USDT" | |
162 | - | let USDT_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
163 | - | let USDC_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
164 | - | let BAI_ASSET_ID = "AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1" | |
165 | - | let numberOfPayments = size(i.payments) | |
166 | - | if ((numberOfPayments != 1)) | |
167 | - | then throw("Payment necessary!") | |
168 | - | else { | |
169 | - | let payment = i.payments[0] | |
170 | - | let feeAssetId = payment.assetId | |
171 | - | let feeAssetIdString = match feeAssetId { | |
172 | - | case b: ByteVector => | |
173 | - | toBase58String(b) | |
174 | - | case _ => | |
175 | - | "" | |
176 | - | } | |
177 | - | let paymentAmount = payment.amount | |
178 | - | let amount = if (!(isDefined(feeAssetId))) | |
179 | - | then { | |
180 | - | let wavesUsdtPrice = match getInteger(WAVES_USDT_ORACLE, WAVES_USDT_ORACLE_KEY) { | |
181 | - | case n: Int => | |
182 | - | n | |
183 | - | case _ => | |
184 | - | 0 | |
185 | - | } | |
186 | - | (fraction(paymentAmount, wavesUsdtPrice, 100000000) * 100) | |
187 | - | } | |
188 | - | else if ((feeAssetIdString == USDT_ASSET_ID)) | |
189 | - | then (paymentAmount * 100) | |
190 | - | else if ((feeAssetIdString == USDC_ASSET_ID)) | |
191 | - | then (paymentAmount * 100) | |
192 | - | else throw("payment necessary in Waves, USDC or USDT!") | |
193 | - | [ScriptTransfer(i.caller, amount, fromBase58String(BAI_ASSET_ID))] | |
194 | - | } | |
195 | 154 | } | |
196 | 155 | ||
197 | 156 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let AI_TOKEN_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
5 | 5 | ||
6 | 6 | let STATUS_OPEN = "open" | |
7 | 7 | ||
8 | 8 | let STATUS_CHECKED_OUT = "checked_out" | |
9 | 9 | ||
10 | 10 | let STATUS_DONE = "done" | |
11 | 11 | ||
12 | 12 | let CHECKED_OUT_BY = "_checked_out_by_" | |
13 | 13 | ||
14 | 14 | let SIMPLE_CHATGPT_TASK = "simple_ChatGPT_task" | |
15 | 15 | ||
16 | 16 | let CHECK_OUT_HEIGHT = "_check_out_height_" | |
17 | 17 | ||
18 | 18 | let REGISTER_HEIGHT = "_register_height_" | |
19 | 19 | ||
20 | 20 | let COMMIT_HEIGHT = "_commit_height_" | |
21 | 21 | ||
22 | 22 | func canBeCheckedOut (taskId,type) = { | |
23 | 23 | let status = getString(this, ((taskId + "_status_") + type)) | |
24 | 24 | (status == STATUS_OPEN) | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func isCorrectAgent (taskId,agentId,type) = { | |
29 | 29 | let checkoutAgentId = getString(this, ((taskId + CHECKED_OUT_BY) + type)) | |
30 | 30 | (checkoutAgentId == agentId) | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getPriceForType (type) = match getInteger(this, ("price_" + type)) { | |
35 | 35 | case i: Int => | |
36 | 36 | i | |
37 | 37 | case _ => | |
38 | 38 | -1 | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | @Callable(i) | |
43 | 43 | func registerTask (description,type) = { | |
44 | 44 | let numberOfPayments = size(i.payments) | |
45 | 45 | if ((numberOfPayments != 1)) | |
46 | 46 | then throw("Payment necessary!") | |
47 | 47 | else { | |
48 | 48 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
49 | 49 | let txId = toBase58String(i.transactionId) | |
50 | 50 | let payment = i.payments[0] | |
51 | 51 | let fee = payment.amount | |
52 | 52 | let feeAssetId = payment.assetId | |
53 | 53 | let taskId = ((txId + "_") + callerPublicKey) | |
54 | 54 | let timestamp = lastBlock.timestamp | |
55 | 55 | let minFee = getPriceForType(type) | |
56 | 56 | let daoUserValue = match getInteger(this, ("dao_user_" + callerPublicKey)) { | |
57 | 57 | case n: Int => | |
58 | 58 | (n + fee) | |
59 | 59 | case _ => | |
60 | 60 | fee | |
61 | 61 | } | |
62 | 62 | let daoSum = match getInteger(this, "dao_sum") { | |
63 | 63 | case n: Int => | |
64 | 64 | (n + fee) | |
65 | 65 | case _ => | |
66 | 66 | fee | |
67 | 67 | } | |
68 | 68 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
69 | 69 | then throw("Payment only possible in the AI Token!") | |
70 | 70 | else if ((minFee == -1)) | |
71 | 71 | then throw("Task type not supported!") | |
72 | 72 | else if ((minFee > fee)) | |
73 | - | then throw((("Payment needs to be at least " + toString(minFee)) + " | |
73 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " BAI Token!")) | |
74 | 74 | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), IntegerEntry("dao_sum", daoSum), IntegerEntry(("dao_user_" + callerPublicKey), daoUserValue)] | |
75 | 75 | } | |
76 | 76 | } | |
77 | 77 | ||
78 | 78 | ||
79 | 79 | ||
80 | 80 | @Callable(i) | |
81 | 81 | func registerTaskCallback (description,type,callback) = { | |
82 | 82 | let numberOfPayments = size(i.payments) | |
83 | 83 | if ((numberOfPayments != 1)) | |
84 | 84 | then throw("Payment necessary!") | |
85 | 85 | else { | |
86 | 86 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
87 | 87 | let caller = toString(i.caller) | |
88 | 88 | let txId = toBase58String(i.transactionId) | |
89 | 89 | let payment = i.payments[0] | |
90 | 90 | let fee = payment.amount | |
91 | 91 | let feeAssetId = payment.assetId | |
92 | 92 | let taskId = ((txId + "_") + callerPublicKey) | |
93 | 93 | let timestamp = lastBlock.timestamp | |
94 | 94 | let minFee = getPriceForType(type) | |
95 | 95 | if ((feeAssetId != AI_TOKEN_ASSET_ID)) | |
96 | 96 | then throw("Payment only possible in the AI Token!") | |
97 | 97 | else if ((minFee == -1)) | |
98 | 98 | then throw("Task type not supported!") | |
99 | 99 | else if ((minFee > fee)) | |
100 | - | then throw((("Payment needs to be at least " + toString(minFee)) + " | |
101 | - | else [StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_callback_") + type), callback), StringEntry(((taskId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), StringEntry(((("callback_accounting_" + txId) + "_") + toString(height)), taskId)] | |
100 | + | then throw((("Payment needs to be at least " + toString(minFee)) + " BAI Token!")) | |
101 | + | else $Tuple2([StringEntry(((taskId + "_description_") + type), description), StringEntry(((txId + "_initializer_") + type), callerPublicKey), StringEntry(((taskId + "_callback_") + type), callback), StringEntry(((taskId + "_caller_") + type), caller), StringEntry(((taskId + "_status_") + type), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry(((taskId + REGISTER_HEIGHT) + type), height), IntegerEntry(((taskId + "_register_timestamp_") + type), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true), StringEntry(((("callback_accounting_" + txId) + "_") + toString(height)), taskId)], taskId) | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 | ||
106 | 106 | ||
107 | 107 | @Callable(i) | |
108 | 108 | func checkoutTask (taskId,type) = { | |
109 | 109 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
110 | 110 | let taskStillOpen = canBeCheckedOut(taskId, type) | |
111 | 111 | let timestamp = lastBlock.timestamp | |
112 | 112 | if (!(taskStillOpen)) | |
113 | 113 | then throw("Task not open for checkout!") | |
114 | 114 | else [StringEntry(((taskId + CHECKED_OUT_BY) + type), callerPublicKey), StringEntry(((taskId + "_status_") + type), STATUS_CHECKED_OUT), IntegerEntry(((taskId + CHECK_OUT_HEIGHT) + type), height), IntegerEntry(((taskId + "_check_out_timestamp_") + type), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))] | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | 119 | @Callable(i) | |
120 | 120 | func commitTask (taskId,response) = { | |
121 | 121 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
122 | 122 | let type = match getString((taskId + "_type")) { | |
123 | 123 | case s: String => | |
124 | 124 | s | |
125 | 125 | case _ => | |
126 | 126 | "not set" | |
127 | 127 | } | |
128 | 128 | let correctAgent = isCorrectAgent(taskId, callerPublicKey, type) | |
129 | 129 | let timestamp = lastBlock.timestamp | |
130 | 130 | let callback = match getString(((taskId + "_callback_") + type)) { | |
131 | 131 | case s: String => | |
132 | 132 | s | |
133 | 133 | case _ => | |
134 | 134 | "no callback" | |
135 | 135 | } | |
136 | 136 | let caller = match getString(((taskId + "_caller_") + type)) { | |
137 | 137 | case s: String => | |
138 | 138 | s | |
139 | 139 | case _ => | |
140 | 140 | "no callback" | |
141 | 141 | } | |
142 | 142 | if (!(correctAgent)) | |
143 | 143 | then throw("Task may only be submitted by the agent who checked the task out!") | |
144 | 144 | else if ((type == "not set")) | |
145 | 145 | then throw("Can not identify type of task id") | |
146 | 146 | else if ((callback != "no callback")) | |
147 | 147 | then { | |
148 | - | let result = invoke(Address(fromBase58String(caller)), callback, [response], nil) | |
148 | + | let result = invoke(Address(fromBase58String(caller)), callback, [taskId, response], nil) | |
149 | 149 | if ((result == result)) | |
150 | 150 | then [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
151 | 151 | else throw("Strict value is not equal to itself.") | |
152 | 152 | } | |
153 | 153 | else [StringEntry(((taskId + "_status_") + type), STATUS_DONE), StringEntry(((taskId + "_result_") + type), response), IntegerEntry(((taskId + COMMIT_HEIGHT) + type), height), IntegerEntry(((taskId + "_commit_timestamp_") + type), timestamp), DeleteEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId))] | |
154 | - | } | |
155 | - | ||
156 | - | ||
157 | - | ||
158 | - | @Callable(i) | |
159 | - | func buy () = { | |
160 | - | let WAVES_USDT_ORACLE = addressFromStringValue("3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy") | |
161 | - | let WAVES_USDT_ORACLE_KEY = "%s%s__price__WAVES-USDT" | |
162 | - | let USDT_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
163 | - | let USDC_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum" | |
164 | - | let BAI_ASSET_ID = "AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1" | |
165 | - | let numberOfPayments = size(i.payments) | |
166 | - | if ((numberOfPayments != 1)) | |
167 | - | then throw("Payment necessary!") | |
168 | - | else { | |
169 | - | let payment = i.payments[0] | |
170 | - | let feeAssetId = payment.assetId | |
171 | - | let feeAssetIdString = match feeAssetId { | |
172 | - | case b: ByteVector => | |
173 | - | toBase58String(b) | |
174 | - | case _ => | |
175 | - | "" | |
176 | - | } | |
177 | - | let paymentAmount = payment.amount | |
178 | - | let amount = if (!(isDefined(feeAssetId))) | |
179 | - | then { | |
180 | - | let wavesUsdtPrice = match getInteger(WAVES_USDT_ORACLE, WAVES_USDT_ORACLE_KEY) { | |
181 | - | case n: Int => | |
182 | - | n | |
183 | - | case _ => | |
184 | - | 0 | |
185 | - | } | |
186 | - | (fraction(paymentAmount, wavesUsdtPrice, 100000000) * 100) | |
187 | - | } | |
188 | - | else if ((feeAssetIdString == USDT_ASSET_ID)) | |
189 | - | then (paymentAmount * 100) | |
190 | - | else if ((feeAssetIdString == USDC_ASSET_ID)) | |
191 | - | then (paymentAmount * 100) | |
192 | - | else throw("payment necessary in Waves, USDC or USDT!") | |
193 | - | [ScriptTransfer(i.caller, amount, fromBase58String(BAI_ASSET_ID))] | |
194 | - | } | |
195 | 154 | } | |
196 | 155 | ||
197 | 156 | ||
198 | 157 | @Verifier(tx) | |
199 | 158 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
200 | 159 |
github/deemru/w8io/026f985 59.71 ms ◑