TrustFlow is a secure and transparent crowdfunding platform built on the Ethereum blockchain. It removes the need for centralized intermediaries by allowing creators to launch their own fundraising campaigns and backers to contribute directly via smart contracts. This project is a demonstration of a factory-based contract architecture, which enables scalable and efficient deployment of multiple, independent crowdfunding campaigns.
- Decentralized Campaign Creation: Any user can deploy a new, dedicated crowdfunding campaign with a single transaction using the factory contract.
- Transparent & Trustless Funding: All contributions and fund distributions are managed by smart contracts, ensuring the process is transparent and verifiable on the blockchain.
- Tier-Based Contributions: Campaign creators can define different funding tiers with specific amounts and benefits.
- Automatic Fund Management: Funds are held securely in the smart contract. They are released to the creator only upon a successful campaign or are made available for refunds if the campaign fails.
- Admin Controls: The factory owner can pause the platform, and individual campaign owners can manage their specific campaigns (e.g., adding tiers, extending deadlines).
The project is composed of two main contracts:
This is the core contract for a single campaign. It is a reusable blueprint that manages a campaign's state, contributions, and fund flow.
constructor(): Initializes a new campaign with a name, description, goal, and deadline. The caller of this function becomes the campaign's owner.fund(): Apayablefunction that allows users to contribute to a specific tier.addTier(): Allows the campaign owner to define new contribution levels.withdraw(): Enables the owner to withdraw collected funds if the campaign goal is met.refund(): Allows backers to retrieve their contributions if the campaign fails.togglePause(): Gives the campaign owner the ability to pause or unpause their specific campaign.
This contract acts as a central hub for all campaigns. It's the primary entry point for creators.
createCampaign(): The key function that deploys a new instance of theCrowdFundingcontract. It takes campaign details as parameters and makes the caller the owner of the newly deployed campaign.Campaigns[]: A public array that stores a record of every campaign created by the factory, making them discoverable.userCampaigns: A mapping that tracks all campaigns created by a specific user.
To interact with the smart contracts, you will need a development environment like Hardhat or Truffle and an Ethereum wallet.
- Clone the repository:
git clone [your-repo-url]
- Install dependencies:
npm install
- Compile the contracts:
npx thirdweb compile