LedgerVest is a decentralized investment and fundraising platform built on Ethereum that allows investors to contribute to campaigns and campaign managers to raise funds with transparency and security through smart contracts.
- Decentralized Fundraising: Create and manage fundraising campaigns on the blockchain
- MetaMask Integration: Seamless wallet connection for transactions
- Smart Contract Security: All funds are managed through secure smart contracts
- Transparent Fund Management: View campaign balances, contributors, and transaction history
- Democratic Decision Making: Vote on fund withdrawal requests
- Multi-contributor Support: Multiple people can contribute to a single campaign
- Frontend: Next.js, React, TypeScript, TailwindCSS
- Blockchain: Ethereum (Sepolia Testnet), Solidity, Hardhat
- Authentication: MetaMask wallet connection
- State Management: React Context API
- Development Tools: Hardhat, ethers.js
- Node.js (v18+)
- npm or yarn
- MetaMask browser extension
- Sepolia testnet ETH (for testing)
important
For frontend/backend development, there's no need to rebuild the blockchain
just directly run the belowing and you should see the webpage at localhost:3000
npm install
npm run devgit clone https://gitlab.oit.duke.edu/cw555/fintech512-project_ledgervest.git
cd fintech512-project_ledgervest
# Install dependencies
npm install# Create .env file
touch .envAdd the following to your .env file:
(remember to add .env to .gitignore to prevent pushing private key to repo)
SEPOLIA_RPC=<your_alchemy_sepolia_url>
PRIVATE_KEY=<your_metamask_private_key> # Include 0x prefixTo get your Alchemy Sepolia URL:
- Create an account at Alchemy
- Create a new app and select Ethereum/Sepolia
- Copy the HTTP API key
# Compile the smart contracts
cd blockchain
npx hardhat compile
# Run tests locally (no real ETH used)
npx hardhat test
# Deploy to Sepolia testnet
npx hardhat run scripts/deploy.js --network sepoliaAfter deployment, you'll see a CampaignFactory address in the console. Note this address.
You should see Campaign.json, CampaignFactory.json, contract-address.json being copied to web/src/utils/abis/
below should be all done if correctly deployed the smart contract
# Navigate to the web folder
cd ../webCreate or update src/utils/abis/contract-address.json if necessary:
{
"CampaignFactory": "YOUR_COPIED_FACTORY_ADDRESS"
}Ensure the ABI files are in place (if they weren't copied automatically):
cp ../blockchain/artifacts/contracts/Campaign.sol/Campaign.json src/utils/abis/
cp ../blockchain/artifacts/contracts/Campaign.sol/CampaignFactory.json src/utils/abis/# Start the development server
npm run devVisit http://localhost:3000 in your browser.
blockchain/ # Smart contract code
βββ contracts/ # Solidity contracts
β βββ Campaign.sol # Main contract
βββ scripts/ # Deployment scripts
βββ test/ # Contract tests
βββ hardhat.config.js # Hardhat configuration
web/ # Frontend application
βββ public/ # Static assets
βββ src/
β βββ app/ # Next.js pages
β β βββ page.tsx # Homepage
β β βββ projects/ # Projects listing
β β βββ campaigns/ # Campaign details
β β βββ create/ # Create campaign
β βββ components/ # React components
β βββ lib/ # Library code
β β βββ context/ # React contexts
β βββ utils/ # Utility functions
β βββ abis/ # Contract ABIs
β βββ ethers.js # Ethereum utilities
βββ next.config.js # Next.js configuration- Set MetaMask to Sepolia: Make sure your MetaMask is connected to the Sepolia testnet
- Get Sepolia ETH: Request test ETH from a Sepolia faucet
- Connect Wallet: Click the "Connect Wallet" button in the top-right corner
- Click "Create Campaign" button
- Set the minimum contribution amount (in ETH)
- Submit and confirm the transaction in MetaMask
- Your campaign will appear in the campaigns list once mined
- Browse available campaigns
- Click on a campaign to view details
- Enter contribution amount (must be β₯ minimum contribution)
- Click "Contribute" and confirm in MetaMask
- Navigate to your campaign
- Create a new spending request with:
- Description of the purpose
- Amount in ETH
- Recipient address
- Confirm transaction in MetaMask
- Navigate to a campaign you've contributed to
- View the "Spending Requests" section
- Click "Approve" on requests you support
- Confirm transaction in MetaMask
- After receiving sufficient approvals (>50% of contributors)
- Click "Finalize" on the request
- Confirm transaction in MetaMask
- Funds will be transferred to the recipient
The platform uses two main contracts:
- CampaignFactory: Creates new campaigns and tracks all deployed campaigns
- Campaign: Handles individual campaign logic including:
- Contributions
- Spending requests
- Approvals
- Fund transfers
The platform connects to MetaMask or other Ethereum wallets via the Web3 provider API. Key operations:
- Read Operations: View campaign details, balances, and request status
- Write Operations: Create campaigns, contribute funds, approve requests, finalize transfers
- User initiates action (create, contribute, approve, etc.)
- Wallet prompts for transaction confirmation
- Transaction is sent to the Ethereum network
- UI updates when transaction is mined
All development and testing should be done on the Sepolia testnet to avoid using real ETH.
For local development without blockchain interaction:
- Comment out blockchain calls in
useWallethook - Use mock data for testing UI
- Transaction Errors: Ensure you have sufficient Sepolia ETH for gas
- Contract Interactions: Check that ABI files match deployed contracts
- MetaMask Connection: Reset MetaMask account if experiencing connection issues
Contributions are welcome! Please feel free to submit a Pull Request.
