Oracles: bringing data to the blockchain

In the context of blockchains, an oracle is an agent that finds and verifies real-world occurrences and submits this information to the blockchain to be used by smart contracts. The data could be the price of a currency, the weather at a given location, the result of a sport event or an election.

There are different types of oracles that can be implemented and used depending on your needs:

  • Software oracles handle information available online on the internet. An example could be the temperature, prices of commodities and goods, flight or train delays, etc. The data originates from online sources, like APIs, websites… The software oracle extracts the needed information and pushes it into the smart contract. We wrote about the Oraclize service that does this for you.
  • Hardware Oracles, some smart contracts need information directly from the physical world, for example, a product is scanned using a barcode reader and the information is sent to the smart contract. Another use case is RFID sensors in the supply chain industry that could help the blockchain tracks the supply.

The oracle could just provide the result of an action happening in the real world or could be here to resolve a dispute as an expert in a contract where parties are don’t agree on something.

The oracles can either bring data inside the blockchain or inform an actor outside of the blockchain about an event:

  • Inbound Oracles These provide the smart contract with data from the external world. Example use case will be an automatic buy order if the USD hits a certain price.
  • Outbound Oracles These provide smart contracts with the ability to send data to the outside world. An example would be a smart lock in the physical world which receives a payment on its blockchain address and will unlock automatically.

 

To implement a simple Oracle pattern we could write a simple smart contract for a flight delay insurance. In this smart contract, they will be three actors: The insurer, the client and an thrusted oracle that will tell if the flight was late or not and transfer all the bounty to the insurer or the client depending on the result.

Our smart contract will work in 3 steps:

  • The insurer create the contract and lock 10 time the price of the cost of the insurance in the smart contract.
  • The client pay the price of the insurance and the money of the client and the insurer are locked.
  • The oracle tells if the flight was delayed or not. If the flight was late the client receive his deposit and the money from the insurer, if the flight was on time the insurer get refunded his guarantee and get the fee paid by the client.

There is lot of room for improvement in our basic contract, for example we could also imagine that the oracle get a fee for rewarding his service.

Here is the basic implementation of our contract:

 

 

Leave a Comment