Created
June 17, 2022 14:51
-
-
Save Ernesto-tha-great/20fad14d07270ae69f486d1be3ac170f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//SPDX-License-Identifier: MIT | |
pragma solidity ^0.8.0; | |
// Importing OpenZeppelin's SafeMath Implementation | |
import "@openzeppelin/contracts/utils/math/SafeMath.sol"; | |
import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; | |
import './Project.sol'; | |
contract CrowdFund { | |
// SafeMath for safe integer operations | |
using SafeMath for uint256; | |
// List of all the projects | |
Project[] public projects; | |
// event for when new project starts | |
event ProjectStarted( | |
address contractAddress, | |
address projectCreator, | |
string title, | |
string description, | |
string imageLink, | |
uint256 fundRaisingDeadline, | |
uint256 goalAmount | |
); | |
function startProject( | |
IERC20 cUSDToken, | |
string calldata title, | |
string calldata description, | |
string calldata imageLink, | |
uint durationInDays, | |
uint amountToRaise | |
) external { | |
uint raiseUntil = block.timestamp.add(durationInDays.mul(1 days)); | |
Project newProject = new Project(cUSDToken, payable(msg.sender), title, description, imageLink, raiseUntil, amountToRaise); | |
projects.push(newProject); | |
emit ProjectStarted( | |
address(newProject), | |
msg.sender, | |
title, | |
description, | |
imageLink, | |
raiseUntil, | |
amountToRaise | |
); | |
} | |
function returnProjects() external view returns(Project[] memory) { | |
return projects; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment