DEV Community

Cover image for Flare Oracle: A Comprehensive Guide for Developers
AJTECH0001
AJTECH0001

Posted on

Flare Oracle: A Comprehensive Guide for Developers

Introduction

Blockchain technology has revolutionized decentralized applications (dApps), but one fundamental limitation persists: blockchains are inherently isolated. Smart contracts lack direct access to off-chain data, making it impossible to react to real-world events without external assistance. This is where oracles come in.

Oracles bridges on-chain and off-chain data sources, enabling smart contracts to interact with real-world information. They power decentralized finance (DeFi) applications, gaming platforms, prediction markets, and more. However, traditional oracles introduce security risks, cost inefficiencies, and trust concerns, leading to vulnerabilities in blockchain applications.

Flare solves these challenges through enshrined oracles—oracles that are natively built into the blockchain protocol, ensuring decentralization, security, and efficiency. This article provides an in-depth look at Flare’s Flare Time Series Oracle (FTSO) and Flare Data Connector (FDC), explaining their architecture, benefits, and use cases for developers.

Image description

Understanding Oracles in Blockchain

Why Are Oracles Needed?

Smart contracts can only interact with data within their own blockchain environment. They cannot fetch external information such as asset prices, weather updates, or sports scores on their own. Oracles solve this issue by:

  • Bridging the On-Chain and Off-Chain Worlds – They fetch external data and bring it onto the blockchain.

  • Enabling Real-World Reactions – Smart contracts can execute based on real-world events.

  • Enhancing Blockchain Utility – Oracles expand the potential of dApps by allowing access to verified external information.

Common Oracle Use Cases

  • Price Feeds – Oracles provide real-time asset prices for DeFi applications like lending, derivatives, and AMMs.

  • Weather Data – Supports insurance and climate-based financial products.

  • Sports Scores – Enables decentralized betting platforms.

  • Random Number Generation (RNG) – Essential for gaming, lotteries, and fair protocol operations.

  • Proof of Identity & Location – Assists with KYC/AML compliance and location-based services.

Traditional oracles, however, rely on third-party services, which introduce cost, security concerns, and points of failure.

Flare’s Enshrined Oracle Architecture

Flare integrates two complementary oracle systems into its protocol:

Image description

Flare Time Series Oracle (FTSO)

Design Principles

Decentralized Data Aggregation:

  • 100+ independent providers submit price feeds.
  • Providers are selected based on stake-weighted delegation (~67% of FLR is staked/delegated).

High-Frequency Updates:

  • Data is refreshed every 1.8 seconds (aligned with block time).
  • Supports 1,000+ time-series feeds (e.g., crypto prices, indices).

Incentive Alignment:

  • Delegators earn rewards for accurate submissions.
  • Providers with consistent inaccuracies lose stake.

Technical Workflow

Data Submission: Providers fetch data from independent sources.

Weighted Median Calculation: Outliers are discarded; the median of remaining values becomes the canonical price.

On-Chain Availability: Finalized data is written to Flare’s state for dApp consumption.

Sample contract

This example smart contract queries the latest feed values for FLR/USD, BTC/USD, and ETH/USD from FTSOv2 on Flare Testnet Coston2.

// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;

import {ContractRegistry} from "@flarenetwork/flare-periphery-contracts/coston2/ContractRegistry.sol";
/* THIS IS A TEST IMPORT, in production use: import {FtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/FtsoV2Interface.sol"; */
import {TestFtsoV2Interface} from "@flarenetwork/flare-periphery-contracts/coston2/TestFtsoV2Interface.sol";

/**
 * THIS IS AN EXAMPLE CONTRACT.
 * DO NOT USE THIS CODE IN PRODUCTION.
 */
contract FtsoV2FeedConsumer {
    TestFtsoV2Interface internal ftsoV2;
    // Feed IDs, see https://dev.flare.network/ftso/feeds for full list
    bytes21[] public feedIds = [
    bytes21(0x01464c522f55534400000000000000000000000000), // FLR/USD
    bytes21(0x014254432f55534400000000000000000000000000), // BTC/USD
    bytes21(0x014554482f55534400000000000000000000000000) // ETH/USD
    ];

    /**
     * Get the current value of the feeds.
     */
    function getFtsoV2CurrentFeedValues()
    external
    returns (
        uint256[] memory _feedValues,
        int8[] memory _decimals,
        uint64 _timestamp
    )
    {
        /* THIS IS A TEST METHOD, in production use: ftsoV2 = ContractRegistry.getFtsoV2(); */
        ftsoV2 = ContractRegistry.getTestFtsoV2();
        /* Your custom feed consumption logic. In this example the values are just returned. */
        return ftsoV2.getFeedsById(feedIds);
    }
}
Enter fullscreen mode Exit fullscreen mode

