What is Oracle

945G...fRid
23 May 2024
56



Oracle Design Patterns

Oracles generally perform key functions such as collecting off-chain data, transferring it on-chain with a signed message, and storing it in a smart contract. Once available in a contract’s storage, the data can be accessed by other smart contracts via message calls or directly by Ethereum nodes and clients.

Oracles can be set up in three main ways: immediate-read, publish-subscribe, and request-response.

Immediate-Read Oracles

Immediate-read oracles provide data for immediate decisions, such as verifying a person’s age or fetching an address. Data stored once in the contract’s storage can be accessed by other contracts or directly by clients without incurring transaction costs. For example, a university could set up an oracle to verify academic achievements using hashed data for efficiency and privacy.

Publish-Subscribe Oracles

Publish-subscribe oracles broadcast data that changes regularly. Smart contracts can poll these oracles or listen for updates. Examples include price feeds and weather information. While polling is inefficient for web servers, it is manageable in blockchain platforms where local calls to a synced client can check for data changes. Event logs in Ethereum facilitate watching for oracle updates.

Request-Response Oracles

Request-response oracles handle vast datasets, responding to specific queries. This model suits data provider businesses and involves an EOA interacting with an oracle contract. The oracle processes the request, retrieves and signs the data, and delivers it to the requester. This pattern allows detailed data retrieval and scheduling of updates, though it can be complex and resource-intensive.

Oracles may follow other schemes, such as direct EOA interactions or IoT-enabled hardware sensors. The request-response pattern, seen in client-server architectures, is useful for two-way communication but may not suit scenarios like daily interest rate queries, where a publish-subscribe model might be more efficient.

In summary, oracles are crucial for bringing real-world data to blockchain applications, expanding the functionality and scope of smart contracts while navigating the challenges of trust and decentralization.

Write & Read to Earn with BULB

Learn More

Enjoy this blog? Subscribe to 666

2 Comments

B
No comments yet.
Most relevant comments are displayed, so some may have been filtered out.