Hi I have a function that returns a uint256.
function getLatestPrice() public view returns (int) {
(
/*uint80 roundID*/,
int price,
/*uint startedAt*/,
/*uint timeStamp*/,
/*uint80 answeredInRound*/
) = priceFeed.latestRoundData();
return price;
}
I want to compare this amount to msg.value, but the editor says >= is not compatible with uint/int256?
require(msg.value >= getLatestPrice(), "insufficient number");
TypeError: Operator >= not compatible with types uint256 and int256
How can I require msg.value to be greater than or equal to my uint256?
Thank you,
Best Answer
You need to cast the type, given that this is a price from a pricefeed you can do that without worrying but be mindful in future contracts. The following should work: