Trustless crowdfunding on Ethereum. Create campaigns, contribute ETH, and withdraw only when goals are met — all enforced by smart contract.
Live Demo: parth1305.github.io/web3-crowdfund
Contract: 0x189ab20b1993166d1c498c5acafa396658d2fea5 on Sepolia
FundChain is a full-stack Web3 application that demonstrates end-to-end blockchain development — from a Solidity smart contract deployed on Ethereum Sepolia, to a Node.js/Express backend API, to a vanilla JS frontend.
No intermediaries. No trust required. The contract enforces all rules.
All logic lives on-chain. The backend is a read/write API layer over the contract.
| Layer | Technology |
|---|---|
| Smart Contract | Solidity 0.8.28, Hardhat v3 |
| Blockchain | Ethereum Sepolia Testnet |
| Backend | Node.js, Express, TypeScript, viem |
| Frontend | Vanilla HTML/CSS/JS |
| RPC | Alchemy |
| Deploy | GitHub Pages (frontend) |
web3-crowdfund/
├── contracts/
│ └── Crowdfund.sol # Solidity smart contract
├── test/
│ └── Crowdfund.test.ts # 9 passing tests
├── scripts/
│ └── deploy.ts # Hardhat deploy script
├── backend/
│ └── src/
│ ├── index.ts # Express server (port 3001)
│ ├── contract.ts # viem client + ABI
│ └── routes.ts # API route handlers
├── frontend/
│ └── index.html # Single-page frontend
└── hardhat.config.ts
contracts/Crowdfund.sol
struct Campaign {
address owner;
string title;
uint256 goal;
uint256 deadline;
uint256 amountRaised;
bool withdrawn;
}
Functions:
createCampaign(title, goal, durationInDays) — creates a new campaigncontribute(campaignId) — send ETH to a campaign (payable)withdraw(campaignId) — owner withdraws if goal metrefund(campaignId) — contributor claims refund if goal not metgetCampaign(campaignId) — read campaign dataSecurity: Reentrancy protection via state updates before external calls.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/campaigns |
List all campaigns |
| GET | /api/campaigns/:id |
Get single campaign |
| POST | /api/campaigns |
Create new campaign |
| POST | /api/campaigns/:id/contribute |
Contribute ETH |
Example — Create Campaign:
curl -X POST http://localhost:3001/api/campaigns \
-H "Content-Type: application/json" \
-d '{"title": "My Campaign", "goalInEth": "0.05", "durationInDays": 30}'
git clone https://github.com/Parth1305/web3-crowdfund.git
cd web3-crowdfund
npm install
cd backend && npm install && cd ..
export SEPOLIA_RPC_URL="https://eth-sepolia.g.alchemy.com/v2/YOUR_KEY"
export SEPOLIA_PRIVATE_KEY="0xYOUR_PRIVATE_KEY"
export CROWDFUND_CONTRACT_ADDRESS="0x189ab20b1993166d1c498c5acafa396658d2fea5"
npx hardhat test
# 9 passing
cd backend
npm run dev
# Server running on http://localhost:3001
Open frontend/index.html in your browser.
npx hardhat run scripts/deploy.ts --network sepolia
Update CROWDFUND_CONTRACT_ADDRESS and the address in frontend/index.html with the new contract address.
✓ should create a campaign
✓ should allow contributions
✓ should allow owner to withdraw when goal is met
✓ should prevent withdrawal if goal not met
✓ should allow refund if goal not met after deadline
✓ should prevent refund if goal was met
✓ should prevent contributions after deadline
✓ should prevent double withdrawal
✓ should track multiple contributors
Run with:
npx hardhat test
Parth Gohil
PGD in Backend & Blockchain Development — York University
GitHub
Built on Ethereum Sepolia · Not for production use