|
1 | 1 | --- |
2 | 2 | title: JsonApi |
3 | | -description: An attestation request that fetches data from the given url and then edits the information with a jq transformation. |
4 | | -keywords: [fdc, oracle, flare-data-connector, flare-network] |
| 3 | +description: An attestation type that fetches and transforms JSON data from web APIs using JQ transformations. |
| 4 | +keywords: [fdc, oracle, flare-data-connector, flare-network, json, api, web2] |
5 | 5 | sidebar_position: 1 |
6 | 6 | --- |
7 | 7 |
|
8 | | -An attestation request that fetches data from the given url and then edits the information with a jq transformation. |
| 8 | +An attestation type that enables secure data retrieval from Web2 JSON APIs with custom JQ transformations. This attestation type allows smart contracts to access and process external JSON data in a verifiable way. |
| 9 | + |
| 10 | +:::warning[Testing Networks Only] |
| 11 | +JsonApi attestation type is currently only available on Coston and Coston2 test networks. |
| 12 | +::: |
9 | 13 |
|
10 | 14 | ## Supported sources |
11 | 15 |
|
12 | | -- `WEB2` |
13 | | -- test networks: `testWEB2` |
| 16 | +- `WEB2` (Web 2.0 JSON APIs) |
| 17 | +- Test networks: `testWEB2` |
14 | 18 |
|
15 | 19 | ## Request |
16 | 20 |
|
17 | | -| Field | Solidity type | Description | |
18 | | -| --------------- | ------------- | -------------------------------------------------------- | |
19 | | -| `url` | `string` | URL of the data source. | |
20 | | -| `postprocessJq` | `string` | JQ filter to postprocess the json received from the url. | |
21 | | -| `abi_signature` | `string` | ABI signature of struct for encoding. | |
| 21 | +| Field | Solidity Type | Description | |
| 22 | +| --------------- | ------------- | -------------------------------------------------------------------------------- | |
| 23 | +| `url` | `string` | URL of the JSON API endpoint to query. | |
| 24 | +| `postprocessJq` | `string` | JQ filter expression to transform the retrieved JSON data. | |
| 25 | +| `abi_signature` | `string` | ABI signature defining the struct format for encoding the transformed JSON data. | |
22 | 26 |
|
23 | 27 | ## Response |
24 | 28 |
|
25 | | -| Field | Solidity type | Description | |
26 | | -| ------------------ | ------------- | ----------------- | |
27 | | -| `abi_encoded_data` | `bytes` | ABI encoded data. | |
28 | | - |
29 | | -## Lowest Used Timestamp |
| 29 | +| Field | Solidity Type | Description | |
| 30 | +| ------------------ | ------------- | ------------------------------------------------ | |
| 31 | +| `abi_encoded_data` | `bytes` | ABI-encoded data result after JQ transformation. | |
30 | 32 |
|
31 | | -For `lowestUsedTimestamp`, `0xffffffffffffffff` ($2^{64}-1$ in hex) is used. |
| 33 | +## Verification Process |
32 | 34 |
|
33 | | -## Verification process |
| 35 | +1. The attestation service performs a GET request to the specified `url`. |
34 | 36 |
|
35 | | -Query the URL with GET method. |
36 | | -If the query is unsuccessful or does not return a json, reject the request. |
| 37 | + - If the request fails or returns non-JSON data, the attestation request is rejected. |
| 38 | + - The service validates that the response is valid JSON data. |
37 | 39 |
|
38 | | -Apply the jq filter specified in the request to the received json. |
| 40 | +2. The specified `postprocessJq` filter is applied to the retrieved JSON: |
39 | 41 |
|
40 | | -ABI encode the filtered json with the abi_signature provided in the request and return it as abi_encoded_data. |
| 42 | + - The JQ filter must be a valid JQ expression. |
| 43 | + - The filter's output must match the structure defined in `abi_signature`. |
| 44 | + - If the JQ transformation fails, the attestation request is rejected. |
41 | 45 |
|
42 | | -`LowestUsedTimestamp` is unlimited. |
| 46 | +3. The transformed data is ABI-encoded according to the provided `abi_signature`: |
| 47 | + - The encoding must match the Solidity ABI specification. |
| 48 | + - The encoded bytes are returned in `abi_encoded_data`. |
0 commit comments