Skip to content

Instantly share code, notes, and snippets.

@miguelmota
Last active January 13, 2020 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miguelmota/696f8a2f47f6986ac3b307cdc0d9fbd5 to your computer and use it in GitHub Desktop.
Save miguelmota/696f8a2f47f6986ac3b307cdc0d9fbd5 to your computer and use it in GitHub Desktop.
Solidity example of how to read USD price of ETH onchain using MakerDAO medianizer price feed contract
pragma solidity >=0.4.22 <0.6.0;
interface IMakerDaoMedianizer {
function read() external view returns (bytes32);
}
contract Example {
IMakerDaoMedianizer makerDaoMedianizer;
constructor(address _makerDaoMedianizer) public {
makerDaoMedianizer = IMakerDaoMedianizer(_makerDaoMedianizer);
}
function usdPrice() external view returns (bytes32) {
return makerDaoMedianizer.read();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment