chainlink-data-feeds
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseChainlink Data Feeds (Hedera)
Chainlink Data Feeds(Hedera)
Push feed pattern: a Chainlink aggregator is updated off-chain; on-chain readers call and must reject incomplete, non-positive, or stale rounds.
latestRoundData()text
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.
推送式喂价模式: Chainlink聚合器在链下更新;链上调用方调用,且必须拒绝不完整、非正或过时的轮次数据。
latestRoundData()text
Chainlink DON → AggregatorV3Interface feed → consumer latestRoundData()调用方可以将喂价封装在本地接口后;这是可选操作。请勿假定存在项目特定的适配器名称。
Quick Reference
快速参考
| Piece | Role |
|---|---|
| |
| Round completeness | |
| Price | |
| Freshness | Compare |
| Scale | Normalize feed decimals to the consumer’s scale (often 18) |
| Pair identity | Prefer canonical uppercase symbols ( |
Hedera chain IDs: testnet , mainnet .
296295See references/hedera-feeds.md for where to source Hedera feed addresses. See references/examples.md for read and normalize sketches.
| 项 | 作用 |
|---|---|
| 提供 |
| 轮次完整性 | |
| 价格 | |
| 新鲜度 | 将 |
| 数值刻度 | 将喂价小数位数标准化为调用方的刻度(通常为18位) |
| 交易对标识 | 若对交易对键做哈希,优先使用标准大写符号( |
Hedera链ID: 测试网,主网。
296295获取Hedera喂价地址的方式请参考references/hedera-feeds.md。读取与标准化示例请参考references/examples.md。
Critical: Completeness Then Staleness
关键注意点:先校验完整性,再校验时效性
Never return a price from a missing or unfinished round. Revert when:
| Condition | Why |
|---|---|
| Aggregator has not finished this round |
| No successful update |
| Invalid / non-positive price |
| Stale for this consumer |
solidity
(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);切勿返回缺失或未完成轮次的价格。出现以下情况时应回滚交易:
| 条件 | 原因 |
|---|---|
| 聚合器尚未完成本轮更新 |
| 无成功更新记录 |
| 价格无效/非正 |
| 对该调用方而言数据已过时 |
solidity
(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
关键注意点:使用Hedera专属喂价,而非以太坊地址
Do not copy Ethereum mainnet aggregator addresses onto Hedera. Look up Hedera-specific Data Feed addresses for chain / and re-check docs before mainnet.
295296Pair maps (if you use them) should be constructor-only unless the project explicitly supports post-deploy updates.
切勿将以太坊主网的聚合器地址复用到Hedera上。请查询链ID/对应的Hedera专属Data Feed地址,并在主网上线前重新核对文档。
295296交易对映射(若使用)应仅在构造函数中初始化,除非项目明确支持部署后更新。
Decimal Normalization
小数位数标准化
feed.decimals()solidity
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.
feed.decimals()solidity
uint256 price = normalizeToScale(uint256(answer), feed.decimals(), /* target */ 18);转换时需明确舍入规则(通常向下取整)。请勿将原始聚合器单位与18位小数的金额混用。
Checklist
检查清单
When implementing or reviewing Chainlink reads on Hedera:
- Feed address taken from Hedera Data Feeds docs (not Ethereum)
- completeness checks before using
latestRoundDataanswer - Non-positive prices revert
- Staleness bound is enforced
- Decimals normalized to the consumer scale
- Chain ID is or
295(or the project’s documented Hedera network)296
在Hedera上实现或审核Chainlink喂价读取逻辑时:
- 喂价地址取自Hedera Data Feeds文档(而非以太坊)
- 使用前已完成
answer的完整性校验latestRoundData - 非正价格会触发回滚
- 已强制执行时效性限制
- 小数位数已标准化为调用方的刻度
- 链ID为或
295(或项目文档规定的Hedera网络)296
References
参考资料
- references/examples.md — and normalize sketches
latestRoundData - references/hedera-feeds.md — where to source Hedera aggregator addresses
- Chainlink Data Feeds
- Hedera price feed addresses
- references/examples.md — 与标准化示例
latestRoundData - references/hedera-feeds.md — Hedera聚合器地址获取方式
- Chainlink Data Feeds
- Hedera价格喂价地址