Last active
March 11, 2026 10:30
-
-
Save renso3x/af346ef70adf4a562e39ebcb1a50528f to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.31; | |
| import "@chainlink/contracts/src/v0.8/interfaces/AggregatorV3Interface.sol"; | |
| contract ConvertETHtoPHP { | |
| AggregatorV3Interface internal priceFeed; | |
| uint256 public constant USD_TO_PHP_RATE = 56; | |
| constructor() { | |
| priceFeed = AggregatorV3Interface( | |
| 0x694AA1769357215DE4FAC081bf1f309aDC325306 | |
| ); | |
| } | |
| function convertEthToPhp(uint256 ethAmountWei) public view returns (uint256) { | |
| (, int256 ethUsdPrice, , ,) = priceFeed.latestRoundData(); | |
| require(ethUsdPrice > 0, "Invalid price"); | |
| uint256 ethUsd = (ethAmountWei * uint256(ethUsdPrice)) / 1e18; | |
| uint256 ethToPhp = (ethUsd * USD_TO_PHP_RATE) / 1e8; | |
| return ethToPhp; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment