A decentralized crowdfunding platform built on StarkNet, enabling users to create and participate in fundraising campaigns using ERC20 tokens. The platform consists of a Cairo smart contract for on-chain logic and a Next.js frontend for user interaction.
- Support for any ERC20 token on StarkNet (currently UI supports STRK and ETH)
- Secure fund management with ownership controls
- Deadline-based campaign management
- Flexible campaign reset functionality
- Transparent fund tracking and withdrawal system
- Role-based access control system
The platform implements a robust role-based access control system:
- Toggle campaign active status (activate/deactivate)
- Withdraw funds when conditions are met
- Reset campaign with new parameters
- View special owner-only UI controls
- Manage campaign core parameters
- View campaign details and progress
- Make donations to active campaigns
- View their donation history
- Connect/disconnect wallet
- Donations only accepted when campaign is active
- Withdrawals only allowed when:
- Campaign deadline has passed, OR
- Funding target has been reached
- Campaign reset only possible after:
- All funds have been withdrawn
- Previous campaign is completed
- Owner-only function access
- Active status checks
- Deadline enforcement
- Balance verification
- Token approval validation
- Modern, responsive UI built with Next.js and Tailwind CSS
- Real-time campaign progress tracking
- Interactive donation interface
- Countdown timer for campaign deadline
- Dark/Light mode support
- Owner-specific controls for campaign management
scaffold-stark-crowd-funding/
├── packages/
│ ├── nextjs/ # Frontend application
│ │ ├── app/ # Next.js pages and components
│ │ ├── components/ # Reusable UI components
│ │ └── hooks/ # Custom React hooks
│ └── snfoundry/ # Smart contract
│ └── contracts/ # Cairo contract files
- Node.js (v16 or higher)
- Yarn package manager
- Scarb (for Cairo contract development)
- StarkNet wallet (e.g., ArgentX, Braavos)
-
Clone the repository:
git clone https://github.com/yourusername/scaffold-stark-crowd-funding.git cd scaffold-stark-crowd-funding
-
Install dependencies:
yarn install
-
Compile the smart contract:
cd packages/snfoundry/contracts scarb build
-
Run contract tests:
scarb test
-
Deploy the contract:
yarn deploy --network {NETWORK_NAME} # "sepolia" or "mainnet", defaults to "devnet"
-
Start the frontend development server:
cd packages/nextjs yarn dev
The contract implements the IFund
interface with the following functions:
get_fund_balance
: Get current campaign balanceget_fund_target
: Get campaign funding targetget_fund_description
: Get campaign descriptionget_deadline
: Get campaign end timestampget_token_symbol
: Get fundraising token symbolget_token_address
: Get fundraising token contract addressget_owner
: Get contract owner addressget_active
: Get campaign active status
fund_to_contract
: Contribute tokens to the campaignwithdraw_funds
: Withdraw funds to grantee (owner only)reset_fund
: Reset campaign with new parameters (owner only)set_active
: Toggle campaign active status (owner only)
- Real-time display of:
- Campaign description
- Current balance
- Funding target
- Progress percentage
- Remaining time
- Token symbol
- Wallet connection integration
- Donation input with token selection
- Progress bar visualization
- Countdown timer
- Responsive design for all devices
- Dark/Light theme support
- Campaign activation/deactivation
- Fund withdrawal management
- Campaign reset functionality
The contract emits the following events:
OwnableEvent
: Ownership management eventsSelfDestructed
: Contract self-destruction eventTransfer
: Successful token transfer eventTransferFailed
: Failed transfer eventResetFund
: Campaign reset eventActiveChanged
: Campaign status change event
- Owner-only access control for sensitive functions
- Withdrawal restrictions
- Campaign state management
- Parameter updates
- Deadline enforcement for campaign lifecycle
- Safe token transfer handling
- Input validation for all user interactions
- Proper error handling and event emission
- Role-based UI element visibility
- Transaction confirmation dialogs for important actions
- OpenZeppelin Contracts (Cairo)
- Ownable component
- ERC20 interface
- Next.js 13+
- React
- Tailwind CSS
- scaffold-stark hooks
- StarkNet.js
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
demo video https://youtu.be/shciV6KVuyQ Sepolia environment https://scaffold-stark-crowd-funding-nextjs.vercel.app/