'Is there a way to convert a specified amount of gwei to ETH/USD in a contract without using formulas everytime?
function getConversionRate(uint256 ethAmount) public view returns (uint256) {
uint256 ethPrice = getPrice();
uint256 ethAmountInUsd = (ethPrice * ethAmount) / 1000000000000000000;
return ethAmountInUsd;
This is how I currently am converting gwei to ETH/USD, but if I increased my specified amount of gwei in my function in Remix IDE. The formula would have to be changed manually. Is there a way to automate this? OR is there an API that I could import that will do this for me if I made a function that called on that?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
