0

This script gives me some random like a number and not real eth price? the price that is outputting is 38598000000?!

  AggregatorInterface internal ref;
  // For ETH-USD on ropsten, input the address:
  // 0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507
  address _aggregator = 0x8468b2bDCE073A157E560AA4D9CcF6dB1DB98507;
  string toni;
  constructor() public {
    
    ref = AggregatorInterface(_aggregator);
    
  }
    int256 price;

  function getLatestAnswer() public view returns (int256) {
    return ref.latestAnswer();
  }    

1 Answer 1

2

I think Chainlink's Ropsten price feed contract is no longer in use.

Ropsten doesn't appear to be one of their supported test networks - I would suggest using Kovan or Rinkeby. (The examples in the docs all use Kovan.)

Kovan:

Rinkeby:

6
  • is there any chance i can get just 1753
    – Toni Dev
    Mar 17, 2021 at 12:36
  • can i get frist 4 numbers
    – Toni Dev
    Mar 17, 2021 at 12:42
  • Why do you only want 4 digits? To display to the user? Mar 17, 2021 at 13:16
  • I would recommend keeping all the digits so that you don't lose precision. Then on your front end you could divide by 1 x 10^8 and use .toFixed(2) (if you're using Javascript). Mar 17, 2021 at 13:20
  • Im short on time can i only display first 4 digits because user needs to give input nad it will not give to system 175311231231 it will give 1753 only
    – Toni Dev
    Mar 17, 2021 at 13:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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