SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "./Lending.sol";
contract Treasury is Lending{

Lending lending = new Lending();
bool internal checkEligibility;
uint public eligibleAmt;
event receiveFundEvent(
uint  indexed  amount);
event withdrawEvent(
address  indexed borrower,
uint indexed amount);
uint totalFund = 0;

function receiveFund() payable public  {
uint amt = lending.calculateInterest();
require(msg.value==amt,"Repay The correct Amount");
totalFund = msg.value + totalFund;
emit receiveFundEvent(msg.value);}

function withdraw (uint  _collateralVal) public {
eligibleAmt = super.requestForLoan( _collateralVal);
   totalFund = totalFund -eligibleAmt;
   emit withdrawEvent(msg.sender,eligibleAmt);}

   function fakeFund() public payable {}


Error: revert The transaction has been reverted to the initial state. Note: The called function should be payable if you send value and the value you send should be less than your current balance. Debug the transaction to get more information.

1 Answer 1


Add the payable modifier in the withdraw function like below:

function withdraw(unit _collateralVal) public payable {
   // Your code...

More information about payable keyword: https://solidity-fr.readthedocs.io/fr/latest/cheatsheet.html#modifiers

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.