SKALE Connect
SKALE Connect allows developers to access any external data source using the decentralized power of your SKALE Chain. If your dApp needs market data, weather temperatures, or Ethereum data, SKALE Connect provides a simple way to deliver this data to your Dapp.
Chain Name | Oracle Contract Address |
---|---|
Calypso Testnet | 0x3aBF627F8450242376331c0752d19c9c6F01CB88 |
Europa Testnet | 0x3ac975ec90aD45D52B8A9599cB7910689772593C |
Nebula Testnet | 0x476a3F651d724472346bA4D6389665abC4921537 |
Titan Testnet | 0xC0007F195B7c49b40C6166a78B2C81Fee8f7593E |
Theory
Oracle Methods
- oracle_submitRequest (http(s))
- oracle_submitRequest (eth)
- oracle_checkResult
Supported Geth Endpoints
Besides any http/https endpoint, the Oracle supports the following Geth JSON RPC endpoint for retrieving Ethereum network data:
eth://eth_call
JSON RPC API Reference
oracle_submitRequest (http(s))
Submits an Oracle request and returns a message receipt.
Parameters:
cid: <uint64>
- chain IDuri: <string>
- Oracle http|https endpoint. Must begin withhttp://
orhttps://
.time: <uint64>
- Linux time of request in msjsps: <array>
- list of JSON pointer to the data elements to be picked from the server response. The array must have 1 - 32 elements.encoding: <string>
- the only supported encoding isjson
.- (optional)
trims: <uint64>
- an array of trim values used to trim endings of strings in the Oracle result. Iftrims
array is provided, it must provide trim values for each JSON pointer requested. - (optional)
post: <string>
- if provided, the Oracle will use POST instead of GET (default). The value will be posted to the endpoint. pow: <string>
- uint64 proof of work used to protect against DoS attacks.
Results:
The result will be an RpcResponse JSON object with result equal to:
<string>
- a message receipt used to check later if the result is ready
Example:
oracle_submitRequest (eth)
Submits an Oracle request to an Ethereum API and returns a message receipt.
Parameters:
cid: <uint64>
- chain IDuri: <string>
- Oracle geth endpoint. Must begin witheth://
.time: <uint64>
- Linux time of request in msethApi: <string>
- value ofeth_call
.params: <string>
- params toeth_call
.encoding: <string>
- the only supported encoding isjson
.pow: <string>
- uint64 proof of work used to protect against DoS attacks.
pow
must be the last parameter.
Example:
oracle_checkResult
Checks whether an Oracle result has been derived. By default the result is signed by nodes, where is the maximum number of untruthful nodes. Each node signs using its ETH wallet ECDSA key.
If no result has been derived, ORACLE_RESULT_NOT_READY
is returned.
Otherwise an error is returned.
The client is supposed to wait 1 second and try again.
Parameters:
receipt: <string>
- message receipt, returned by a call tooracle_submitRequest
Results:
The result repeats JSON elements from the corresponding Oracle request, plus includes a set of additional elements:
rslts: <array>
- string resultssigs : <array>
- ECDSA signatures where signatures are not null.
Example:
Hands On
How it works
- A client submits a JSON RPC
oracle_submitRequest
GET or POST request to the SKALE chain containing the request specification. - The SKALE daemon (skaled) distributes the request to all other nodes in the SKALE Chain and the client is presented with a receipt.
- Each of the 16 SKALE nodes performs the request, retrieves the data, and signs the result with it’s ECDSA key.
- The Oracle result is returned when nodes sign the same result, where is the maximum number of untruthful nodes. On SKALE Chains is .
-
Request Formatting
To make a JSON-RPC request, send an HTTP POST request with a
Content-Type: application/json
header. The JSON request data should contain 4 fields:jsonrpc: <string>
, set to"2.0"
id: <number>
, a unique client-generated identifying integermethod: <string>
, a string containing the method to be invokedparams: <array>
, a JSON array of ordered parameter values
The response output will be a JSON object with the following fields:
jsonrpc: <string>
, matching the request specificationid: <number>
, matching the request identifierresult: <array|number|object|string>
, requested data or success confirmation
Requests can be sent in batches by sending an array of JSON-RPC request objects as the data for a single POST.
-
Request Example
Below is shown how to make a request to the SKALE Connect. The full example, in Javascript, requests from the SKALE Calypso Testnet the balanceOf a NFT present on the Ethereum Goerli Network.
Additional SKALE Connect Documentation
Click here for the official documentation.