Giter Site home page Giter Site logo

foundry-rs / book Goto Github PK

View Code? Open in Web Editor NEW
721.0 16.0 535.0 6.61 MB

A book on all things Foundry, available at https://book.getfoundry.sh.

Home Page: https://book.getfoundry.sh

License: Apache License 2.0

Handlebars 1.32% Solidity 27.20% Roff 10.59% Shell 28.38% CSS 1.98% Python 30.53%
foundry documentation guides ethereum book mdbook

book's Introduction

๐Ÿ“– Foundry Book

All Contributors

A book on all things Foundry. Read now.

Contributing

Check our contributing guidelines. Feel free to contribute wording, sentences, chapters, and guides!

The book is build with mdbook, which you can get by running cargo install mdbook.

The book also requires mdbook-external-links: cargo install mdbook-external-links.

To see the book change live run:

mdbook serve

To run the book with docker, run:

docker run -p 3000:3000 -v `pwd`:/book peaceiris/mdbook serve

To add a new section (file) to the book, add it to SUMMARY.md.

For a more structured overview of the current issues, see the GitHub project.

Contributors โœจ

Thanks goes to these wonderful people (emoji key):

Zero Ekkusu
Zero Ekkusu

๐Ÿ“– ๐Ÿ‘€ ๐Ÿšง
Rootul Patel
Rootul Patel

๐Ÿ“– ๐Ÿšง ๐Ÿ‘€
zk-tarts
zk-tarts

๐Ÿ“–
Nicholas
Nicholas

๐Ÿ“–
metehan
metehan

๐Ÿ“–
Harris
Harris

๐Ÿšง
Rajesh Muppalla
Rajesh Muppalla

๐Ÿšง
Matt Solomon
Matt Solomon

๐Ÿ“–
Ruvaag
Ruvaag

๐Ÿšง
awolff
awolff

๐Ÿšง
kayaba-attribution
kayaba-attribution

๐Ÿ“–
Noah Citron
Noah Citron

๐Ÿ‘€
Sabnock
Sabnock

๐Ÿ“–
Ikko Ashimine
Ikko Ashimine

๐Ÿšง
Ed Mazurek
Ed Mazurek

๐Ÿšง
devtooligan
devtooligan

๐Ÿšง ๐Ÿ“–
0xfoobar
0xfoobar

๐Ÿ“–
odyslam.eth
odyslam.eth

๐Ÿšง
FredCoen
FredCoen

โœ…
bblanc42
bblanc42

๐Ÿ“–
0xMySt1c
0xMySt1c

๐Ÿšง
Bjerg
Bjerg

๐Ÿšง ๐Ÿ“– ๐Ÿ‘€
Georgios Konstantopoulos
Georgios Konstantopoulos

๐Ÿ‘€
Devan Non
Devan Non

๐Ÿ“–
josht
josht

๐Ÿšง
dmfxyz
dmfxyz

๐Ÿšง ๐Ÿ‘€ ๐Ÿ“–
Drake Evans
Drake Evans

๐Ÿšง
Paul Razvan Berg
Paul Razvan Berg

๐Ÿšง
Perelyn Sama
Perelyn Sama

๐Ÿšง ๐Ÿ“–
N
N

๐Ÿ“–
John Adler
John Adler

๐Ÿšง
0xTaylor
0xTaylor

๐Ÿšง
0xCookedRice
0xCookedRice

๐Ÿšง
Dan Hepworth
Dan Hepworth

๐Ÿšง
tobias
tobias

๐Ÿšง
anticlimactic
anticlimactic

๐Ÿšง ๐Ÿ“–
Pedro Maia
Pedro Maia

๐Ÿ“–
Erick
Erick

๐Ÿšง
Will Minshew
Will Minshew

๐Ÿ“–
Dave Belvedere
Dave Belvedere

๐Ÿšง
A.L.
A.L.

๐Ÿšง
p0n1
p0n1

๐Ÿšง
Rohan Kulkarni
Rohan Kulkarni

