0

I have tried to use the chainlink and contract address of NFT to fetch the price but I am not sure where I am wrong

pragma solidity ^0.8.7;

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

contract PriceConsumerV3 {

AggregatorV3Interface internal priceFeed;


constructor() {
    priceFeed = AggregatorV3Interface(0x495f947276749Ce646f68AC8c248420045cb7b5e);
}

/**
 * Returns the latest price
 */
function getLatestPrice() public view returns (int) {
    (
        /*uint80 roundID*/,
        int price,
        /*uint startedAt*/,
        /*uint timeStamp*/,
        /*uint80 answeredInRound*/
    ) = priceFeed.latestRoundData();
    return price;
}

}

1 Answer 1

1

As I understand it you are attempting to return the price of an NFT using price feeds.

priceFeed = AggregatorV3Interface(0x495f947276749Ce646f68AC8c248420045cb7b5e); This interface needs to use the address of an interface contract for pricefeeds. Example: https://etherscan.io/address/0x5f4eC3Df9cbd43714FE2740f5E3616155c5b8419#code

A further list and explanation can be found in the Chainlink Docs.

It might be possible to return prices based on OpenSea's API using Any API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.