LogoLogo
  • Quex oracles
  • How it works?
    • Why another oracle?
    • Quex oracle security
    • Onchain verification
  • General information
    • Where to start
    • Quex approach and terminology
    • Quex data delivery modes
    • Smart contract addresses
  • Developers
    • Building with Quex
    • Getting started tutorial
    • Flow creation
    • Client callback format
    • Request oracle pool
      • Descriptive guide
      • Supported post-processing operations
      • Data encoding format
  • Data providers
    • Running your own oracle pool
    • TD oracle requirements
    • Registering your Trust Domain
    • Pool creation
    • Follow us!
Powered by GitBook
On this page
  1. Developers
  2. Request oracle pool

Data encoding format

PreviousSupported post-processing operationsNextRunning your own oracle pool

Last updated 1 month ago

For EVM networks, Quex Request Oracles support all data structures compatible with . A Solidity ABI schema is specified within Quex Request Oracles as a string, and it must match the data structure returned by the jq filter and used in your smart contracts.

Below is a list of typical or interesting schemas that might assist you when creating your flow:

Integer: uint256

The simplest case is fetching a single numeric value from an API. In such cases, use uint256 as your schema. When using the FlowBuilder tool, set your schema during flow creation as follows:

config = config.withSchema("uint256");

Later, decode the response while processing the oracle’s data:

uint256 responseValue = abi.decode(response.value, (uint256));

Nested structures

Let's consider a more complex scenario. Suppose the DApp collects the order books for BTC/USDT pair for its logic. It needs the following data from Binance:

  • The sequential number of the update to keep track of the ordering (Binance returns it as lastUpdateId)

  • Five best bids

  • Five best asks

Both bids and asks should be represented as tuples of integers (price, quantity) with precision up to 8 digits after the decimal point.

To handle this scenario, we can define the following Solidity structures:

struct Order {
    uint256 price;
    uint256 quantity;
}

struct OrderBook {
    uint256 lastUpdateId;
    Order[5] bids;
    Order[5] asks;
}

Then, define your ABI schema as (uint256,(uint256,uint256)[5],(uint256,uint256)[5]). When using the FlowBuilder tool, set the schema during flow creation:

config = config.withSchema("(uint256,(uint256,uint256)[5],(uint256,uint256)[5])");

Finally, decoding the response during processing is straightforward:

orderbook = abi.decode(response.value, (OrderBook))

As illustrated by these examples, Quex Request Oracles support a wide range of data schemas - from simple integers to complex nested structures. By leveraging ABI encoding, you can flexibly and securely integrate off-chain data into your smart contracts, enabling sophisticated, data-driven logic within your dApps.

ABI encoding