{"id":18014289,"url":"https://github.com/codingshot/crowded-fund","last_synced_at":"2026-04-20T19:02:42.363Z","repository":{"id":257970313,"uuid":"872638196","full_name":"codingshot/crowded-fund","owner":"codingshot","description":"Escrow based campaigns contracts based on Potlock campaign contracts","archived":false,"fork":false,"pushed_at":"2024-10-15T20:09:01.000Z","size":2359,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-04T15:12:52.031Z","etag":null,"topics":["base","berachain","ethereum","funding","juicebox","kickstarter","potlock","solidity"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codingshot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-14T19:44:24.000Z","updated_at":"2024-10-16T14:07:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"11a47008-556e-447a-940f-b2e5a43a5b99","html_url":"https://github.com/codingshot/crowded-fund","commit_stats":null,"previous_names":["codingshot/crowded-fund"],"tags_count":0,"template":false,"template_full_name":"scaffold-eth/scaffold-eth-2","purl":"pkg:github/codingshot/crowded-fund","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingshot%2Fcrowded-fund","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingshot%2Fcrowded-fund/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingshot%2Fcrowded-fund/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingshot%2Fcrowded-fund/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codingshot","download_url":"https://codeload.github.com/codingshot/crowded-fund/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codingshot%2Fcrowded-fund/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32061251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T11:35:06.609Z","status":"ssl_error","status_checked_at":"2026-04-20T11:34:48.899Z","response_time":94,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["base","berachain","ethereum","funding","juicebox","kickstarter","potlock","solidity"],"created_at":"2024-10-30T04:07:34.708Z","updated_at":"2026-04-20T19:02:42.342Z","avatar_url":"https://github.com/codingshot.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Crowded Fund - EVM implementation of Campaigns Escrow Contract\nProvide a way to raise funds, for yourself as an organization, or on behalf of an organization, through donations, raising on behalf of organizations has an approval process to indicate whether the campaign is \"official\". Contract can also function as an escrow with minimum target amounts, refunding donors if the target is not met. Campaigns can be time-based.\n\n\nAn EVM adaptation of the NEAR Campaign contracts as part of Potlock Protocol\nhttps://github.com/PotLock/core/tree/feat/campaigns/contracts/campaigns For more on Potlock https://docs.potlock.io \n\n# 🏗 Scaffold-ETH 2\n\n\n\n\n\u003ch4 align=\"center\"\u003e\n  \u003ca href=\"https://docs.scaffoldeth.io\"\u003eDocumentation\u003c/a\u003e |\n  \u003ca href=\"https://scaffoldeth.io\"\u003eWebsite\u003c/a\u003e\n\u003c/h4\u003e\n⚙️ Built using NextJS, RainbowKit, Hardhat, Wagmi, Viem, and Typescript.\n\n- ✅ **Contract Hot Reload**: Your frontend auto-adapts to your smart contract as you edit it.\n- 🪝 **[Custom hooks](https://docs.scaffoldeth.io/hooks/)**: Collection of React hooks wrapper around [wagmi](https://wagmi.sh/) to simplify interactions with smart contracts with typescript autocompletion.\n- 🧱 [**Components**](https://docs.scaffoldeth.io/components/): Collection of common web3 components to quickly build your frontend.\n- 🔥 **Burner Wallet \u0026 Local Faucet**: Quickly test your application with a burner wallet and local faucet.\n- 🔐 **Integration with Wallet Providers**: Connect to different wallet providers and interact with the Ethereum network.\n\n![Debug Contracts tab](https://github.com/scaffold-eth/scaffold-eth-2/assets/55535804/b237af0c-5027-4849-a5c1-2e31495cccb1)\n\n## Requirements\n\nBefore you begin, you need to install the following tools:\n\n- [Node (\u003e= v18.18)](https://nodejs.org/en/download/)\n- Yarn ([v1](https://classic.yarnpkg.com/en/docs/install/) or [v2+](https://yarnpkg.com/getting-started/install))\n- [Git](https://git-scm.com/downloads)\n\n## Quickstart\n\nTo get started with Scaffold-ETH 2, follow the steps below:\n\n1. Clone this repo \u0026 install dependencies\n\n```\ngit clone https://github.com/scaffold-eth/scaffold-eth-2.git\ncd scaffold-eth-2\nyarn install\n```\n\n2. Run a local network in the first terminal:\n\n```\nyarn chain\n```\n\nThis command starts a local Ethereum network using Hardhat. The network runs on your local machine and can be used for testing and development. You can customize the network configuration in `hardhat.config.ts`.\n\n3. On a second terminal, deploy the test contract:\n\n```\nyarn deploy\n```\n\nThis command deploys a test smart contract to the local network. The contract is located in `packages/hardhat/contracts` and can be modified to suit your needs. The `yarn deploy` command uses the deploy script located in `packages/hardhat/deploy` to deploy the contract to the network. You can also customize the deploy script.\n\n4. On a third terminal, start your NextJS app:\n\n```\nyarn start\n```\n\nVisit your app on: `http://localhost:3000`. You can interact with your smart contract using the `Debug Contracts` page. You can tweak the app config in `packages/nextjs/scaffold.config.ts`.\n\n**What's next**:\n\n- Edit your smart contract `Campaigns.sol` in `packages/hardhat/contracts`\n- Edit your frontend homepage at `packages/nextjs/app/page.tsx`. For guidance on [routing](https://nextjs.org/docs/app/building-your-application/routing/defining-routes) and configuring [pages/layouts](https://nextjs.org/docs/app/building-your-application/routing/pages-and-layouts) checkout the Next.js documentation.\n- Edit your deployment scripts in `packages/hardhat/deploy`\n- Edit your smart contract test in: `packages/hardhat/test`. To run test use `yarn hardhat:test`\n- You can add your Alchemy API Key in `scaffold.config.ts` if you want more reliability in your RPC requests.\n\n## Documentation\n\nVisit our [docs](https://docs.scaffoldeth.io) to learn how to start building with Scaffold-ETH 2.\n\nTo know more about its features, check out our [website](https://scaffoldeth.io).\n\n## Contributing to Scaffold-ETH 2\n\nWe welcome contributions to Scaffold-ETH 2!\n\nPlease see [CONTRIBUTING.MD](https://github.com/scaffold-eth/scaffold-eth-2/blob/main/CONTRIBUTING.md) for more information and guidelines for contributing to Scaffold-ETH 2.\n\n\n\n\n# Solidity Campaigns Contract Overview\n\n## Overview\n\nThis smart contract implements a decentralized fundraising platform on the Ethereum blockchain. It allows users to create and manage fundraising campaigns, accept donations in ETH or ERC20 tokens, and handle the distribution of funds to recipients and fee collectors. The contract is inspired by the [PotLock campaigns contract](https://github.com/PotLock/core/tree/feat/campaigns/contracts/campaigns).\n\n## Features\n\n- Create and manage fundraising campaigns\n- Accept donations in ETH or ERC20 tokens\n- Implement referral and creator fee systems\n- Escrow functionality for campaigns with minimum funding goals\n- Refund mechanism for failed campaigns\n- Flexible fee structure with configurable protocol, referral, and creator fees\n\n## Contract Structure\n\nThe main contract `Campaigns.sol` contains the following key components:\n\n1. Campaign and Donation structs\n2. State variables for managing campaign and donation IDs, fees, and configuration\n3. Mappings for storing campaign and donation data\n4. Functions for creating and updating campaigns\n5. Donation processing and refund functions\n6. Getter functions for retrieving campaign and donation information\n7. Admin functions for updating fee structures and withdrawing stuck funds\n\n## Key Functions\n\n### Campaign Management\n\n- `createCampaign`: Create a new fundraising campaign\n- `updateCampaign`: Update an existing campaign (only by owner, before start)\n\n### Donation Handling\n\n- `donate`: Make a donation to a specific campaign\n- `processEscrowedDonations`: Process escrowed donations after reaching the minimum goal\n- `refundDonations`: Refund donations for failed campaigns\n\n### Information Retrieval\n\n- `getCampaign`: Get campaign details\n- `getDonation`: Get donation details\n- `getCampaignsByOwner`: Get campaigns created by a specific owner\n- `getCampaignsByRecipient`: Get campaigns for a specific recipient\n- `getDonationsByCampaign`: Get donations for a specific campaign\n- `getDonationsByDonor`: Get donations made by a specific donor\n\n### Admin Functions\n\n- Update fee structures (protocol, referral, creator)\n- Withdraw stuck ETH or ERC20 tokens (emergency functions)\n\n## Security Considerations\n\n- Uses OpenZeppelin's `Ownable` and `ReentrancyGuard` to enhance security\n- Implements input validation to ensure data integrity\n- Includes emergency functions to withdraw stuck funds, accessible only by the owner\n\n## Gas Optimization\n\n- Uses `uint256` for most numeric values\n- Employs structs to group related data\n- Emits events for important state changes\n\n## Differences from PotLock Implementation\n\n- This Ethereum implementation uses Solidity instead of Rust\n- Adapts to Ethereum's transaction model and global state storage\n- Utilizes OpenZeppelin libraries for standard functionalities\n\n## Future Improvements\n\n- Implement a multi-signature wallet for the protocol fee recipient and contract ownership\n- Add support for batch operations to optimize gas usage\n- Implement a time-lock mechanism for critical parameter changes\n- Develop a factory contract for easier deployment and management of multiple campaign contracts\n\n### Recent Updates\n\n1. **Claim Functionality**: Implemented a pull-based refund system with `claimRefund` and `claimAllRefunds` functions, allowing donors to claim refunds for failed campaigns.\n\n2. **Official Campaign Status**: Added an `isOfficial` boolean to the Campaign struct, which is set to true if the campaign creator is also the recipient. This can be updated using the `setOfficialStatus` function.\n\n3. **Commit-Reveal Scheme**: Implemented a two-step process for creating campaigns using a commit-reveal scheme to prevent front-running.\n\n4. **Gas Optimization**: Improved gas efficiency by using `uint256` for most numeric values and employing structs to group related data.\n\n### Key Functions\n\n- `createCampaignCommitment`: Create a new campaign commitment\n- `revealCampaign`: Reveal the campaign details after commitment\n- `updateCampaign`: Update an existing campaign (only by owner, before start)\n- `donate`: Make a donation to a specific campaign\n- `processEscrowedDonations`: Process escrowed donations after reaching the minimum goal\n- `claimRefund`: Claim a refund for a specific donation\n- `claimAllRefunds`: Claim all refunds for a campaign\n- `setOfficialStatus`: Set the official status of a campaign (only by recipient)\n\n### Testing Framework\n\nThe contract is tested using the Hardhat testing framework with Chai assertions. The test file `Campaigns.ts` contains various test suites that cover different aspects of the contract functionality.\n\n#### Key Test Suites\n\n1. **Deployment**: Tests the initial state of the contract after deployment.\n2. **Campaign Creation and Management**: Tests creating, revealing, and updating campaigns.\n3. **Donations**: Tests making donations, processing escrowed donations, and handling campaign end conditions.\n4. **Refunds**: Tests the refund claiming process for failed campaigns.\n5. **Admin Functions**: Tests owner-only functions for updating fee structures and withdrawing stuck funds.\n6. **Edge Cases and Attack Vectors**: Tests various edge cases and potential attack scenarios.\n7. **Gas Limit and Large Scale Operations**: Tests handling of large numbers of donations and refunds.\n8. **Official Campaign Status**: Tests setting and checking the official status of campaigns.\n\n#### How the Testing Framework Works\n\n1. The tests use the `ethers` library to interact with the smart contract.\n2. Before each test suite, the contract is deployed to a local Hardhat network.\n3. Test cases use `async/await` syntax to handle asynchronous contract interactions.\n4. Chai assertions (`expect`) are used to verify the expected outcomes of contract function calls.\n5. The `ethers.provider` is used to manipulate the blockchain state (e.g., increasing time) for testing time-dependent functionality.\n6. Events emitted by the contract are captured and verified in relevant test cases.\n\nTo run the tests, use the command `yarn hardhat test` in the project directory.\n\nFor more detailed information on the contract implementation and tests, please refer to the `Campaigns.sol` and `Campaigns.ts` files in the repository.\n\n\n## Campigns and Referrals\nReferrals are utilized for campaign creators, Potlock protocol, and referrers. These amounts are also escrowed until the campaign is successful.\n\nReferral fees are calculated at the time of donation\n. When a user makes a donation, the contract calculates the referral fee based on the referralFeeBasisPoints set for the campaign.\nFor campaigns with a minimum amount (escrow-based):\nIf the campaign's minimum amount has not been reached, all funds, including the referral fee, are held in escrow1\n. The escrowBalance of the campaign is increased by the full donation amount.\nThe referral fee is not immediately paid out. Instead, it's stored as part of the Donation struct1\n.\nIf the campaign reaches its minimum amount, the processEscrowedDonations function can be called1\n. This function will transfer the escrowed funds, including paying out the referral fees for all donations.\nIf the campaign ends without reaching its minimum amount, donors can claim refunds using the claimRefund or claimAllRefunds functions1\n. In this case, the full donation amount is refunded to the donor, including the portion that would have been the referral fee.\nFor campaigns without a minimum amount or when the minimum has already been reached:\nThe referral fee is immediately transferred to the referrer at the time of donation","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingshot%2Fcrowded-fund","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodingshot%2Fcrowded-fund","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodingshot%2Fcrowded-fund/lists"}