How do Smart Contracts Get Real-World Data?

How do Smart Contracts Get Real-World Data?

An introduction to Oracles in Blockchain

Suppose you and your friend made a bet on who will win the next Super Bowl. You don't really trust each other with bets, so you decided to seal the deal with a "wagering smart contract". However, for your smart contract to determine the winner, it needs to know who actually won the Super Bowl, but that information is not in the blockchain.

Oracles to the rescue

This is where oracles come in. They provide smart contracts with off-chain data. They are not part of the blockchain. They are third-party agents that submit real-world occurrences to be used by smart contracts and trigger smart contract executions when certain conditions are met.

Now with the help of an oracle, the wagering smart contract will be able to know who won the Super Bowl and automatically transfer the money to the winner's wallet.

But there is a downside...

oracle meme

There is an obvious flaw with oracles. They are not part of the blockchain, so the rules that keep the blockchain secure do not apply. Any inaccurate data from an oracle could trigger an unwanted smart contract execution.

Suppose your friend decided to make the odds 100% in his favor. He hacked the official Super Bowl site and changed the information about the winning team. Then the oracle, which gets its information from the official site, would report to the smart contract this false information, triggering a money transfer to your friend's wallet.

This is what is known as "the oracle problem". Even if a smart contract is secured and well audited, if the oracle is compromised, the whole contract will be affected.

Summary

Oracles play an essential role in making smart contracts viable for various use cases. They act as a bridge between blockchain and the real world. But they could also serve as a weak entry point for hackers to exploit. So they need to be trustworthy and reliable.