Skip to content

Latest commit

 

History

History
95 lines (76 loc) · 3.39 KB

README.md

File metadata and controls

95 lines (76 loc) · 3.39 KB

Foundry Fund Me Project

This repository contains the implementation of the Foundry Fund Me project, based on the course by Cyfrin Updraft. The project is a decentralized application (dApp) built using Foundry, which allows users to fund a smart contract and withdraw funds. It showcases fundamental concepts of Solidity, Ethereum development, and Foundry.

Table of Contents

Overview

The Fund Me project demonstrates how to:

Write and deploy a smart contract that accepts and manages funds. Implement withdrawal functionality with ownership constraints. Test contracts effectively using Foundry. This project serves as a hands-on practice exercise for developing decentralized applications and understanding core blockchain concepts.

Features

  • Funding: Users can send Ether to the contract to fund it.
  • Withdrawal: The contract owner can withdraw funds securely.
  • Ownership Management: Only the contract owner can withdraw funds.
  • Comprehensive Testing: Includes multiple tests to validate the contract's functionality and correctness.
  • Gas Optimization: Implemented best practices for efficient gas usage.

Prerequisites

Before running this project, ensure you have the following installed:

  • Foundry: The Ethereum development framework.
  • Node.js: For managing dependencies.
  • Git: To clone this repository.

Installation

  1. Clone the repository:
git clone https://github.com/KMean/fundry-fund-me.git
cd fundry-fund-me
  1. Install dependencies:
forge install
  1. Set up environment variables: Create a .env file and provide the necessary variables:
ALCHEMY_SEPOLIA_RPC_URL=<YOUR_RPC_URL>

Instead of using private keys in your .env file use the encrypted private key feature provided by forge:

cast wallet import your-account-name --interactive
Enter private key:
Enter password:
`your-account-name` keystore was saved successfully. Address: address-corresponding-to-private-key

Usage

Compile the Contract

forge build

Deploy the contract

forge script script/DeployFundMe.s.sol --rpc-url <RPC_URL> --account <YOUR_ENCRYPTED_ACCOUNT> --broadcast

Interact with the Contract

Use Foundry scripts to interact with the deployed contract:

  • Fund the contract: Call the fund function with the desired amount of Ether.
  • Withdraw funds: Only the owner can call the withdraw function.

Testing

Run the tests to ensure everything works as expected:

forge test

Tests include:

  • Funding the contract.
  • Ensuring only the owner can withdraw.
  • Verifying accurate balances.

Acknowledgments

  • Special Thanks to Cyfrin for creating some of the best courses on smart contracts development and to Patrick Collins for consistently delivering top-notch Web3 educational content. Your work inspires developers to excel in blockchain development.
  • Foundry for providing a robust blazing fast Ethereum development framework.
  • The Ethereum and Solidity communities for excellent resources and support.