mcpField
C
chainlink-data-feeds

chainlink-data-feeds

github.com/hedera-devDevelopment28464 installsUpdated 8w ago
Repository

About chainlink-data-feeds

chainlink-data-feeds is an implementation and review guide for Hedera smart contract developers using Chainlink Data Feeds. It focuses on round validation, stale-data limits, and decimal normalization.

Key features

  1. 01Read prices through AggregatorV3Interface
  2. 02Check round completeness and update time
  3. 03Reject non-positive or stale prices
  4. 04Normalize prices to a target scale
  5. 05Use Hedera-specific feed addresses

Use cases

  1. 01Read price feeds in Hedera contracts
  2. 02Review price data completeness and freshness
  3. 03Align feed decimals with contract arithmetic

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/hedera-dev/hedera-skills --skill chainlink-data-feeds

After installing, type/chainlink-data-feedsin Claude Code to confirm it loaded.

Bundled filesreferences/examples.mdreferences/hedera-feeds.md

Details

From the project README

Chainlink Data Feeds (Hedera)

Push feed pattern: a Chainlink aggregator is updated off-chain; on-chain readers call latestRoundData() and must reject incomplete, non-positive, or stale rounds.

Chainlink DON → AggregatorV3Interface feed → consumer latestRoundData()

Consumers may wrap the feed behind a local interface; that is optional. Do not assume a project-specific adapter name.

Quick Reference

PieceRole
AggregatorV3InterfacelatestRoundData() + decimals()
Round completenessansweredInRound >= roundId and updatedAt != 0
Priceanswer > 0 (feeds are typically signed int256)
FreshnessCompare block.timestamp - updatedAt to a max staleness
ScaleNormalize feed decimals to the consumer’s scale (often 18)
Pair identityPrefer canonical uppercase symbols (HBAR, USD) if you hash pair keys

Hedera chain IDs: testnet 296, mainnet 295.

See references/hedera-feeds.md for where to source Hedera feed addresses. See references/examples.md for read and normalize sketches.

Critical: Completeness Then Staleness

Never return a price from a missing or unfinished round. Revert when:

ConditionWhy
answeredInRound < roundIdAggregator has not finished this round
updatedAt == 0No successful update
answer <= 0Invalid / non-positive price
block.timestamp - updatedAt > maxStalenessStale for this consumer
(uint80 roundId, int256 answer,, uint256 updatedAt, uint80 answeredInRound) =
    feed.latestRoundData();

if (answeredInRound < roundId || updatedAt == 0) revert IncompleteRound();
if (answer <= 0) revert InvalidPrice();
if (block.timestamp - updatedAt > maxStaleness) revert StalePrice(updatedAt, maxStaleness);

Critical: Hedera Feeds, Not Ethereum Addresses

Do not copy Ethereum mainnet aggregator addresses onto Hedera. Look up Hedera-specific Data Feed addresses for chain 295 / 296 and re-check docs before mainnet.

Pair maps (if you use them) should be constructor-only unless the project explicitly supports post-deploy updates.

Decimal Normalization

feed.decimals() is often 8. Convert to the scale your app uses before arithmetic:

uint256 price = normalizeToScale(uint256(answer), feed.decimals(), /* target */ 18);

Keep conversion rounding explicit (usually round down). Do not mix raw aggregator units with 18-decimal amounts.

Checklist

When implementing or reviewing Chainlink reads on Hedera:

  • Feed address taken from Hedera Data Feeds docs (not Ethereum)
  • latestRoundData completeness checks before using answer
  • Non-positive prices revert
  • Staleness bound is enforced
  • Decimals normalized to the consumer scale
  • Chain ID is 295 or 296 (or the project’s documented Hedera network)

References

Comments

Markdown supported