Giter Site home page Giter Site logo

0x5am / foundry-fund-me Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 29 KB

A simple crowdsourcing smart contract built with Solidity. Created as part of Cyfrin's Updraft Solidity course.

License: MIT License

Makefile 10.12% Solidity 89.88%
smart-contracts solidity

foundry-fund-me's Introduction

Contributors Forks Stargazers Issues MIT License LinkedIn


Foundry FundMe

A crowdsourcing DAPP built to deploy on Ethereum.
Explore the docs »

View Demo · Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Deploy
  5. License
  6. Contact

About The Project

This project was created in conjunction with Patrick Collins as part of Cyfrin's Updraft solidity course. This is a simple smart contract which allows crowdsourcing on the Ethereum mainnet.

(back to top)

Built With

This section should list any major frameworks/libraries used to bootstrap your project. Leave any add-ons/plugins for the acknowledgements section. Here are a few examples.

  • Solidity

(back to top)

Getting Started

Prerequisites

  • git
    • If you have correctly installed git you should see a response similar to the one below when you run git --version
      git --version
      git version x.x.x
  • foundry
    • If you have correctly installed git you should see a response similar to the one below when you run forge --version
      forge --version
      forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)

Installation

  1. Clone the repo
    git clone https://github.com/0x5am/foundry-fund-me
  2. Navigate to the repo
    cd foundry-fund-me
  3. Execute the makefile
    make

(back to top)

Usage

Deploy

forge script script/DeployFundMe.s.sol

(back to top)

Local zkSync Deployment

The following instructions will allow you to work with this repository in zkSync.

(Additional) Requirements

In addition to the requirements above, you will also need:

  • foundry-zksync

    • If you have correctly installed git you should see a response similar to the one below when you run forge --version
      forge --version
      forge 0.0.2 (816e00b 2023-03-16T00:05:26.396218Z)
  • npx & npm

      • If you have correctly installed git you should see a response similar to the one below when you run npm --version
      npm --version
      8.1.0
  • docker

    • If you have correctly installed git you should see a response similar to the one below when you run docker --version
      docker --version
      Docker version 20.10.7, build f0df35
    • To make sure the daemon is running correctly you should see a similar response when you run sh docker --info
      Client:
        Context:    default
        Debug Mode: false

(back to top)

Setup local zkSync node

Run the following commands:

npx zk-sync-cli dev config

Select In memory node and do not select any additional modules. Then run the following command:

npx zksync-cli dev start

If done correctly, you should see an output similar to the following:

In memory node started v0.1.0-alpha.22:
 - zkSync Node (L2):
  - Chain ID: 260
  - RPC URL: http://127.0.0.1:8011
  - Rich accounts: https://era.zksync.io/docs/tools/testing/era-test-node.html#use-pre-configured-rich-wallets

Deploy to local zkSync node

make deploy-zk

This will deploy a mock price feed and fund me contract to the zkSync node using a custom makefile shortcut.

(back to top)

Deployment to a testnet or mainnet

  1. Set up your environment variables
  • You'll want to set your TESTNET_RPC_URL and PRIVATE_KEY as environment variables in a .env file.
    • PRIVATE_KEY: The private key of your account/wallet (like MetaMask, for example). NOTE: THIS IS FOR DEVELOPMENT PURPOSES ONLY, PLEASE DO NOT USE AN ACCOUNT THAT HAS ANY REAL FUNDS ASSOCIATED.
    • TESTNET_RPC_URL: This should be the url of whatever testnet node you are working with. This project was tested on the Seplolia testnet, you can set up one for free with Alchemy.
    • Optionally, you can add your ETHERSCAN_API_KEY if you wish to verify your contract on Etherscan.
  1. Get testnet ETH
  • Head over to any faucet (Chainlink, Google, Alchemy). After a few minutes the testnet ETH should appear in your wallet.
  1. Deploy using the following command:
forge script script/DeployFundMe.s.sol --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY

Scripts

After deploying to a testnet or local net, you will be able to run the scripts. This can be done using cast when deployed locally:

cast send <FUNDME_CONTRACT_ADDRESS> "fund()" --value 0.1ether --private-key <PRIVATE_KEY>

or

forge script script/Interactions.s.sol:FundFundMe --rpc-url sepolia  --private-key $PRIVATE_KEY  --broadcast
forge script script/Interactions.s.sol:WithdrawFundMe --rpc-url sepolia  --private-key $PRIVATE_KEY  --broadcast

Withdraw

cast send <FUNDME_CONTRACT_ADDRESS> "withdraw()"  --private-key <PRIVATE_KEY>

Estimate gas

You can estimate how much gas each of your functions cost by running the following command:

forge snapshot

If done correctly, you will see an output file called .gas-snapshot.

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

@_0x5am

https://github.com/0x5am/foundry-fund-me

(back to top)

foundry-fund-me's People

Contributors

0x5am avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.