๐Ÿšง
Galmoli
Galmoli

๐Ÿšง
Tom
Tom

๐Ÿšง
Andrey Leutwiler Gomes
Andrey Leutwiler Gomes

๐Ÿšง ๐Ÿ“–
Joshua Trujillo
Joshua Trujillo

๐Ÿ“–
calnix
calnix

๐Ÿ“–
Matthias Seitz
Matthias Seitz

๐Ÿšง ๐Ÿ“–
xaaru
xaaru

๐Ÿšง
Wias Liaw
Wias Liaw

๐Ÿšง
Shawn Harmsen
Shawn Harmsen

๐Ÿ“– ๐Ÿšง
Ward Bradt
Ward Bradt

๐Ÿšง
๏ฝ“๏ฝ‰๏ฝ‡๏ฝˆ
๏ฝ“๏ฝ‰๏ฝ‡๏ฝˆ

๐Ÿ“–
James Bachini
James Bachini

๐Ÿšง
Zach Obront
Zach Obront

๐Ÿšง
Scott Tsai
Scott Tsai

๐Ÿšง
Kristian Quirapas
Kristian Quirapas

๐Ÿšง
Bruno Filetti
Bruno Filetti

๐Ÿ“–
Pranesh A S
Pranesh A S

๐Ÿšง
0xYYY
0xYYY

๐Ÿ“–
Julian Martinez
Julian Martinez

๐Ÿšง
Tirth Patel
Tirth Patel

๐Ÿšง
Nader Dabit
Nader Dabit

๐Ÿšง
h00p30
h00p30

๐Ÿ“–
beskay
beskay

๐Ÿšง
fangjun
fangjun

๐Ÿšง
Bento Box
Bento Box

๐Ÿ“–
appleseed-iii
appleseed-iii

๐Ÿ“–
soyboy
soyboy

๐Ÿ“–
double v
double v

๐Ÿ‘€
skaunov
skaunov

๐Ÿšง
t11s
t11s

๐Ÿšง
Murphy Law
Murphy Law

๐Ÿ“–
Arbiter
Arbiter

๐Ÿ“–
neodaoist
neodaoist

๐Ÿ“–
minaminao
minaminao

๐Ÿšง
Fidel Ramos
Fidel Ramos

๐Ÿšง
Elijah Sullivan
Elijah Sullivan

๐Ÿ“–
m0ham3dx
m0ham3dx

๐Ÿšง
Yuqi Liu
Yuqi Liu

๐Ÿšง
ControlCplusControlV
ControlCplusControlV

๐Ÿšง
Charles Azanlekor
Charles Azanlekor

๐Ÿšง
Abhi Gulati
Abhi Gulati

๐Ÿšง
Karim Helmy
Karim Helmy

๐Ÿšง
HashHaran
HashHaran

๐Ÿ“–
omahs
omahs

๐Ÿšง
Franfran
Franfran

๐Ÿ“–
DaniPopes
DaniPopes

๐Ÿšง
Stijn Balk
Stijn Balk

๐Ÿ“–
Salief Lewis
Salief Lewis

๐Ÿ“–
ryzhak
ryzhak

๐Ÿ“–
Enrique Ortiz
Enrique Ortiz

๐Ÿ“–
Massimiliano Tomassoli
Massimiliano Tomassoli

๐Ÿ“–
mr-roh
mr-roh

๐Ÿ“–
Chirag Baghasingh
Chirag Baghasingh

๐Ÿ“–
Amin Bashiri
Amin Bashiri

๐Ÿ“–
ibremseth
ibremseth

๐Ÿ“–
Alexe Luca Spataru
Alexe Luca Spataru

๐Ÿ“–
Riley
Riley

๐Ÿ“–
Yotam Bar-On
Yotam Bar-On

๐Ÿ“–
Tudor
Tudor

๐Ÿ“–
Chris Cushman
Chris Cushman

๐Ÿ“–
ernestor.eth
ernestor.eth

๐Ÿ“–
Asir Shahriar Roudra
Asir Shahriar Roudra

