Expand description
§Oracle
A pallet that provides a decentralized and trustworthy way to bring external, off-chain data onto the blockchain.
§Pallet API
See the pallet module for more information about the interfaces this pallet exposes,
including its configuration trait, dispatchables, storage items, events and errors.
§Overview
The Oracle pallet enables blockchain applications to access real-world data through a decentralized network of trusted data providers. It’s designed to be flexible and can handle various types of external data such as cryptocurrency prices, weather data, sports scores, or any other off-chain information that needs to be brought on-chain.
The pallet operates on a permissioned model where only authorized oracle operators can submit data. This ensures data quality and prevents spam while maintaining decentralization through multiple independent operators. The system aggregates data from multiple sources using configurable algorithms, typically taking the median to resist outliers and manipulation attempts.
§Key Concepts
- Oracle Operators: A set of trusted accounts authorized to submit data. Managed through the
[
SortedMembers] trait, allowing integration with membership pallets. - Data Feeds: Key-value pairs where keys identify the data type (e.g., currency pair) and values contain the actual data (e.g., price).
- Data Aggregation: Configurable algorithms to combine multiple operator inputs into a single trusted value, with median aggregation provided by default.
- Timestamped Data: All submitted data includes timestamps for freshness tracking.
§Low Level / Implementation Details
§Design Goals
The oracle system aims to provide:
- Decentralization: Multiple independent data providers prevent single points of failure
- Data Quality: Aggregation mechanisms filter out outliers and malicious data
- Flexibility: Configurable data types and aggregation strategies
- Performance: Efficient storage and retrieval of timestamped data
- Security: Permissioned access with cryptographic verification of data integrity
§Design
The pallet uses a dual-storage approach:
RawValues: Stores individual operator submissions with timestampsValues: Stores the final aggregated values after processing
This design allows for:
- Historical tracking of individual operator submissions
- Efficient access to final aggregated values
- Clean separation between raw data and processed results
- Easy integration with data aggregation algorithms
Re-exports§
pub use traits::CombineData;pub use traits::DataFeeder;pub use traits::DataProvider;pub use traits::DataProviderExtended;pub use traits::OnNewData;pub use weights::WeightInfo;pub use pallet::*;
Modules§
- pallet
- The
palletmodule in each FRAME pallet hosts the most important items needed to construct this pallet. - traits
- This module provides traits for data feeding and provisioning.
- weights
- Autogenerated weights for
pallet_oracle
Macros§
- create_
median_ value_ data_ provider - Creates a median data provider from a list of other data providers.
Structs§
- Default
Combine Data - Sort by value and returns median timestamped value. Returns prev_value if not enough valid values.
Traits§
- Benchmark
Helper - Helper trait for benchmarking oracle operations.