Skip to content

Instantly share code, notes, and snippets.

@Ernesto-tha-great
Created June 17, 2022 14:51
Show Gist options
  • Save Ernesto-tha-great/20fad14d07270ae69f486d1be3ac170f to your computer and use it in GitHub Desktop.
Save Ernesto-tha-great/20fad14d07270ae69f486d1be3ac170f to your computer and use it in GitHub Desktop.
//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