๐Ÿ“–
stitetsati
stitetsati

๐Ÿ“–
William Cheung
William Cheung

๐Ÿ’ป
Zhuo Zhang
Zhuo Zhang

๐Ÿ’ป
Anton Totomanov
Anton Totomanov

๐Ÿ’ป

This project follows the all-contributors specification.

book's People

Contributors

0xvv avatar allcontributors[bot] avatar appleseed-iii avatar danipopes avatar devanoneth avatar dmfxyz avatar evalir avatar github-actions[bot] avatar klkvr avatar l0gykal avatar leutwiler avatar m0ham3dx avatar mattsse avatar mds1 avatar odyslam avatar omahs avatar onbjerg avatar paulrberg avatar perelyn-sama avatar portdeveloper avatar rkrasiuk avatar robriks avatar rootulp avatar sabnock01 avatar sbvegan avatar shawnharmsen avatar skaunov avatar wiasliaw avatar wildmolasses avatar zeroekkusu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

book's Issues

Document `forge run`

This is the original PR, but it might have changed a bit since then - most notably the debugger is accessible only through this command for the time being.

DSTest examples might be incorrect

File: ds-test.md

Issue: The docs might be incorrect

Getting TypeError: No unique declaration found after argument-dependent lookup. when an int_const is passed to an assertion function.

// function assertEq(uint a, uint b) internal;
assertEq(1 ether, 1e18 wei);

Meanwhile, logging works fine:

// event log_uint(uint);
emit log_uint(1 ether);

Solution: I will fix the docs if others are getting the same error.

No guidance on how to import "cheats.expectRevert"

While reading the Writing Tests chapter, I stumbled upon the following code snippet:

function testCannotSubtract43() public {
    cheats.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11));
    testNumber -= 43;
}

I tried to run it but I got the following error:

Error:
   0: Compiler run failed
      DeclarationError: Undeclared identifier.
        --> /Users/paulrberg/workspace/templates/foundry-template/test/Contract.t.sol:22:9:
         |
      22 |         cheats.expectRevert(abi.encodeWithSignature("Panic(uint256)", 0x11));
         |         ^^^^^^

It looks like the docs are not showing how to import and initialize the cheats when first mentioning them.

Add note about `extcodesize` for `vm.mockCall`

If you mock a call on an address with no code the call might fail regardless because Solidity does an extcodesize check before calls under normal circumstances. Can be fixed by using vm.etch in tandem

Automate some documentation

It would be nice to automate some parts of the documentation, such as the overall reference for cast, forge and the output of specific commands. This will require some scripts, and it might be possible to use the output of forge --help/cast --help or rustdoc in some way.

We still want to retain examples and so on, so it will require some thinking. If this can be pulled off, it would mean that some documentation is essentially written by improving the output of the help commands on the relevant commands upstream in Foundry, which will increase the quality of those

Chapters on upcoming features

We should add chapters on the following features when they are released:

Landed recently:

Coming later:

  • Coverage reports
  • Invariant tests
  • Symbolic testing
  • Mutation testing
  • Documentation generation
  • Deployment system

Switch host

The book should probably be deployed to Netlify or Vercel so we can have previews in pull requests

Book restructuring

I want to restructure the book a bit by including section headers, draft chapters and removing some chapters that just take up space.

Draft SUMMARY.md:

# Summary

[Introduction](./README.md)

# Getting Started

- [Installation](./getting-started/installation.md)
- [First Steps with Foundry](./getting-started/first-steps.md)

# Forge Overview

- [What is Forge?](./forge/README.md)
- [Projects]()
  - [Creating a New Project](./forge/creating-a-new-project.md)
  - [Working on an Existing Project](./forge/working-on-an-existing-project.md)
  - [Dependencies](./forge/dependencies.md)
  - [Project Layout](./forge/project-layout.md)
  - [Configuring with `foundry.toml`](./forge/config.md)
