-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 75fe8d7
Showing
15 changed files
with
38,244 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# Celo Marketplace Dapp | ||
|
||
 | ||
|
||
## Description | ||
|
||
This is a GoFundMe Page built on the celo Blockchain: | ||
|
||
- Recieves Contribution from Well Wishers; | ||
- Once the Amount To Be Funded is reached, The Contribute Button is De-activated; | ||
- Tracks the Number of People Who have Contributed; | ||
- You can contibute Multiple times but the funders List is only updated Once; | ||
- Keeps track of the Balance remaining to be contributed; | ||
|
||
The concept here is the ability to be able to keep track of the funders and once the target has been reached, the fundme won't be able to recieve any more funds. Also, the Contribute button is taken down. The Novelty is the choice for a person to be able to fund a project with any amount. nothing is too little. | ||
|
||
## Smart Contract Functionality Added | ||
|
||
- Included a Mapping with in a struct | ||
- Included an Array within a Struct | ||
- Keeping Track of Funders | ||
- Included Modifiers to Check for where or Not the Project Has been Funded | ||
- Storage vs Memory when Using Structs, Where and When | ||
|
||
## Front End Functionality Added | ||
|
||
- Included a Modal for the Input of the amount You Intead to contribute | ||
- Conditional Display of the Contribute Button Depending on the Balance remaining | ||
- A Tag to show projects that are being Funded Against those that Are already Funded | ||
- Display Number of Funders | ||
- Center align of the GoFundMe Button | ||
|
||
## TODO | ||
|
||
- beautify the layout | ||
- create admin pages | ||
- include an option for a person to live a note. | ||
|
||
## Live Demo | ||
|
||
[GoFundMe](https://eliashezron.github.io//) | ||
|
||
## Usage | ||
|
||
### Requirements | ||
|
||
1. Install the Metamask wallet | ||
2. Create a wallet. | ||
3. Go to [https://celo.org/developers/faucet](https://celo.org/developers/faucet) and get tokens for the alfajores testnet. | ||
4. Switch to the alfajores testnet in the Metamask. | ||
|
||
### Test | ||
|
||
1. connect your celo Wallet on the Alfajores Testnet | ||
2. Create a FundMe, Prefarably you use an Imageurl on ipfs | ||
3. Fund a Project | ||
|
||
## Project Setup | ||
|
||
### Install | ||
|
||
``` | ||
npm install | ||
``` | ||
|
||
### Start | ||
|
||
``` | ||
npm run dev | ||
``` | ||
|
||
### Build | ||
|
||
``` | ||
npm run build | ||
``` |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity >=0.8.0 <0.9.0; | ||
|
||
interface IERC20Token { | ||
function transfer(address, uint256) external returns (bool); | ||
|
||
function approve(address, uint256) external returns (bool); | ||
|
||
function transferFrom( | ||
address, | ||
address, | ||
uint256 | ||
) external returns (bool); | ||
|
||
function totalSupply() external view returns (uint256); | ||
|
||
function balanceOf(address) external view returns (uint256); | ||
|
||
function allowance(address, address) external view returns (uint256); | ||
|
||
event Transfer(address indexed from, address indexed to, uint256 value); | ||
event Approval( | ||
address indexed owner, | ||
address indexed spender, | ||
uint256 value | ||
); | ||
} | ||
|
||
contract GoFundMeOnCelo { | ||
uint256 internal listLength = 0; | ||
|
||
address internal cUsdTokenAddress = | ||
0x874069Fa1Eb16D44d622F2e0Ca25eeA172369bC1; | ||
struct GoFundMe { | ||
address payable owner; | ||
string name; | ||
string image; | ||
string description; | ||
string location; | ||
uint256 amount; | ||
uint256 balance; | ||
address[] funders; | ||
bool funded; | ||
mapping(address => bool) uniqueFunder; | ||
} | ||
// GoFundMe[] public goFundMes; | ||
mapping(uint256 => GoFundMe) goFundMes; | ||
|
||
function createFundMe( | ||
string memory _name, | ||
string memory _image, | ||
string memory _description, | ||
string memory _location, | ||
uint256 _amount | ||
) public { | ||
bool _funded = false; | ||
uint256 _balance = _amount; | ||
GoFundMe storage newGoFundMe = goFundMes[listLength]; | ||
newGoFundMe.owner = payable(msg.sender); | ||
newGoFundMe.name = _name; | ||
newGoFundMe.image = _image; | ||
newGoFundMe.description = _description; | ||
newGoFundMe.location = _location; | ||
newGoFundMe.amount = _amount; | ||
newGoFundMe.balance = _balance; | ||
newGoFundMe.funded = _funded; | ||
listLength++; | ||
} | ||
|
||
function readFundMe(uint256 _index) | ||
public | ||
view | ||
returns ( | ||
address payable, | ||
string memory, | ||
string memory, | ||
string memory, | ||
string memory, | ||
uint256, | ||
bool | ||
) | ||
{ | ||
return ( | ||
goFundMes[_index].owner, | ||
goFundMes[_index].name, | ||
goFundMes[_index].image, | ||
goFundMes[_index].description, | ||
goFundMes[_index].location, | ||
goFundMes[_index].balance, | ||
goFundMes[_index].funded | ||
); | ||
} | ||
|
||
modifier notYetFunded(uint256 _index) { | ||
GoFundMe storage goFundMe = goFundMes[_index]; | ||
require(!goFundMe.funded, "Already funded"); | ||
_; | ||
} | ||
|
||
function fund(uint256 _index, uint256 _amount) | ||
public | ||
payable | ||
notYetFunded(_index) | ||
{ | ||
require( | ||
IERC20Token(cUsdTokenAddress).transferFrom( | ||
msg.sender, | ||
goFundMes[_index].owner, | ||
_amount | ||
), | ||
"Transfer failed." | ||
); | ||
GoFundMe storage goFundMe = goFundMes[_index]; | ||
goFundMe.balance -= _amount; | ||
if (goFundMe.balance == 0) { | ||
goFundMe.funded = true; | ||
} | ||
if (!goFundMe.uniqueFunder[msg.sender]) { | ||
goFundMe.funders.push(msg.sender); | ||
goFundMe.uniqueFunder[msg.sender] = true; | ||
} | ||
} | ||
|
||
function getListLength() public view returns (uint256) { | ||
return (listLength); | ||
} | ||
|
||
function getFundersLength(uint256 _index) public view returns (uint256) { | ||
GoFundMe storage goFundMe = goFundMes[_index]; | ||
return (goFundMe.funders.length); | ||
} | ||
|
||
function getBalance(uint256 _index) public view returns (uint256) { | ||
GoFundMe storage goFundMe = goFundMes[_index]; | ||
return (goFundMe.balance); | ||
} | ||
} |
Oops, something went wrong.