1

I have followed the steps in the Chainlink docs Beginner's tutorial, as described here:

https://docs.chain.link/docs/beginners-tutorial/

Everything appears to work until the last paragraph:

Click "getLatestPrice", and voilà! The latest price appears just underneath the button. We have successfully deployed a smart contract, which uses Chainlink price feeds, to the Kovan Ethereum testnet!

Instead, when I click "getLatestPrice", Remix's output window displays:

call to PriceConsumerV3.getLatestPrice call to

PriceConsumerV3.getLatestPrice errored: [object Object]

Does anyone know what I'm doing wrong?

Thanks!

1
  • Same problem here .cannot retrieve any data Jun 12 at 9:53
2

This appears to be a Remix-specific error. I copied what you did, deployed it on Kovan via Remix, and got the same error. Then, I tried to use the Etherscan interface to read that data after verifying the contract, and everything worked just fine.

Contract code: https://kovan.etherscan.io/address/0x31C09Eaf8bA8D8FC9Ab044896F870cD737617FF6#readContract

Flattened Solidity code for Etherscan verification:

pragma solidity ^0.6.7;

// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0;

interface AggregatorV3Interface {

  function decimals() external view returns (uint8);
  function description() external view returns (string memory);
  function version() external view returns (uint256);

  // getRoundData and latestRoundData should both raise "No data present"
  // if they do not have data to report, instead of returning unset values
  // which could be misinterpreted as actual reported values.
  function getRoundData(uint80 _roundId)
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );
  function latestRoundData()
    external
    view
    returns (
      uint80 roundId,
      int256 answer,
      uint256 startedAt,
      uint256 updatedAt,
      uint80 answeredInRound
    );

}


contract PriceConsumerV3 {

    AggregatorV3Interface internal priceFeed;

    /**
     * Network: Kovan
     * Aggregator: ETH/USD
     * Address: 0x9326BFA02ADD2366b30bacB125260Af641031331
     */
    constructor() public {
        priceFeed = AggregatorV3Interface(0x9326BFA02ADD2366b30bacB125260Af641031331);
    }

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

Update: I submitted this as an issue to Remix https://github.com/ethereum/remix-project/issues/1282

1
  • Thanks for the help! Jun 12 at 11:24
1

you are getting the error [object Object] because you are using javascript VM provider, it cannot interact with other contracts on kovan testnet, it can only interact with other contacts deployed using remix in the same browser.

Switch web3 provider from Javascript VM to Injected Web3from left panel while deploying , and keep your metamask connected to kovan

2
  • I also thought so at first, but deploying to Kovan on Remix and querying on Remix didn't fix the problem. I had to query via Etherscan after verifying the deployed contract to get a meaningful return. Jun 12 at 7:57
  • But no doubt, this contract will not work on any network other than Kovan. Jun 12 at 7:58

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.