I'm currently developing a Solidity smart contract named FundMe, where users can contribute funds in Ether (ETH). I'm aiming to enforce a minimum funding requirement of $50 USD equivalent. However, I'm encountering issues with the implementation, particularly with the conversion rate calculation and the enforcement of the minimum value.

Here's the relevant portion of my contract:

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@chainlink/[email protected]/src/v0.8/shared/interfaces/AggregatorV3Interface.sol";

contract FundMe {
    uint public minimumUsd = 50 * 1e18;
    function fund() public payable {
        require(msg.value > 0, "No Value Sent");
        require(msg.value >= minimumUsd, "Didn't Send Enough");

        // Further contract logic...

    function getPrice() public view returns(uint) {
        AggregatorV3Interface priceFeed = AggregatorV3Interface(0x694AA1769357215DE4FAC081bf1f309aDC325306);
        (,int256 price,,,) = priceFeed.latestRoundData();
        return uint(price * 1e10);

    function getConversionRate(uint ethAmount) public view returns(uint) {
        uint ethPrice = getPrice();
        uint ethAmountInUsd = (ethPrice * ethAmount) / 1e18;

        return ethAmountInUsd;

    // Withdraw function implementation omitted for brevity

However, when I attempt to send a transaction with an amount of 0.02 ETH, which according to my calculations equals approximately $57.72, I receive the error message "Didn't Send Enough". Similarly, when inspecting the minimumUsd variable using a function call, it displays a value of 50 ETH equivalent to $143,875.00, which seems incorrect.

Could someone please assist me in correcting the conversion rate calculation and ensuring that the minimum funding requirement is accurately enforced in USD? Additionally, any guidance on how to correctly set the minimum value to $50 USD equivalent would be greatly appreciated.


1 Answer 1


Your implementation is correct.

In your fund() function, you just need to replace this statement:

require(msg.value >= minimumUsd, "Didn't Send Enough");

With this:

require(getConversionRate(msg.value) >= minimumUsd, "Didn't Send Enough");
  • I think it would be require(getConversionRate(msg.value) >= minimumUsd, "Didn't Send Enough"); Commented May 2 at 4:53
  • @ZartajAfser, both mean the same thing. Commented May 2 at 5:36
  • As, whatever function we call using msg.value, it’ll be passed as first argument to it by default, provided that the function is having the first argument of type uint256. Commented May 2 at 5:38
  • Can you try doing this once Commented May 2 at 7:24
  • 1
    Exactly, I know it works with libraries. Thanks for editing. Commented May 2 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.