You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Chainlink获取KCC链的价格喂价数据

KCC链Chainlink价格喂价合约地址说明

可用喂价地址汇总

你现有代码的调用逻辑完全兼容KCC链的Chainlink喂价合约,无需修改调用逻辑,仅需替换构造函数中的喂价合约地址即可。

KCC主网(主流交易对)

  • BTC/USD:0x593c50c4Cf3b85954C72A250a331d28e50D3F71D
  • ETH/USD:0x639Fe65495536B3fB51762c10bC71e603C94057e
  • USDT/USD:0xbFbEafD01F5eD21086e4F1aBc2d35f9dC804b827
  • KCS/USD:0x370A36664124bF960b451E9958B8Bc6B8D7845f6

KCC测试网(主流交易对)

  • BTC/USD:0x2DfE64b03e755952Fb2147902F527a87a9764aA8
  • ETH/USD:0x98c4215622B740052d43a4e1Ae729D5E5D28e74F
  • USDT/USD:0xA13d1993Ff4F31B63Ee79D1726f207295fA835d5
  • KCS/USD:0x47eF8726c1158289a80d42b0E0621eF29aF3742e

适配后代码示例

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol";

contract PriceTest {
    AggregatorV3Interface internal priceFeed;
    
    constructor()  { 
        // priceFeed = AggregatorV3Interface(0x0567F2323251f0Aab15c8dFb1967E4e8A7D42aeE); // BSC主网
        // priceFeed = AggregatorV3Interface(0xcf0f51ca2cDAecb464eeE4227f5295F2384F84ED); // Rinkeby测试网
        // priceFeed = AggregatorV3Interface(0xd0D5e3DB44DE05E9F294BB0a3bEEaF030DE24Ada); // Mumbai测试网
        priceFeed = AggregatorV3Interface(0x370A36664124bF960b451E9958B8Bc6B8D7845f6); // KCC主网 KCS/USD 示例,按需替换
        // priceFeed = AggregatorV3Interface(0x47eF8726c1158289a80d42b0E0621eF29aF3742e); // KCC测试网 KCS/USD 示例,按需替换
    }
 
   function getLatestPrice() public view returns (uint256) {
        (,int price,,,) = priceFeed.latestRoundData();
        return uint256(price);
    }       
}

注意:所有喂价返回值精度为8位小数,你现有代码的返回逻辑可直接复用,无需额外调整精度处理。


内容的提问来源于stack exchange,提问作者Yusnee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.27 06:06:07