Skip to content

Instantly share code, notes, and snippets.

@renso3x
Last active March 11, 2026 10:30
Show Gist options
  • Select an option

  • Save renso3x/af346ef70adf4a562e39ebcb1a50528f to your computer and use it in GitHub Desktop.

Select an option

Save renso3x/af346ef70adf4a562e39ebcb1a50528f to your computer and use it in GitHub Desktop.
// 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