4

Lets consider an example of transaction lifecycle where a smart contract uses Oracle to get external data ETH/USD price feed that is changed in real-time.

Transaction is executed during mining, so it creates request to Chainlink oracles that return Price1. Is Price1 stored/cached somewhere on the blockchain?

Once block is mined, mining node sends it to other Ethereum nodes to validate.

Validating nodes also execute that smart contract. What will happen to subsequent calls to the Oracle to get the ETH/USD price? Would Oracle return "cached" response Price1 during block validation or we would get Price2. Does it mean if we get Price2 then block validation fails?

1 Answer 1

6

Short answer to your question: Yes, oracle responses are stored on-chain.

Long Answer: You can read more about how the requesting model works for chainlink, and how it gets data on-chain, but here is the gist, which will help answer this question. The simplest way to understand the architecture is by understanding how runlog initiators work.

  1. An on-chain contract makes a request to an off-chain Chainlink oracle by emitting an event to the blockchain log. This event has the instructions for what kind of data to get, and how to return it. The Chainlink nodes, are looking for these events.

  2. The node then follows the instructions, and in a transaction that the chainlink node makes, it then places the data on-chain, defined by the event. The event will specify which function the data will be run through.

You can look at the Chainlink price feeds page and see on-chain data. They even have a link to etherscan to show you where the contract and data is stored.

Your question is very good, because it is why having an oracle system built into a blockchain is not possible, if fetching external data was part of the validation process, no nodes would be able to reach a consensus. So instead, a Chainlink oracle places the data on-chain in a transaction, and then it goes through the same validation process that every other transaction goes through.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.