Smart contracts exist on the blockchain and can only access data available on-chain. They rely on what’s called an oracle to interact with real world, or off-chain, data. An oracle is a source of data that is being fed to a smart contract. For example, oracles provide data like the price of a stock, weather data like temperatures, or even the outcome of a sporting event.
Oracles are divided into two categories: software and hardware.
Software oracles relay information to smart contracts from the digital world outside the Ethereum blockchain. This information comes from online sources like websites, backend APIs, or even other smart contracts. Weather data, stock prices, flight schedules, sporting event results, etc are all common examples of information software oracles can provide.
Hardware oracles use equipment to inform smart contracts what’s happening in the physical world. Hardware oracles often utilize Internet of things, or IoT, devices. These devices track and verify real world data before sending it to the smart contract. Common examples include thermometers, supply chain RFID tags, GPS data, etc.
Oracles have their ups and downs
While oracles enable new possibilities for smart contracts, they also introduce potential risks. Smart contracts trust the information given to them by oracles. And, this data is often critical to how the smart contract functions. What would happen if an attacker hijacking the data feed? Or, what if the source of information simply malfunctions? Consequently, Developers have to take these risks into consideration when designing oracles. Decentralizing oracles across multiple sources of data helps mitigate some of these risks.
Want to learn more about how oracles interact with smart contracts in DeFi? Follow us on Twitter @DefiPulse or come chat us on Discord.