Skip to content

Repository files navigation

Foundry Fund Me

MIT License Foundry v1.0 Node.js ≥14.x

Foundry Fund Me is a simple crowdfunding smart contract suite built with Foundry—a fast, modular toolkit for Ethereum development.


⚙️ Features

  • Fund the contract: Users can send ETH to support your project.
  • Owner withdrawal: Only the contract owner can withdraw accumulated funds.
  • Chainlink Price Feeds: Enforces a USD-denominated minimum contribution.
  • Access control: Secure withdrawal using OpenZeppelin’s Ownable pattern.

🛠 Prerequisites & Installation

Windows (Git Bash or WSL)

  1. Install Git & Git Bash Download Git (includes Git Bash) from https://git-scm.com/downloads and follow the installer.

  2. Install Node.js Download the Windows installer from https://nodejs.org/en/download/ and run it. Verify:

    node -v
    npm -v
  3. (Optional) Set up WSL

    • Open PowerShell as Administrator and run:

      wsl --install
    • Restart, then install a Linux distro from Microsoft Store (e.g., Ubuntu).

    • In your WSL shell, install Git and Node.js via your distro’s package manager.

  4. Install Foundry In Git Bash or WSL:

    curl -L https://foundry.paradigm.xyz | bash
    foundryup

macOS / Linux

  1. Install Git (if not already installed):

    # macOS (with Homebrew)
    brew install git
    
    # Ubuntu
    sudo apt update && sudo apt install git -y
  2. Install Node.js

    # macOS (with Homebrew)
    brew install node
    
    # Ubuntu
    curl -fsSL https://deb.nodesource.com/setup_14.x | sudo -E bash - 
    sudo apt-get install -y nodejs
  3. Install Foundry

    curl -L https://foundry.paradigm.xyz | bash
    foundryup

🔐 Environment Setup

  1. Configure .env Create a .env file in project root:

    RPC_URL=your_rpc_url
    PRIVATE_KEY=your_private_key
    ETHERSCAN_API_KEY=your_etherscan_api_key

    Add .env to .gitignore.

  2. (Recommended) Create a Wallet Keystore

    cast wallet import BOB --interactive

    Keystore saved to ~/.foundry/keystores.

    Deploy with keystore:

    forge script script/DeployFundMe.s.sol:DeployFundMe \
      --rpc-url $RPC_URL \
      --account BOB \
      --broadcast \
      --verify \
      -vvvv

🏗️ Project Layout

src/         Solidity contracts (FundMe.sol, PriceConverter.sol)
script/      Deployment scripts (Forge scripts)
test/        Unit & integration tests (Forge)
lib/         External libraries (forge-std)
broadcast/   Deployment logs & artifacts

🚀 Quickstart

1. Launch Local Node (Anvil)

anvil

2. Build & Test

forge build
forge test

3. Deploy Contracts

Mainnet/Testnet

forge script script/DeployFundMe.s.sol:DeployFundMe \
  --rpc-url $RPC_URL \
  --private-key $PRIVATE_KEY \
  --broadcast \
  --verify \
  -vvvv

Local Anvil

# terminal A:
anvil

# terminal B:
forge script script/DeployFundMe.s.sol:DeployFundMe \
  --rpc-url http://127.0.0.1:8545 \
  --private-key $PRIVATE_KEY \
  --broadcast \
  -vvvv

4. Interact via Cast

# Get balance
cast balance <address> --rpc-url $RPC_URL

# Read-only call
cast call <contract_addr> "functionName(type)" <args> --rpc-url $RPC_URL

# Send transaction
cast send <contract_addr> "functionName(type)" <args> --rpc-url $RPC_URL --private-key $PRIVATE_KEY

🔧 Utility Commands

Command Description
forge fmt Format contracts
forge snapshot Record gas usage for functions
anvil Start local Ethereum node
cast --help Show Cast CLI help

📚 Resources


🤝 Contributing

  1. Fork the repo.
  2. Create a branch (git checkout -b feature/xyz).
  3. Make changes & commit.
  4. Push & open a PR.

Ensure tests pass.


📝 License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages