tx · 3okdC1kQ5pDdK8ktWtAT27ALWyYaTMQgCn33JUiwtKEJ

3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV:  -0.05000000 Waves

2023.08.13 22:04 [2709186] smart account 3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV > SELF 0.00000000 Waves

{ "type": 13, "id": "3okdC1kQ5pDdK8ktWtAT27ALWyYaTMQgCn33JUiwtKEJ", "fee": 5000000, "feeAssetId": null, "timestamp": 1691953433896, "version": 2, "chainId": 84, "sender": "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV", "senderPublicKey": "DS6HkopS9zypvxX6VhkdNvv6v4wcPZuChRvTwKJeacxE", "proofs": [ "UJjoNarCerXKBsQLjSa21189ino7c5q1oB5gWPPUEAzDgVZLoiJcpdF8rZvoKprJfQRxKpSbvNTJcXcVGgYYvjd" ], "script": "base64:BgImCAISBAoCCAgSAwoBCBIECgIICBIDCgEIEgQKAggIEgQKAggIEgANABFBSV9UT0tFTl9BU1NFVF9JRAEgk+FyOHEEm2rommMfBCS3ZFOXLD68ZguDdK9ouySN4kIAC1NUQVRVU19PUEVOAgRvcGVuABJTVEFUVVNfQ0hFQ0tFRF9PVVQCC2NoZWNrZWRfb3V0AAtTVEFUVVNfRE9ORQIEZG9uZQAOQ0hFQ0tFRF9PVVRfQlkCD19jaGVja2VkX291dF9ieQATU0lNUExFX0NIQVRHUFRfVEFTSwITc2ltcGxlX0NoYXRHUFRfdGFzawAQQ0hFQ0tfT1VUX0hFSUdIVAIRX2NoZWNrX291dF9oZWlnaHQAD1JFR0lTVEVSX0hFSUdIVAIQX3JlZ2lzdGVyX2hlaWdodAANQ09NTUlUX0hFSUdIVAIOX2NvbW1pdF9oZWlnaHQBD2NhbkJlQ2hlY2tlZE91dAEGdGFza0lkBAZzdGF0dXMJAJ0IAgUEdGhpcwkArAICBQZ0YXNrSWQCB19zdGF0dXMJAAACBQZzdGF0dXMFC1NUQVRVU19PUEVOAQ5pc0N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KXBheW1lbnQgbmVjZXNzYXJ5IGluIFdhdmVzLCBVU0RDIG9yIFVTRFQhCQDMCAIJAQ5TY3JpcHRUcmFuc2ZlcgMIBQFpBmNhbGxlcgUGYW1vdW50CQDZBAEFDEJBSV9BU1NFVF9JRAUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleZNFXlU=", "height": 2709186, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6zuBE5c7nEWMMeSmtAfB2X5i6aveTFntARqmMKwA5qCf Next: FxKDSfbh8ZMbjRDi2uj4sggGSK9gezevV3MkhSBK8Syq Diff:
OldNewDifferences
111111 let timestamp = lastBlock.timestamp
112112 if (!(taskStillOpen))
113113 then throw("Task not open for checkout!")
114- else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(((("open_" + type) + "_") + taskId))]
114+ else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))]
115115 }
116116
117117
133133 let callerPublicKey = toBase58String(i.callerPublicKey)
134134 let correctAgent = isCorrectAgent(taskId, callerPublicKey)
135135 let timestamp = lastBlock.timestamp
136+ let type = match getString((taskId + "_type")) {
137+ case s: String =>
138+ s
139+ case _ =>
140+ "not set"
141+ }
136142 if (!(correctAgent))
137143 then throw("Task may only be submitted by the agent who checked the task out!")
138- else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)]
144+ else if ((type == "not set"))
145+ then throw("Can not identify type of task id")
146+ else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp), DeleteEntry(((((("checked_out_" + type) + "_") + taskId) + "_by_") + callerPublicKey))]
139147 }
140148
141149
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let AI_TOKEN_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1'
55
66 let STATUS_OPEN = "open"
77
88 let STATUS_CHECKED_OUT = "checked_out"
99
1010 let STATUS_DONE = "done"
1111
1212 let CHECKED_OUT_BY = "_checked_out_by"
1313
1414 let SIMPLE_CHATGPT_TASK = "simple_ChatGPT_task"
1515
1616 let CHECK_OUT_HEIGHT = "_check_out_height"
1717
1818 let REGISTER_HEIGHT = "_register_height"
1919
2020 let COMMIT_HEIGHT = "_commit_height"
2121
2222 func canBeCheckedOut (taskId) = {
2323 let status = getString(this, (taskId + "_status"))
2424 (status == STATUS_OPEN)
2525 }
2626
2727
2828 func isCorrectAgent (taskId,agentId) = {
2929 let checkoutAgentId = getString(this, (taskId + CHECKED_OUT_BY))
3030 (checkoutAgentId == agentId)
3131 }
3232
3333
3434 func getTaskId (txId) = {
3535 let callerPublicKey = match getString(this, (txId + "_initializer")) {
3636 case str: String =>
3737 str
3838 case _ =>
3939 ""
4040 }
4141 match getString(this, ((txId + "_") + callerPublicKey)) {
4242 case str: String =>
4343 str
4444 case _ =>
4545 ""
4646 }
4747 }
4848
4949
5050 func getPriceForType (type) = match getInteger(this, ("price_" + type)) {
5151 case i: Int =>
5252 i
5353 case _ =>
5454 -1
5555 }
5656
5757
5858 @Callable(i)
5959 func registerTask (description,type) = {
6060 let numberOfPayments = size(i.payments)
6161 if ((numberOfPayments != 1))
6262 then throw("Payment necessary!")
6363 else {
6464 let callerPublicKey = toBase58String(i.callerPublicKey)
6565 let txId = toBase58String(i.transactionId)
6666 let payment = i.payments[0]
6767 let fee = payment.amount
6868 let feeAssetId = payment.assetId
6969 let taskId = ((txId + "_") + callerPublicKey)
7070 let timestamp = lastBlock.timestamp
7171 let minFee = getPriceForType(type)
7272 if ((feeAssetId != AI_TOKEN_ASSET_ID))
7373 then throw("Payment only possible in the AI Token!")
7474 else if ((minFee == -1))
7575 then throw("Task type not supported!")
7676 else if ((minFee > fee))
7777 then throw((("Payment needs to be at least " + toString(minFee)) + " AI Token!"))
7878 else [StringEntry((taskId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((taskId + "_status"), STATUS_OPEN), StringEntry((taskId + "_type"), type), IntegerEntry((taskId + REGISTER_HEIGHT), height), IntegerEntry((taskId + "_register_timestamp"), timestamp), BooleanEntry(((("open_" + type) + "_") + taskId), true)]
7979 }
8080 }
8181
8282
8383
8484 @Callable(i)
8585 func registerChatGPTTask (description) = {
8686 let numberOfPayments = size(i.payments)
8787 if ((numberOfPayments != 1))
8888 then throw("Payment necessary!")
8989 else {
9090 let callerPublicKey = toBase58String(i.callerPublicKey)
9191 let txId = toBase58String(i.transactionId)
9292 let payment = i.payments[0]
9393 let fee = payment.amount
9494 let feeAssetId = payment.assetId
9595 let taskId = ((txId + "_") + callerPublicKey)
9696 let timestamp = lastBlock.timestamp
9797 if ((feeAssetId != AI_TOKEN_ASSET_ID))
9898 then throw("Payment only possible in the AI Token!")
9999 else if ((10000000 > fee))
100100 then throw("Payment needs to be at least 0.1 AI Token!")
101101 else [StringEntry((taskId + "_description"), description), StringEntry((txId + "_initializer"), callerPublicKey), StringEntry((taskId + "_status"), STATUS_OPEN), StringEntry((taskId + "_type"), SIMPLE_CHATGPT_TASK), IntegerEntry((taskId + REGISTER_HEIGHT), height), IntegerEntry((taskId + "_register_timestamp"), timestamp), BooleanEntry(("open_chatgpt_" + taskId), true)]
102102 }
103103 }
104104
105105
106106
107107 @Callable(i)
108108 func checkoutTask (taskId,type) = {
109109 let callerPublicKey = toBase58String(i.callerPublicKey)
110110 let taskStillOpen = canBeCheckedOut(taskId)
111111 let timestamp = lastBlock.timestamp
112112 if (!(taskStillOpen))
113113 then throw("Task not open for checkout!")
114- else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(((("open_" + type) + "_") + taskId))]
114+ else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), BooleanEntry(((((("checked_out_by_" + callerPublicKey) + "_") + type) + "_") + taskId), true), DeleteEntry(((("open_" + type) + "_") + taskId))]
115115 }
116116
117117
118118
119119 @Callable(i)
120120 func checkoutChatGPTTask (taskId) = {
121121 let callerPublicKey = toBase58String(i.callerPublicKey)
122122 let taskStillOpen = canBeCheckedOut(taskId)
123123 let timestamp = lastBlock.timestamp
124124 if (!(taskStillOpen))
125125 then throw("Task not open for checkout!")
126126 else [StringEntry((taskId + CHECKED_OUT_BY), callerPublicKey), StringEntry((taskId + "_status"), STATUS_CHECKED_OUT), IntegerEntry((taskId + CHECK_OUT_HEIGHT), height), IntegerEntry((taskId + "_check_out_timestamp"), timestamp), DeleteEntry(("open_chatgpt_" + taskId))]
127127 }
128128
129129
130130
131131 @Callable(i)
132132 func commitTask (taskId,response) = {
133133 let callerPublicKey = toBase58String(i.callerPublicKey)
134134 let correctAgent = isCorrectAgent(taskId, callerPublicKey)
135135 let timestamp = lastBlock.timestamp
136+ let type = match getString((taskId + "_type")) {
137+ case s: String =>
138+ s
139+ case _ =>
140+ "not set"
141+ }
136142 if (!(correctAgent))
137143 then throw("Task may only be submitted by the agent who checked the task out!")
138- else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)]
144+ else if ((type == "not set"))
145+ then throw("Can not identify type of task id")
146+ else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp), DeleteEntry(((((("checked_out_" + type) + "_") + taskId) + "_by_") + callerPublicKey))]
139147 }
140148
141149
142150
143151 @Callable(i)
144152 func commitChatGPTTask (taskId,response) = {
145153 let callerPublicKey = toBase58String(i.callerPublicKey)
146154 let correctAgent = isCorrectAgent(taskId, callerPublicKey)
147155 let timestamp = lastBlock.timestamp
148156 if (!(correctAgent))
149157 then throw("Task may only be submitted by the agent who checked the task out!")
150158 else [StringEntry((taskId + "_status"), STATUS_DONE), StringEntry((taskId + "_result"), response), IntegerEntry((taskId + COMMIT_HEIGHT), height), IntegerEntry((taskId + "_commit_timestamp"), timestamp)]
151159 }
152160
153161
154162
155163 @Callable(i)
156164 func buy () = {
157165 let WAVES_USDT_ORACLE = addressFromStringValue("3N1WjhmF3EyutvrvtsfsSLbhmiLU8Bc1Toy")
158166 let WAVES_USDT_ORACLE_KEY = "%s%s__price__WAVES-USDT"
159167 let USDT_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum"
160168 let USDC_ASSET_ID = "98D3pkKvfrXEnXmQqKGWgtoGvVh1aTf4CPDttqG9csum"
161169 let BAI_ASSET_ID = "AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1"
162170 let numberOfPayments = size(i.payments)
163171 if ((numberOfPayments != 1))
164172 then throw("Payment necessary!")
165173 else {
166174 let payment = i.payments[0]
167175 let feeAssetId = payment.assetId
168176 let feeAssetIdString = match feeAssetId {
169177 case b: ByteVector =>
170178 toBase58String(b)
171179 case _ =>
172180 ""
173181 }
174182 let paymentAmount = payment.amount
175183 let amount = if (!(isDefined(feeAssetId)))
176184 then {
177185 let wavesUsdtPrice = match getInteger(WAVES_USDT_ORACLE, WAVES_USDT_ORACLE_KEY) {
178186 case n: Int =>
179187 n
180188 case _ =>
181189 0
182190 }
183191 (fraction(paymentAmount, wavesUsdtPrice, 100000000) * 100)
184192 }
185193 else if ((feeAssetIdString == USDT_ASSET_ID))
186194 then (paymentAmount * 100)
187195 else if ((feeAssetIdString == USDC_ASSET_ID))
188196 then (paymentAmount * 100)
189197 else throw("payment necessary in Waves, USDC or USDT!")
190198 [ScriptTransfer(i.caller, amount, fromBase58String(BAI_ASSET_ID))]
191199 }
192200 }
193201
194202
195203 @Verifier(tx)
196204 func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)
197205

github/deemru/w8io/026f985 
41.08 ms