Create impactful campaigns, discover causes, and fund transparently using MetaMask on the Sepolia testnet.
Built with Solidity · Remix · React + Vite · Cloudflare Workers · MetaMask
Defund is a non‑custodial, decentralized crowdfunding platform. Campaigns are created and funded directly on Ethereum (Sepolia testnet) via MetaMask, ensuring transparency and on‑chain accountability. An integrated AI helper refines campaign inputs to make titles and descriptions more impactful.
- Create campaigns with title, description, target amount, deadline, and image
- Fund campaigns using your MetaMask wallet (Sepolia ETH for testing)
- AI assist to improve your campaign content with one click
- View all campaigns on a dashboard and drill into details
- Live Ethereum price chart with INR conversion (ETH ↔ INR)
![]() Dashboard — browse active campaigns |
![]() Campaign details — fund with MetaMask |
![]() Create campaign — AI enhances content |
![]() ETH price chart — convert ETH ↔ INR |
- Smart Contracts: Solidity (deployed via Remix to Sepolia)
- Wallet: MetaMask (Browser extension)
- Frontend: React + Vite
- AI Helper: Cloudflare Worker (HTTP API)
- Price + Conversion: CoinGecko API (demo environment)
- Media: Unsplash API for images
React (Vite) ───────────▶ MetaMask ───────────▶ Ethereum (Sepolia)
│ ▲ ▲
│ │ │
│ POST /enhance-campaign│ │
├──────────▶ Cloudflare Worker (AI) │
│ Read/Write
│ ───────────▶ Defund Smart Contract
│
├──────────▶ CoinGecko (ETH price, INR conversion)
└──────────▶ Unsplash (campaign images)
- Node.js 18+ and npm
- MetaMask installed in your browser
- Sepolia test ETH in your MetaMask account
- A deployed Defund contract address on Sepolia
Create a .env file in the client folder with the following variables:
# Sepolia Defund contract address (from your Remix deployment)
VITE_CONTRACT_ADDRESS=0xYourSepoliaContractAddress
# Unsplash API access key (for campaign images)
VITE_UNSPLASH_ACCESS_KEY=your_unsplash_access_key
# CoinGecko demo API key (for ETH price + conversion)
VITE_COINGECKO_API_KEY=your_coingecko_demo_keyNotes:
- Contract address is read in
src/utils/connectToWallet.js. - Unsplash key is used by
src/api/unsplashInstance.js. - CoinGecko key is used by
src/utils/getEthPrice.js(demo environment). - The AI helper is configured to call a Cloudflare Worker at
https://ai-worker.defund-ai.workers.devviasrc/api/aiWorkerInstance.js. If you deploy your own worker, update that base URL accordingly.
From the client directory:
npm install
npm run devBuild and preview:
npm run build
npm run previewThe app expects MetaMask to be available in the browser and your network set to Sepolia.
-
Dashboard
- Lists all campaigns pulled from the Defund smart contract.
- Click a campaign to view details, donators, and funding history.
-
Create Campaign
- Input title, description, target amount (ETH), deadline, and image URL.
- Use the “AI” button to refine your content for better impact.
- Submits
createCampaignto the Defund contract via MetaMask.
-
Ethereum Page
- Live ETH price chart.
- Simple ETH ↔ INR conversion powered by CoinGecko.
- Deploy the Defund contract to Sepolia using Remix.
- Copy the deployed address into
VITE_CONTRACT_ADDRESS. - The frontend reads campaigns via
getCampaigns, creates new ones viacreateCampaign, and funds viadonateToCampaignusing MetaMask/ethers.
Core functions used by the client:
getCampaigns— fetches all campaigns (owner, title, description, target, deadline, amountCollected, image)createCampaign— creates a new campaign (writes on-chain)donateToCampaign— funds a campaign with ETHgetDonators— returns donors and donation amounts for a given campaignnumberOfCampaigns— returns total count
Implementation references:
- Connect and ABI: client/src/utils/connectToWallet.js
- Contract helpers: client/src/utils/contractUtils.js
The Create Campaign page includes an AI button that augments your inputs to be more compelling. This is served by a Cloudflare Worker (see ai-worker/). If you run your own worker:
- Deploy with Wrangler to your Cloudflare account.
- Update the base URL in
src/api/aiWorkerInstance.jsto point at your worker domain.
- Base: your Cloudflare Worker (e.g.,
https://ai-worker.defund-ai.workers.dev) - Endpoint:
POST /enhance-campaign - Request (JSON):
{
"title": "...",
"description": "...",
"category": "General",
"targetEth": 1.5,
"deadline": "2026-02-28T00:00:00.000Z"
}- Response (JSON):
{
"enhancedTitle": "...",
"enhancedDescription": "..."
}- Status codes:
200(OK),400(invalid body),404(unknown path),405(method not allowed),500/503(service unavailable/config error) - CORS: Enabled for
POST, OPTIONSwithAccess-Control-Allow-Origin: *
Source: ai-worker/src/index.js
From the ai-worker directory:
npm install
# Set secret for Groq API key (do not commit secrets)
wrangler secret put GROQ_API_KEY
# Local dev
npm run dev
# Deploy
npm run deployOptional local .dev.vars can store non-sensitive dev values. Update the client base URL in client/src/api/aiWorkerInstance.js after deployment if your domain changes.
Run the worker and client in separate terminals:
# Terminal 1: AI Worker
cd ai-worker
npm install
npm run dev
# Terminal 2: Client
cd client
npm install
npm run devEnsure MetaMask is on Sepolia. Set env variables in client/.env before starting.
- MetaMask not installed: Install the extension and refresh the page.
- Wrong network: Switch MetaMask to Sepolia; reconnect wallet.
- Pending request: MetaMask may show
-32002; cancel the pending request or wait, then retry. - User rejected request: Error
4001; re-initiate connect and approve. - No campaigns visible: Verify
VITE_CONTRACT_ADDRESSpoints to a valid deployed contract. - AI helper errors: Confirm the worker is running and
GROQ_API_KEYis set via Wrangler secrets.
- CoinGecko (demo): ETH price and conversions. Provide a demo API key in
.env. - Unsplash: Image search and retrieval. Provide a Client ID in
.env.
- Testnet only: Defund currently targets Sepolia for safe testing — do not use real funds.
- Gas fees: Funding campaigns incurs standard Sepolia gas fees.
- Transparency: All campaign activity (creation, funding) is recorded on-chain.
client/
public/
logo.png
demo/
dashboard.png
view-campaign.png
create-campaign.png
ethereum.png
src/
api/
aiWorkerInstance.js
unsplashInstance.js
components/
contexts/
utils/
connectToWallet.js
contractUtils.js
getEthPrice.js
- Ethereum & Sepolia testnet community
- CoinGecko API
- Unsplash
- Cloudflare Workers
- WalletConnect support
- On-chain categories and search
- Campaign updates and milestones
- Multi-currency support and localization
This is an educational/testnet project. Always verify contracts and endpoints before use. No guarantees or warranties are provided.



