Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add WithrawDAoReward() function in projectfund.sol #6

Open
AnandK-2024 opened this issue Nov 14, 2022 · 0 comments
Open

add WithrawDAoReward() function in projectfund.sol #6

AnandK-2024 opened this issue Nov 14, 2022 · 0 comments
Assignees

Comments

@AnandK-2024
Copy link
Member

import "contracts/Daomember.sol";
// reward money of DAO
uint256 public DAOMoney;

// DAOMember contract address
DAOMember dAOMember;

// contract address of DAOMember contract

      constructor(uint256 _enteranceFee, uint256 _daoPercentage , DAOMember DAOMemberCOntractAdd) {
              dAOMember=DAOMember(DAOMemberCOntractAdd);
              lastTimeStamp = block.timestamp;
              daoPercentage = _daoPercentage;
              enteranceFee = _enteranceFee;
          }

// transfer all reward money after successfull funding of project to DAOMember contract

          function WithrawDAoReward() internal onlyOwner{
                  require(DAOMoney>0);
                  (bool success,)=payable(dAOMember).call{value:DAOMoney}("");
                  require(success,"tansfer failed");
              }

update performUpkeep function

function performUpkeep(bytes calldata performData) external override {
(bool upkeepNeeded, ) = checkUpkeep("");
if (!upkeepNeeded) {
revert FundProject__UpkeepNeeded();
}

    uint256 ProjectId = uint256(bytes32(performData));
    _isFunding[ProjectId] = false;
    _isApporovedByDao[ProjectId] = false;

    if (projectFunds[ProjectId] > projectFundingGoalAmount[ProjectId]) {
        _ProjectFundingStatus[ProjectId] = ProjectFundingStatus.SUCCESS;
        uint256 fundsToSent = (projectFunds[ProjectId] *
            (100 - daoPercentage)) / 100;

DAOMoney+=projectFunds[ProjectId]-fundsToSent;
projectFunds[ProjectId] = 0;

        (bool success, ) = (projectOwnerAddress[ProjectId]).call{
            value: fundsToSent
        }("");
        if (!success) {
            revert FundProject__TransferFailed(projectFunds[ProjectId]);
        }

        emit projectSuccessfullyFunded(ProjectId);
    } else {
        _ProjectFundingStatus[ProjectId] = ProjectFundingStatus.FAILED;
        emit projectFundingFailed(ProjectId);
    }
}
@AnandK-2024 AnandK-2024 self-assigned this Nov 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant