Oracles in Blockchains and Smart Contracts

What are oracles in the blockchain and smart contract ecosystem and how are they being used? We will discuss some of its basics, giving you an understanding of the subject, and will provide you with some great resources to learn more.

  1. What are oracles?
  2. How do they work?

What are oracles?

Blockchains and smart contracts have a specific characteristic and that is that they aim to take away a single point of failure as well as a single point of control. Everything about blockchains is about decentralization and distribution, distributing control to the masses and eliminating the need for a powerful intermediary. But what if the smart contracts we write need external data input for important functionality? They do not have access to any data outside of the blockchain. Are we going to have the contract owner send in this data? He can be malicious or compromised, and what if he is unable to send in data in the first place? Another party then? It is an issue that is addressed using oracles. Oracles are ways for smart contracts to take in external data that is not native to the contract (such as weather, stock, flight, temperature, currency, and much more) in a safe and distributed way. They provide smart contracts with the ability to run on external data without a single party controlling the data or creating a single point of failure that can break the contract.

How does it work?

You will set up a connection to one or more oracles from within your smart contract. Every time your contract requires external data it will open a request to the oracle(s), which on its turn will fetch the data in a distributed manner. Once the data is fetched it will call into the smart contract and provide the data which can then be used in the contract for whatever functionality is implemented. The goal here is that the oracles provide the data in a way that it cannot be comprised and altered before being submitted into the contract.

Trusted and Trustless Oracles

Trusted oracles are typically used in a private blockchain scenarios and often the provider of the oracle is also the creator of the blockchain-based application that connects to it, meaning it is not very decentralized. This leads it also to having a single point of failure. These oracles kind of work like a single proxy for smart contracts to access external data.

Trustless Oracles

Oracles that are unknown and may or may not be malicious. They are trustless given that they operate on the public blockchain. When using trusless oracles you eliminate a single point of failure by connecting with multiple oracles, as such that if one oracles goes down or provides false/inaccurate data the application still has access to quality data. Using trusless oracles, however, means that you need to implement considerable measures to minimize trust and protect from malicious actions (multiple data sources, multiple oracles, and more).

Staking is for example also such a measure that can be taken to eliminate malicious oracle behavior. It means that the oracles stake value which can be lost if it ends up acting maliciously or provide poor data quality. This incentivize the oracles to be very careful with the data they submit and steers them away from considering attacks (such as Sybil, Cartel, and Mirroring attacks).

Do you want to learn more about smart contracts and blockchain technology? There are some amazing courses out there on the internet that can be a great way to get comfortable with the subject. Here are three courses we recommend:

Blockchain Developer Nanodegree by Udacity | $999
This is an amazing program for anybody that is serious about getting into blockchain technology and wants to get skilled working with smart contracts. It is definitely more pricey but it is most likely the most all-round course with the highest quality certificate you can find. It starts with the Bitcoin blockchain to provide a solid understanding of blockchain essentials, from which it then moves to Ethereum, and especially dives into smart contract development and building blockchain-based applications.

Introduction to Bitcoin and Decentralized Technology by Pluralsight | Free Trial
Pluralsight is another amazing platform that focuses on tech subjects and is incredibly popular. Their Introduction to Bitcoin and Decentralized Technology course is a great step for anybody that is looking to get into the field. However, note that this is mostly focused on the Bitcoin blockchain and specifically focuses on a high-level approach.

Smart Contracts by Coursera | $43/month
If you are already a bit more familiar with blockchain tech and want to get going developing smart contracts on Ethereum, this course is an excellent choice. Coursera provides a complete specialization on blockchain technology which is definitely worth checking out if you want to commit to this but this subcourse can be an excellent start to get into smart contract programming anyway.

Want to see more courses? Check out our Blockchain subject page which showcases the best blockchain courses on the internet.