Coder Social home page Coder Social logo

hello-foundry's Introduction

hello-foundry

https://github.com/foundry-rs/foundry

https://book.getfoundry.sh/

Basic

  • Install
curl -L https://foundry.paradigm.xyz | bash
foundryup
  • Init
forge init
  • Basic commands
forge build
forge test
forge test --match-path test/HelloWorld -vvvv

  • Test
    • counter app
    • test setup, ok, fail
    • match
    • verbose
    • gas report
forge test --match-path test/Counter.t.sol -vvv --gas-report

  • Solidity version and optimizer settings

https://github.com/foundry-rs/foundry/tree/master/config


  • Remapping
forge remappings
forge install rari-capital/solmate
forge update lib/solmate
forge remove solmate

npm i @openzeppelin/contracts

  • Formatter
forge fmt


  • console (Counter, test, log int)
forge test --match-path test/Console.t.sol -vv

Intermediate


  • Test auth
  • Test error
    • vm.expectRevert
    • require error message
    • custom error
    • label assertions
  • Test event (expectEmit)
  • Test time (Auction.sol)
  • Test send eth (Wallet.sol) - hoax, deal
  • Test signature

Advanced

  • mainnet fork
forge test --fork-url $FORK_URL --match-path test/Fork.t.sol -vvv
  • main fork deal (whale)
forge test --fork-url $FORK_URL --match-path test/Whale.t.sol -vvv

TODO: need working example for (mainnet - opt)

  • crosschain fork

  • Fuzzing (assume, bound)

forge test --match-path test/Fuzz.t.sol
  • Invariant
# Open testing
forge test --match-path test/invariants/Invariant_0.t.sol -vvv
forge test --match-path test/invariants/Invariant_1.t.sol -vvv
# Handler
forge test --match-path test/invariants/Invariant_2.t.sol -vvv
# Actor management
forge test --match-path test/invariants/Invariant_3.t.sol -vvv
  • FFI
forge test --match-path test/FFI.t.sol --ffi -vvv
  • Differential testing
# virtual env
python3 -m pip install --user virtualenv
virtualenv -p python3 venv
source venv/bin/activate

pip install eth-abi
FOUNDRY_FUZZ_RUNS=100 forge test --match-path test/DifferentialTest.t.sol --ffi -vvv

Misc

  • Vyper

https://github.com/0xKitsune/Foundry-Vyper

  1. Install vyper
# virtual env
python3 -m pip install --user virtualenv
virtualenv -p python3 venv
source venv/bin/activate

pip3 install vyper==0.3.7

# Check installation
vyper --version
  1. Put Vyper contract inside vyper_contracts
  2. Declare Solidity interface inside src
  3. Copy & paste lib/utils/VyperDeployer.sol
  4. Write test
forge test --match-path test/Vyper.t.sol --ffi
  • ignore error code
ignored_error_codes = ["license", "unused-param", "unused-var"]
  • Deploy
source .env
forge script script/Token.s.sol:TokenScript --rpc-url $GOERLI_RPC_URL --broadcast --verify -vvvv
  • Forge geiger
forge geiger

TODO:

  • chisel?
  • debugger?
  • forge snapshot?
  • script?

hello-foundry's People

Contributors

t4sk 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.