Integrate external data from outside blockchain [Oracles]

Integrate external data from outside blockchain [Oracles]


4 min read

Since blockchain data is Immutable, hashed, and tracked using blocks, can these blocks contain data from the outside world?

the short answer is yes .

to achieve that we use something called Oracles or as many like to call (Blockchain middleware).

Simply, using an oracle means receiving data from outside of a blockchain. Said another way, an oracle provides a connection between real-world events (Off-chain) and a blockchain. In my opinion, all of the really interesting complex smart contracts require outside information — financial derivatives, stablecoins , identity…literally anything where you want to incorporate something happening in the real world. Turns out, transparently representing real-world events in precise digital terms is a challenge. To better conceptualize oracles, this post will build our intuition around why it’s difficult to represent reality, digitally.

The Blockchain Oracle Problem

The oracle problem revolves around a veritably simple limitation — blockchains can not pull in data from or push data out to any external system as erected-in functionality.

As similar, blockchains are insulated networks, like a computer with no Internet connection. The insulation of a blockchain is the precise property that makes it extremely secure and dependable, as the network only needs to form an agreement on a veritably introductory set of double ( true/ false) questions using data formerly stored inside of its tally.

these questions include :

  • did the public key holder subscribe to the sale with their corresponding private key?
  • does the public address have enough finances to cover its sale?
  • is the type of sale valid within the particular smart contract?

The veritably narrow focus of blockchain agreement is why smart contracts are appertained to as being deterministic — they execute exactly as written with a much-advanced degree of certainty than traditional systems.

Still, for smart contracts to realize the overhead of 90 of their implicit use cases, they must connect to the outside world. For illustration, financial smart contracts need request information to determine settlements, insurance smart contracts need IoT and web data to make opinions on policy payouts, trade finance contracts need trade documents and digital autographs to know when to release payments, and numerous smart contracts want to settle in edict currency on a traditional payment network.

None of this information is innately generated within the blockchain, nor are these traditional services directly accessible.

Bridging the connection between the blockchain (on-chain) and the outside world (off-chain) requires a fresh and separate piece of a structure known as Oracle.

61277245f4962c179dcab303_Hybrid Smart Contract.png

Oracles Types :

The data can come from hardware (IoT) or software (API).

Software oracles: obtains information from internet sources via Data interfaces like APIs...etc, then feeds that data to smart contracts with up-to-date information. In the context of blockchain, this information is often obtained through crypto exchanges for example.

Hardware oracle: takes data from the physical world and converts it into digital values ​​that can be used by blockchain smart contracts. Barcode / QR Code scanners and sensors are examples of devices that actively or passively collect data and send it to smart contracts.

Direction :

Information can travel in either an incoming or outward direction.

Outbound oracles: allow smart contracts to transmit data to external sources,

Inbound oracles: allow the network to transfer information from external data sources to smart contracts.

Oracle Centralization types:

Centralized oracles: A centralized oracle is a whole that delivers data from external sources to smart contracts that are protected by a series of security measures. However, because there is only one node in charge - comparable to a typical single-point financial system - smart contracts become less secure and more vulnerable to corruption and attack from bad information injected into them.

Decentralized Oracle: this type of oracle relies on a variety of external sources to ensure that the data provided on smart contracts is reliable. Decentralized Oracle is based on Schelling's point theory, where all players provide data without conspiracy, and Schelling's game evaluates whether the consensus data point or proposed software revision is valid and acceptable after error filtering.

What Blockchain Oracle can do ?

Listen – monitor the blockchain network to check for any incoming user or smart contract requests for off-chain data.

Extract – fetch data from one or multiple external systems such as off-chain APIs hosted on third-party web servers.

Format – format data retrieved from external APIs into a blockchain readable format (input) and/or making blockchain data compatible with an external API (output).

Validate – generate a cryptographic proof attesting to the performance of an oracle service using any combination of data signing, blockchain transaction signing, TLS signatures, Trusted Execution Environment (TEE) attestations, or zero-knowledge proofs.

Compute – perform some type of secure off-chain computation for the smart contract, such as calculating a median from multiple oracle submissions or generating a verifiable random number for a gaming application.

Broadcast – sign and broadcast a transaction on the blockchain in order to send data and any corresponding proof on-chain for consumption by the smart contract.

Output (optional) – send data to an external system upon the execution of a smart contract, such as relaying payment instructions to a traditional payment network or triggering actions from a cyber-physical system.