Before we begin, let's be clear: this is an intermediate lesson, and it requires a bit of JavaScript and Solidity knowledge.
If you're new to Solidity, it's highly recommended that you go over the first lessons before starting this one.
If you are not comfortable with JavaScript, consider going through a tutorial elsewhere before starting this lesson.
Now, let's suppose you're building a DeFi dapp, and want to give your users the ability to withdraw ETH worth a certain amount of USD. To fulfill this request, your smart contract (for simplicity's sake we'll call it the "caller contract" from here onwards) must know how much one Ether is worth.
And here's the thing: a JavaScript application can easily fetch this kind of information, making requests to the Binance public API (or any other service that publicly provides a price feed). But, a smart contract can't directly access data from the outside world. Instead, it relies on an oracle to pull the data.
Phew! At first glance, this sounds like a complicated thing to do 🤯. But, by taking it one step at a time, we'll set you on a smooth sail.
Now I know that a picture is sometimes worth a thousand words, so here's a simple diagram that explains how this works:
