Please see the following code:
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.1; contract Crowdfund { uint fundLimit = 3 ether; bool contractOpen = true; function donate() external payable { require(contractOpen, "Contract has stopped recieving funds"); require(address(this).balance + msg.value <= fundLimit, "Can't send specified amount"); } } If I try to send 2 (or) 3 ether then the transaction is failing;
The transaction has been reverted to the initial state. Reason provided by the contract: "Can't send specified amount". Debug the transaction to get more information. Ideally, the transaction of 2 (or) 3 ether should not fail because fundLimit is set to 3 ether. And initially, the contract balance is 0.
I am unable to know the reason for this.