Awarded once after a correct answer.
Validate a price before using it
Useful first : Chainlink and the oracle problem · Ethereum accounts and transactions
Reading path · 13 / 41 · Intermediate
A price feed needs checks of asset, network, decimal scale and freshness.
The essentials
Data Feeds aggregate observations and expose results to applications, commonly through a proxy pointing to an aggregator. This separation can support upgrades without changing the address consumed by an application. It also means that administrative arrangements matter.
How it works
Publication may depend on a deviation threshold or heartbeat interval. A feed is not necessarily a tick-by-tick price stream. Consumers should check the exact asset, network, decimal scale and timestamp, and define what happens when data becomes stale or unsuitable.
What to watch
For example, treating an eight-decimal answer as an eighteen-decimal answer creates a severe valuation error even when observations are accurate. Multiple operators do not eliminate correlated data failures. On a Layer 2, applications may also need to account for sequencer downtime and a grace period before resuming sensitive actions.
Understand the details
A price feed is an interface to a specific reported value, not a universal market price. Integrations must confirm the network, feed address, base and quote assets, decimal scale and update time. Updates may depend on a time interval or a deviation condition, depending on the feed. A transaction can execute between two updates.
Boundaries and common mistakes
Freshness limits should match the application’s risk and feed configuration. Rejecting every small delay can stop a service unnecessarily; accepting arbitrarily old values can misprice collateral. Some L2 integrations also need to consider sequencer availability and recovery behavior. A fallback must have its own validation rules.
The mechanism at a glance
- 01Check network and pair
- 02Normalize decimals
- 03Check time and status
- 04Use or reject value
Read these as connected concepts, not necessarily consecutive steps.
Read the explanation
A price feed is an interface to a specific reported value, not a universal market price. Integrations must confirm the network, feed address, base and quote assets, decimal scale and update time. Updates may depend on a time interval or a deviation condition, depending on the feed. A transaction can execute between two updates.
Put the mechanism into context
A fictional feed returns 25000000000 with eight decimals. Its timestamp is two hours old, while this exercise’s application accepts at most thirty minutes. Prepare a validation table before calculating any collateral value. These are example limits, not recommended production settings.
Apply it in the workshop →What this mechanism does not guarantee
Freshness limits should match the application’s risk and feed configuration. Rejecting every small delay can stop a service unnecessarily; accepting arbitrarily old values can misprice collateral. Some L2 integrations also need to consider sequencer availability and recovery behavior. A fallback must have its own validation rules.
The distinction that changes the analysis
A raw answer of 250,000,000 with eight decimals means 2.5 quote units, not 250 million. A consumer also needs the quoted pair and freshness. Correct arithmetic cannot compensate for using the wrong pair or an outdated report.
Explain it yourself
Revisit the case above. Name what is established, what remains to be checked and the evidence needed to conclude. A strong answer addresses both sides of the diagram.
Apply the lesson to a case
A fictional feed returns 25000000000 with eight decimals. Its timestamp is two hours old, while this exercise’s application accepts at most thirty minutes. Prepare a validation table before calculating any collateral value. These are example limits, not recommended production settings.
The value is 250 quote units, but it fails the stated freshness rule. Correct decimal conversion does not rescue stale data. Record a controlled failure or a separately validated fallback instead of silently treating the number as current.
From a market price to a contract
Sources
Observations originate from selected markets and data providers. Market quality affects input quality.
Check your understanding
2 units of its quoted denomination, not 200 million. The denomination and update time still need checking.
Prepare a correction note
Describe the passage and the proposed correction. This creates a local note for you to share; it sends nothing. Do not include personal or confidential information.