Blockchain oracles are entities that connect the blockchain and the real world. They supply smart contracts with data from off-chain sources, such as exchange rates, payment statuses, and weather conditions.
Although oracles are not part of the blockchain itself, they act as trusted intermediaries that deliver verified external data to smart contracts.Most oracles are decentralized, which reduces dependence on a single data source. The distributed design verifies data across multiple nodes before it is used in smart contracts. This approach minimizes manipulation and errors, ensuring that the information provided is accurate and up-to-date.
Push and pull oracles differ in how data is delivered to on-chain smart contracts.
In push oracles, the data provider continuously pushes the latest data to the centralized trusted contract.
In pull oracles, users retrieve the latest data from off-chain providers and verify it through the oracle contract. Pull oracles are more suitable for real-world applications in TON. See details.
Cross-chain oracles transfer data between different blockchains and provide the information required for bridges to operate. They enable decentralized applications to execute cross-chain transactions, such as transferring crypto assets between networks.
Oracles provide market price and cryptocurrency data to DeFi platforms, enabling token values to be linked to real assets. Accurate price feeds enable lending platforms to maintain correct collateral valuation and manage risk, supporting transparency and stability in financial operations.
Oracles aggregate and analyze data from multiple sources to identify real-world events. This allows prediction and insurance smart contracts to execute payments automatically, reducing manual processing and accelerating response times.
Generating random numbers in smart contracts is difficult because all operations must be deterministic and reproducible, which conflicts with the concept of randomness. Computational oracles provide external data that contracts can use to produce verifiable random numbers for games and lotteries, allowing results to be publicly verifiable.Read more: Randomness in TON
Since TON’s execution model is asynchronous, classic methods for interacting with oracles, such as get methods during a transaction, cannot be applied.Instead, the recommended way to retrieve data from an oracle is the carry-value pattern, where a contract sends an internal message to the oracle contract and verifies the response to obtain the needed data.This pattern works efficiently with pull oracles, providing minimal latency. Pull oracles allow full control over update frequency, enabling contracts to obtain data as often as needed.With push oracles, two internal messages — carry and value — are required to retrieve data. Data relevance depends on the provider’s up-time and update intervals. For example, if updates occur every 10 minutes, the data may be outdated by approximately 5 minutes.