##集成ChainLink Price Feeds
安装ChainLink依赖
yarn add --dev @chainlink/contracts
1.使用本地测试环境
使用本地环境就没办法调,真实链上的ChainLink Price Feeds,自己要去发掘开源的Feeds协议,ChainLink提供的Feeds 协议在@chainlink/contracts此库类基本都能找到。或者自己实现个投喂协议,在本地进行部署调试。
2.使用测试环境,以Selopia为例
去ChainLink官网进行Feeds地址的获取。如下图,是获取Price Feeds的合约地址,只需获取适合你的Pair合于地址即可,下方也提供了代码示例。
constructor(address priceFeedAddress) {
/*
*用合约地址来实现一个合约接口类型的对象
*priceFeedAddress就是ChainLink的价格投喂地址
***/
s_priceFeed = AggregatorV3Interface(priceFeedAdd