- [Tests](./forge/tests.md)
  - [Writing Tests](./forge/writing-tests.md)
  - [Cheatcodes](./forge/cheatcodes.md)
  - [Understanding Traces](./forge/traces.md)
  - [Forking Mode](./forge/forking-mode.md)
  - [Coverage Reports]()
- [Advanced Testing](./forge/advanced-testing.md)
  - [Fuzz Testing](./forge/fuzz-testing.md)
  - [Invariant Testing]()
  - [Symbolic Testing]()
  - [Table Testing]()
  - [Mutation Testing]()
- [Linting and Formatting]()
- [Generating Documentation]()
- [Deploying and Verifying](./forge/deploying.md)
- [Gas Tracking](./forge/gas-tracking.md)
  - [Gas Reports]()
  - [Gas Snapshots]()
- [Debugger](./forge/debugger.md)

# Cast Overview

- [What is Cast?](./cast/cast-overview.md)

# Additional Configuration

- [Integrating with VSCode](./guides/vscode.md)
- [Shell Autocompletion](./guides/shell-autocompletion.md)
- [Continuous Integration](./forge/continous-integration.md)

# Tutorials

- [Creating an NFT with Solmate and Foundry](./tutorials/solmate-nft.md)
- [Incremental Adoption]()

# References

- [`forge` Reference]()
- [`cast` Reference](./reference/cast.md)
- [`foundry.toml` Reference](./reference/config.md)
- [`ds-test` Reference](./reference/ds-test.md)
- [Cheatcodes Reference](./reference/cheatcodes.md)

Add Test Contract address to foundry.toml Reference

Test contracts are deployed to 0xb4c79dab8f259c7aee6e5b2aa729821864227e84, but this address is not listed in the config.md reference.

A quick test confirms this is the deploy address.

//SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.8.0 <0.9.0;

import "ds-test/test.sol";

contract JustChecking is DSTest{
    function testDeployer() public {
        emit log_named_address("msg.sender", msg.sender);
        emit log_named_address("tx.origin", tx.origin);
        emit log_named_address("this", address(this));
    }
}

Output

Logs:
  msg.sender: 0x00a329c0648769a73afac7f9381e08fb43dbea72
  tx.origin: 0x00a329c0648769a73afac7f9381e08fb43dbea72
  this: 0xb4c79dab8f259c7aee6e5b2aa729821864227e84

I do not know if there is an environment variable in Forge to control the test deploy address. In DS-Test this environment variable is called DAPP_TEST_ADDRESS (see here).

It is useful to have this address somewhere in the documentation because this contract is the default owner of contracts deployed by the test.

Add contributing guide

Should contain:

  • General ideas on structure
  • General ideas on wording
  • What the labels mean

Chapters on current features

Meta

  • Introduction

Getting started

  • Installation
  • First steps with Foundry

Forge

  • Creating a new project
  • Working on an existing project
  • Dependencies
    • Add sections on forge remove and forge update
    • Document release/tag behavior
  • Project layout
  • foundry.toml
  • Tests
    • Writing tests
    • Cheatcodes
    • Understanding traces
  • Advanced Testing
    • Fuzz testing
  • Continous integration
  • Debugger
  • Cache
  • Deployment (as of now, forge create)

Additional guides

  • Incremental adoption
  • Integrating with VSCode
  • Shell autocompletion

Reference

  • ds-test Reference
  • foundry.toml Reference
  • Cheatcodes Reference

Encountered error using "expectRevert"

Encountered error

> forge test
compiling...
Compiling 1 files with 0.8.12
Compilation finished successfully
Error:
   0: Compiler run failed
      TypeError: Member "expectRevert" not found or not visible after argument-dependent lookup in contract CheatCodes.
        --> /Users/rootulp/git/rootulp/hello_foundry/src/Contract.sol:43:5:
         |
      43 |     cheats.expectRevert(
         |     ^^^^^^^^^^^^^^^^^^^

while trying to reproduce and update the output for https://github.com/onbjerg/foundry-book/blame/master/src/forge/cheatcodes.md#L124

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.