Use Cases

  • DeFi Applications – Trading, lending, yield farming.

  • Stablecoins – Accurate pricing mechanisms.

  • Prediction Markets – Ensuring fair and accurate betting outcomes.

Image description

Flare Data Connector (FDC)

Design Principles

General-Purpose Data:

  • Fetches non-time-series data (e.g., weather, sports scores, cross-chain states).
  • Supports verifiable proofs from open APIs or other blockchains.

Consensus-Driven Attestation:

  • Multiple providers independently verify data.
  • Data is published only after achieving consensus.

Use Cases

  • Cross-Chain Bridges – Secure movement of assets across networks.

  • Lending & Borrowing – Access on-chain credit scores from other blockchains.

  • Automated Workflows – Fetch data from APIs for smart contract automation.

FDC enables dApps to:

  • Verify transactions on external chains (e.g., Bitcoin, Ethereum).

  • Access decentralized identity proofs or IoT sensor data.

{
  "attestationType": "0x45564d5472616e73616374696f6e000000000000000000000000000000000000",
  "sourceId": "0x7465737445544800000000000000000000000000000000000000000000000000",
  "requestBody": {
    "transactionHash": "0x4e636c6590b22d8dcdade7ee3b5ae5572f42edb1878f09b3034b2f7c3362ef3c",
    "requiredConfirmations": "1",
    "provideInput": true,
    "listEvents": true,
    "logIndices": []
  }
}
Enter fullscreen mode Exit fullscreen mode

FTSO vs. FDC: Key Differences

Criteria FTSO FDC
Data Type Time-series (e.g., prices) General-purpose (any data)
Update Frequency Every 1.8 seconds On-demand (event-driven)
Cost Free (subsidized by network) Gas fees apply
Use Cases DeFi, derivatives Cross-chain, insurance, gaming

Enshrined Oracles: A Game-Changer in Blockchain

What Are Enshrined Oracles?

Enshrined oracles are natively built into the blockchain’s consensus mechanism, eliminating external dependencies and improving security. Unlike third-party Oracle solutions, they are part of the Layer 1 blockchain itself.

Ethereum’s Stance on Enshrined Oracles

Ethereum has long debated enshrined oracles. Initially, Vitalik Buterin opposed them due to concerns about protocol neutrality, but over time, he acknowledged their benefits in enhancing blockchain security and efficiency.

Why Flare’s Enshrined Oracles Matter

  • Stronger Security – Eliminates reliance on external third parties.
  • Lower Costs – Free oracle data eliminates expensive service fees.
  • Greater Decentralization – Ensures no single point of failure in data provisioning.

Developer Benefits

1. Simplified Integration

  • Unified API: Access FTSO/FDC via Flare’s native interfaces.
  • Gas Efficiency: FTSO data is free; FDC costs are minimized via batch proofs.

2. Enhanced Security

  • Immutability: Oracle logic is hardcoded into Flare’s protocol.
  • Collusion Resistance: Stake-weighted delegation dilutes malicious influence.

3. Future-Proofing with FTSOv2

Upcoming upgrades include:

  • Sub-Second Updates: Critical for HFT and options trading.
  • Custom Feeds: dApps can request tailored data streams.

Conclusion

Flare’s enshrined oracles represent a paradigm shift in blockchain data infrastructure. By integrating FTSO and FDC directly into Layer 1, Flare eliminates the trade-offs between decentralization, cost, and security that plague third-party solutions. Developers gain access to:

  • High-frequency, free price feeds (FTSO).
  • General-purpose, verifiable data (FDC).
  • A unified security model backed by Flare’s validator network.

As enshrined oracles evolve with FTSOv2 and beyond, Flare is poised to become the backbone of a new generation of dApps—ones that seamlessly interact with real-world data while maintaining blockchain’s core promise of trustlessness.

Additional Resources

Top comments (0)