Last active
January 13, 2020 01:17
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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