Skip to main content
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.

How blockchain oracles work

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.

Types of blockchain oracles

Blockchain oracles can be classified by how they operate, where oracles obtain data, the direction of data flow, and their governance structure.

Push and pull oracles

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.
For a detailed explanation of push and pull oracle models, see ChainLink - Pull vs Push oracles.

Centralized and decentralized oracles

  • Centralized oracles are controlled by a single party, which introduces a single point of failure.
  • Decentralized oracles verify data across multiple nodes, reducing dependence on any single source.

Cross-chain oracles

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.

Application of blockchain oracles

Blockchain oracles connect the digital world of blockchains and the real world, enabling a wide range of applications.

DeFi (decentralized finance)

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.

Prediction markets

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.

Random number generation

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

Oracles 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.

Push oracle flow

  1. The data provider pushes the latest data on-chain.
  2. The user contract, which needs prices on-chain, sends a request message to the trusted oracle contract.
  3. The oracle contract replies to the sender address with a response internal message, containing the requested data.
  4. The user contract receives an oracle response, verifies the sender address, and then is ready to use the provided data.

Pull oracle flow

  1. Users’ off-chain backend calls the API method on the data provider.
  2. Provider responds with signed price data, including a timestamp till this data is valid.
3-4. The user sends a message to his on-chain contract, which requires prices and other business logic.
  1. User contract sends “Verify that this price is correctly signed and valid” internal message to the oracle contract
  2. Oracle contract verifies signature, timestamp, and price feed ID. If everything is okay, it sends a response with the prices back
  3. The user contract receives a response from the oracle contract, checks if the sender is really the oracle, and then can use the provided data
oracle-flow

List of oracles in TON