tx · FrzYyNDfE7qTFC7Kv3qv9McMVJNjoS7cs7U7CnhjCAf1 3NAoJSThEgz12iLrRFSeMZpP1mEYc4QcGa3: -0.01000000 Waves 2023.11.26 18:04 [2860523] smart account 3NAoJSThEgz12iLrRFSeMZpP1mEYc4QcGa3 > SELF 0.00000000 Waves
{ "type": 13, "id": "FrzYyNDfE7qTFC7Kv3qv9McMVJNjoS7cs7U7CnhjCAf1", "fee": 1000000, "feeAssetId": null, "timestamp": 1701011093672, "version": 2, "chainId": 84, "sender": "3NAoJSThEgz12iLrRFSeMZpP1mEYc4QcGa3", "senderPublicKey": "5TXMdPyvDNfxhdixe86fk7Ya8FScpZGfZ6XNawu8sYK4", "proofs": [ "3kzSgjAQUC6RqMbQbUFgxLgx1toPz3zP2z85hvBfFw8jAWto3uWiTXU2PRwmFrWDh1b7MdfeD5KZnjzHnuF2aor3" ], "script": "base64:BgIfCAISBwoFEREICAESAwoBCBIGCgQICAgIEgUKAwgBCAQAC0JBSV9BRERSRVNTAiMzTjl0S2l4enFUWVduRVhReHJEUTVwQlRHdlFkNnNGc3ZtVgARQUlfVE9LRU5fQVNTRVRfSUQBIJPhcjhxBJtq6JpjHwQkt2RTlyw+vGYLg3SvaLskjeJCAQtyZW1vdmVNYXJrcwELbWFya3NTdHJpbmcEAWEJALACAgULbWFya3NTdHJpbmcAAQQBYgkAswICBQFhAAEFAWIBCXBhcnNlSnNvbgEEanNvbgQMbW9kaWZpZWRKc29uCQCwAgIFBGpzb24AAQQNbW9kaWZpZWRKc29uMgkAswICBQxtb2RpZmllZEpzb24AAQQGc3BsaXQxCQC1CQIFDW1vZGlmaWVkSnNvbjICASwECWtleVZhbHVlMQkAtQkCCQCRAwIFBnNwbGl0MQAAAgE6BARrZXkxCQELcmVtb3ZlTWFya3MBCQCRAwIFCWtleVZhbHVlMQAABAZ2YWx1ZTEJAQtyZW1vdmVNYXJrcwEJAJEDAgUJa2V5VmFsdWUxAAEECWtleVZhbHVlMgkAtQkCCQCRAwI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BlcnNvbl9hZGRyZXNzBAR0eElkCQDYBAEIBQFpDXRyYW5zYWN0aW9uSWQJAMwIAgkBC1N0cmluZ0VudHJ5AgUNcHJlZGljdGlvbl9pZAUEdHhJZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFBHR4SWQCB19ndWlsdHkFFWd1aWx0eV9wZXJzb25fYWRkcmVzcwUDbmlsAWkBDXJlcXVlc3RQYXlvdXQDCXByZWRfdHhJZAZhbW91bnQCaWQEBmNsaWVudAkApQgBCAUBaQZjYWxsZXIEBHR4SWQJANgEAQgFAWkNdHJhbnNhY3Rpb25JZAkAzAgCCQELU3RyaW5nRW50cnkCCQCsAgIFAmlkAg9fcmVxdWVzdF9wYXlvdXQFBHR4SWQJAMwIAgkBDEludGVnZXJFbnRyeQIJAKwCAgUEdHhJZAIHX2Ftb3VudAUGYW1vdW50CQDMCAIJAQtTdHJpbmdFbnRyeQIJAKwCAgUEdHhJZAIOX3ByZWRpY3Rpb25faWQFCXByZWRfdHhJZAUDbmlsAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleVnde6c=", "height": 2860523, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CaKWhUsAsyTQLa8YrkUgsChEhwu7ScwE8rxY3xj1ttaN Next: BkVWUdsQ7JYxnNSBQC4rv1kZgMWPBgGeXmi2d41GYYvo Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let BAI_ADDRESS = "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV" | |
5 | 5 | ||
6 | 6 | let AI_TOKEN_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
7 | + | ||
8 | + | func removeMarks (marksString) = { | |
9 | + | let a = drop(marksString, 1) | |
10 | + | let b = dropRight(a, 1) | |
11 | + | b | |
12 | + | } | |
13 | + | ||
14 | + | ||
15 | + | func parseJson (json) = { | |
16 | + | let modifiedJson = drop(json, 1) | |
17 | + | let modifiedJson2 = dropRight(modifiedJson, 1) | |
18 | + | let split1 = split(modifiedJson2, ",") | |
19 | + | let keyValue1 = split(split1[0], ":") | |
20 | + | let key1 = removeMarks(keyValue1[0]) | |
21 | + | let value1 = removeMarks(keyValue1[1]) | |
22 | + | let keyValue2 = split(split1[1], ":") | |
23 | + | let key2 = removeMarks(keyValue2[0]) | |
24 | + | let value2 = removeMarks(keyValue2[1]) | |
25 | + | let keyValue3 = split(split1[2], ":") | |
26 | + | let key3 = removeMarks(keyValue2[0]) | |
27 | + | let value3 = removeMarks(keyValue2[1]) | |
28 | + | $Tuple3([key1, value1], [key2, value2], [key3, value3]) | |
29 | + | } | |
30 | + | ||
7 | 31 | ||
8 | 32 | @Callable(i) | |
9 | 33 | func registerData (clientInput,opponentInput,id,oppAddress,lgtCond) = { | |
18 | 42 | else { | |
19 | 43 | let client = toString(i.caller) | |
20 | 44 | let txId = toBase58String(i.transactionId) | |
21 | - | [StringEntry(id, txId), IntegerEntry((((txId + "_") + client) + "_age"), clientInput[0]), IntegerEntry((((txId + "_") + client) + "_sex"), clientInput[1]), IntegerEntry((((txId + "_") + client) + "_damage"), clientInput[2]), IntegerEntry((((txId + "_") + client) + "_fac1"), clientInput[3]), IntegerEntry((((txId + "_") + client) + "_fac2"), clientInput[4]), IntegerEntry((((txId + "_") + client) + "_fac3"), clientInput[5]), IntegerEntry((((txId + "_") + client) + "_fac4"), clientInput[6]), IntegerEntry((((txId + "_") + client) + "_vio1"), clientInput[7]), IntegerEntry((((txId + "_") + client) + "_vio2"), clientInput[8]), IntegerEntry((((txId + "_") + client) + "_vio3"), clientInput[9]), IntegerEntry((((txId + "_") + client) + "_vio4"), clientInput[10]), IntegerEntry((((txId + "_") + client) + "_cost"), clientInput[11]), IntegerEntry((((txId + "_") + oppAddress) + "_age"), opponentInput[0]), IntegerEntry((((txId + "_") + oppAddress) + "_sex"), opponentInput[1]), IntegerEntry((((txId + "_") + oppAddress) + "_damage"), opponentInput[2]), IntegerEntry((((txId + "_") + oppAddress) + "_fac1"), opponentInput[3]), IntegerEntry((((txId + "_") + oppAddress) + "_fac2"), opponentInput[4]), IntegerEntry((((txId + "_") + oppAddress) + "_fac3"), opponentInput[5]), IntegerEntry((((txId + "_") + oppAddress) + "_fac4"), opponentInput[6]), IntegerEntry((((txId + "_") + oppAddress) + "_vio1"), opponentInput[7]), IntegerEntry((((txId + "_") + oppAddress) + "_vio2"), opponentInput[8]), IntegerEntry((((txId + "_") + oppAddress) + "_vio3"), opponentInput[9]), IntegerEntry((((txId + "_") + oppAddress) + "_vio4"), opponentInput[10]), IntegerEntry((((txId + "_") + oppAddress) + "_cost"), opponentInput[11]), IntegerEntry((txId + "_lgt"), lgtCond)] | |
45 | + | [StringEntry(id, txId), IntegerEntry((((txId + "_") + client) + "_age"), clientInput[0]), IntegerEntry((((txId + "_") + client) + "_sex"), clientInput[1]), IntegerEntry((((txId + "_") + client) + "_damage"), clientInput[2]), IntegerEntry((((txId + "_") + client) + "_fac1"), clientInput[3]), IntegerEntry((((txId + "_") + client) + "_fac2"), clientInput[4]), IntegerEntry((((txId + "_") + client) + "_fac3"), clientInput[5]), IntegerEntry((((txId + "_") + client) + "_fac4"), clientInput[6]), IntegerEntry((((txId + "_") + client) + "_vio1"), clientInput[7]), IntegerEntry((((txId + "_") + client) + "_vio2"), clientInput[8]), IntegerEntry((((txId + "_") + client) + "_vio3"), clientInput[9]), IntegerEntry((((txId + "_") + client) + "_vio4"), clientInput[10]), IntegerEntry((((txId + "_") + client) + "_cost"), clientInput[11]), IntegerEntry((((txId + "_") + oppAddress) + "_age"), opponentInput[0]), IntegerEntry((((txId + "_") + oppAddress) + "_sex"), opponentInput[1]), IntegerEntry((((txId + "_") + oppAddress) + "_damage"), opponentInput[2]), IntegerEntry((((txId + "_") + oppAddress) + "_fac1"), opponentInput[3]), IntegerEntry((((txId + "_") + oppAddress) + "_fac2"), opponentInput[4]), IntegerEntry((((txId + "_") + oppAddress) + "_fac3"), opponentInput[5]), IntegerEntry((((txId + "_") + oppAddress) + "_fac4"), opponentInput[6]), IntegerEntry((((txId + "_") + oppAddress) + "_vio1"), opponentInput[7]), IntegerEntry((((txId + "_") + oppAddress) + "_vio2"), opponentInput[8]), IntegerEntry((((txId + "_") + oppAddress) + "_vio3"), opponentInput[9]), IntegerEntry((((txId + "_") + oppAddress) + "_vio4"), opponentInput[10]), IntegerEntry((((txId + "_") + oppAddress) + "_cost"), opponentInput[11]), IntegerEntry((id + "_lgt"), lgtCond), StringEntry((id + "_status"), "open")] | |
46 | + | } | |
47 | + | } | |
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | @Callable(i) | |
52 | + | func evaluatedDataCallback (response) = { | |
53 | + | let txId = toBase58String(i.transactionId) | |
54 | + | let parsedJson = parseJson(response) | |
55 | + | let crashId = parsedJson._1[1] | |
56 | + | let innocentAddress = parsedJson._2[1] | |
57 | + | let guiltyAddress = parsedJson._3[1] | |
58 | + | let RegisterTxId = match getString(crashId) { | |
59 | + | case s: String => | |
60 | + | s | |
61 | + | case _ => | |
62 | + | "no Data exists" | |
63 | + | } | |
64 | + | if ((RegisterTxId == "no Data exists")) | |
65 | + | then throw("There is no Data for this crashId!") | |
66 | + | else { | |
67 | + | let costEstimationOfInnocentPerson = match getInteger((((RegisterTxId + "_") + innocentAddress) + "_cost")) { | |
68 | + | case s: Int => | |
69 | + | s | |
70 | + | case _ => | |
71 | + | "No data Found" | |
72 | + | } | |
73 | + | if ((costEstimationOfInnocentPerson == "No data Found")) | |
74 | + | then throw("There is no data for this address!") | |
75 | + | else if ((costEstimationOfInnocentPerson == -1)) | |
76 | + | then [StringEntry((crashId + "_eval"), txId), StringEntry((crashId + "_innocent_address"), innocentAddress), StringEntry((crashId + "_guilty_address"), guiltyAddress), StringEntry((crashId + "_status"), "evaluated")] | |
77 | + | else [StringEntry((crashId + "_eval"), txId), StringEntry((crashId + "_innocent_address"), innocentAddress), StringEntry((crashId + "_guilty_address"), guiltyAddress), StringEntry((crashId + "_status"), "closed"), ScriptTransfer(Address(fromBase58String(innocentAddress)), 100000000, unit)] | |
22 | 78 | } | |
23 | 79 | } | |
24 | 80 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let BAI_ADDRESS = "3N9tKixzqTYWnEXQxrDQ5pBTGvQd6sFsvmV" | |
5 | 5 | ||
6 | 6 | let AI_TOKEN_ASSET_ID = base58'AxGKQRxKo4F2EbhrRq6N2tdLsxtMnpzQsS4QemV6V1W1' | |
7 | + | ||
8 | + | func removeMarks (marksString) = { | |
9 | + | let a = drop(marksString, 1) | |
10 | + | let b = dropRight(a, 1) | |
11 | + | b | |
12 | + | } | |
13 | + | ||
14 | + | ||
15 | + | func parseJson (json) = { | |
16 | + | let modifiedJson = drop(json, 1) | |
17 | + | let modifiedJson2 = dropRight(modifiedJson, 1) | |
18 | + | let split1 = split(modifiedJson2, ",") | |
19 | + | let keyValue1 = split(split1[0], ":") | |
20 | + | let key1 = removeMarks(keyValue1[0]) | |
21 | + | let value1 = removeMarks(keyValue1[1]) | |
22 | + | let keyValue2 = split(split1[1], ":") | |
23 | + | let key2 = removeMarks(keyValue2[0]) | |
24 | + | let value2 = removeMarks(keyValue2[1]) | |
25 | + | let keyValue3 = split(split1[2], ":") | |
26 | + | let key3 = removeMarks(keyValue2[0]) | |
27 | + | let value3 = removeMarks(keyValue2[1]) | |
28 | + | $Tuple3([key1, value1], [key2, value2], [key3, value3]) | |
29 | + | } | |
30 | + | ||
7 | 31 | ||
8 | 32 | @Callable(i) | |
9 | 33 | func registerData (clientInput,opponentInput,id,oppAddress,lgtCond) = { | |
10 | 34 | let searchForExistingData = match getString(id) { | |
11 | 35 | case s: String => | |
12 | 36 | s | |
13 | 37 | case _ => | |
14 | 38 | "no Data exists" | |
15 | 39 | } | |
16 | 40 | if ((searchForExistingData != "no Data exists")) | |
17 | 41 | then throw("There is already existing Data for this case!") | |
18 | 42 | else { | |
19 | 43 | let client = toString(i.caller) | |
20 | 44 | let txId = toBase58String(i.transactionId) | |
21 | - | [StringEntry(id, txId), IntegerEntry((((txId + "_") + client) + "_age"), clientInput[0]), IntegerEntry((((txId + "_") + client) + "_sex"), clientInput[1]), IntegerEntry((((txId + "_") + client) + "_damage"), clientInput[2]), IntegerEntry((((txId + "_") + client) + "_fac1"), clientInput[3]), IntegerEntry((((txId + "_") + client) + "_fac2"), clientInput[4]), IntegerEntry((((txId + "_") + client) + "_fac3"), clientInput[5]), IntegerEntry((((txId + "_") + client) + "_fac4"), clientInput[6]), IntegerEntry((((txId + "_") + client) + "_vio1"), clientInput[7]), IntegerEntry((((txId + "_") + client) + "_vio2"), clientInput[8]), IntegerEntry((((txId + "_") + client) + "_vio3"), clientInput[9]), IntegerEntry((((txId + "_") + client) + "_vio4"), clientInput[10]), IntegerEntry((((txId + "_") + client) + "_cost"), clientInput[11]), IntegerEntry((((txId + "_") + oppAddress) + "_age"), opponentInput[0]), IntegerEntry((((txId + "_") + oppAddress) + "_sex"), opponentInput[1]), IntegerEntry((((txId + "_") + oppAddress) + "_damage"), opponentInput[2]), IntegerEntry((((txId + "_") + oppAddress) + "_fac1"), opponentInput[3]), IntegerEntry((((txId + "_") + oppAddress) + "_fac2"), opponentInput[4]), IntegerEntry((((txId + "_") + oppAddress) + "_fac3"), opponentInput[5]), IntegerEntry((((txId + "_") + oppAddress) + "_fac4"), opponentInput[6]), IntegerEntry((((txId + "_") + oppAddress) + "_vio1"), opponentInput[7]), IntegerEntry((((txId + "_") + oppAddress) + "_vio2"), opponentInput[8]), IntegerEntry((((txId + "_") + oppAddress) + "_vio3"), opponentInput[9]), IntegerEntry((((txId + "_") + oppAddress) + "_vio4"), opponentInput[10]), IntegerEntry((((txId + "_") + oppAddress) + "_cost"), opponentInput[11]), IntegerEntry((txId + "_lgt"), lgtCond)] | |
45 | + | [StringEntry(id, txId), IntegerEntry((((txId + "_") + client) + "_age"), clientInput[0]), IntegerEntry((((txId + "_") + client) + "_sex"), clientInput[1]), IntegerEntry((((txId + "_") + client) + "_damage"), clientInput[2]), IntegerEntry((((txId + "_") + client) + "_fac1"), clientInput[3]), IntegerEntry((((txId + "_") + client) + "_fac2"), clientInput[4]), IntegerEntry((((txId + "_") + client) + "_fac3"), clientInput[5]), IntegerEntry((((txId + "_") + client) + "_fac4"), clientInput[6]), IntegerEntry((((txId + "_") + client) + "_vio1"), clientInput[7]), IntegerEntry((((txId + "_") + client) + "_vio2"), clientInput[8]), IntegerEntry((((txId + "_") + client) + "_vio3"), clientInput[9]), IntegerEntry((((txId + "_") + client) + "_vio4"), clientInput[10]), IntegerEntry((((txId + "_") + client) + "_cost"), clientInput[11]), IntegerEntry((((txId + "_") + oppAddress) + "_age"), opponentInput[0]), IntegerEntry((((txId + "_") + oppAddress) + "_sex"), opponentInput[1]), IntegerEntry((((txId + "_") + oppAddress) + "_damage"), opponentInput[2]), IntegerEntry((((txId + "_") + oppAddress) + "_fac1"), opponentInput[3]), IntegerEntry((((txId + "_") + oppAddress) + "_fac2"), opponentInput[4]), IntegerEntry((((txId + "_") + oppAddress) + "_fac3"), opponentInput[5]), IntegerEntry((((txId + "_") + oppAddress) + "_fac4"), opponentInput[6]), IntegerEntry((((txId + "_") + oppAddress) + "_vio1"), opponentInput[7]), IntegerEntry((((txId + "_") + oppAddress) + "_vio2"), opponentInput[8]), IntegerEntry((((txId + "_") + oppAddress) + "_vio3"), opponentInput[9]), IntegerEntry((((txId + "_") + oppAddress) + "_vio4"), opponentInput[10]), IntegerEntry((((txId + "_") + oppAddress) + "_cost"), opponentInput[11]), IntegerEntry((id + "_lgt"), lgtCond), StringEntry((id + "_status"), "open")] | |
46 | + | } | |
47 | + | } | |
48 | + | ||
49 | + | ||
50 | + | ||
51 | + | @Callable(i) | |
52 | + | func evaluatedDataCallback (response) = { | |
53 | + | let txId = toBase58String(i.transactionId) | |
54 | + | let parsedJson = parseJson(response) | |
55 | + | let crashId = parsedJson._1[1] | |
56 | + | let innocentAddress = parsedJson._2[1] | |
57 | + | let guiltyAddress = parsedJson._3[1] | |
58 | + | let RegisterTxId = match getString(crashId) { | |
59 | + | case s: String => | |
60 | + | s | |
61 | + | case _ => | |
62 | + | "no Data exists" | |
63 | + | } | |
64 | + | if ((RegisterTxId == "no Data exists")) | |
65 | + | then throw("There is no Data for this crashId!") | |
66 | + | else { | |
67 | + | let costEstimationOfInnocentPerson = match getInteger((((RegisterTxId + "_") + innocentAddress) + "_cost")) { | |
68 | + | case s: Int => | |
69 | + | s | |
70 | + | case _ => | |
71 | + | "No data Found" | |
72 | + | } | |
73 | + | if ((costEstimationOfInnocentPerson == "No data Found")) | |
74 | + | then throw("There is no data for this address!") | |
75 | + | else if ((costEstimationOfInnocentPerson == -1)) | |
76 | + | then [StringEntry((crashId + "_eval"), txId), StringEntry((crashId + "_innocent_address"), innocentAddress), StringEntry((crashId + "_guilty_address"), guiltyAddress), StringEntry((crashId + "_status"), "evaluated")] | |
77 | + | else [StringEntry((crashId + "_eval"), txId), StringEntry((crashId + "_innocent_address"), innocentAddress), StringEntry((crashId + "_guilty_address"), guiltyAddress), StringEntry((crashId + "_status"), "closed"), ScriptTransfer(Address(fromBase58String(innocentAddress)), 100000000, unit)] | |
22 | 78 | } | |
23 | 79 | } | |
24 | 80 | ||
25 | 81 | ||
26 | 82 | ||
27 | 83 | @Callable(i) | |
28 | 84 | func evaluatedData (prediction_id,per_one_address,per_two_address,guilty_person_address) = { | |
29 | 85 | let txId = toBase58String(i.transactionId) | |
30 | 86 | [StringEntry(prediction_id, txId), StringEntry((txId + "_guilty"), guilty_person_address)] | |
31 | 87 | } | |
32 | 88 | ||
33 | 89 | ||
34 | 90 | ||
35 | 91 | @Callable(i) | |
36 | 92 | func requestPayout (pred_txId,amount,id) = { | |
37 | 93 | let client = toString(i.caller) | |
38 | 94 | let txId = toBase58String(i.transactionId) | |
39 | 95 | [StringEntry((id + "_request_payout"), txId), IntegerEntry((txId + "_amount"), amount), StringEntry((txId + "_prediction_id"), pred_txId)] | |
40 | 96 | } | |
41 | 97 | ||
42 | 98 | ||
43 | 99 | @Verifier(tx) | |
44 | 100 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
45 | 101 |
github/deemru/w8io/026f985 29.06 ms ◑