Clique Query
Clique supports JSON-RPC-styled queries.
id
Unique query ID
Yes
method
Task name
Yes
params
Task input
Yes
input_types
Task input types
Only required by Clique Client SDK
custom_types
Custom types used in task input types
Only required by Clique Client SDK
Clique Network supports both on-chain and off-chain queries. Although they both follow our JSON-RPC-styled queries, the specific types naturally differ due to the different programming languages.
Note that you cannot create an identical Clique Query. If you attempt to create an identical Clique Query, you will encounter a QueryAlreadyExists error. If you do not need to rerun the Clique Query, you can simply retrieve the previous results instead of creating the same query again. If you indeed wish to rerun the query, specify a different id to create a new query.
On-Chain Query
For example, this is the manifest file for the clique_fibonacci sample task:
spec-version = "1"
name = "clique_fibonacci"
type = "Dynamic"
proof-type = ["TEE"]
[input]
n = { type = "u256", description = "n" }
[output]
result = { type = "u256", description = "fibonacci sequence for n" }To create a query for running the clique_fibonacci task, you can define the task input using a struct, such as Params, and construct the query via ICliqueTaskManager.Task:
The above example is quite straightforward. Next, we will demonstrate a slightly more complex example. Below is the manifest file for our clique_httpsRequest task, which can be used to provide TLS calls for smart contracts:
Note that this task includes a custom type Transformation. Next, we will demonstrate how to create a query for this task:
For further details, please refer to Smart Contract Integration.
Off-Chain Query
For off-chain tasks, we use JSON format to create queries. Users can create queries via the Clique Client SDK, or you can directly access the Clique Network to create queries. However, we strongly recommend using the Clique Client SDK, as it helps you validate the query, eliminating the need for you to manually perform complex validation.
Creating off-chain queries is straightforward and supports the creation of batch queries.
Single Query
If use our Clique Client SDK, here we use the Rust SDK as an example:
If you wish to directly access the Clique Network, you can construct the JSON query in the following format, but you will be responsible for validating the entire process yourself:
Batch Query
If use our Clique Client SDK:
If accessing the Clique Network directly:
Last updated