📈 GH Trending Explorer 🎲 Surprise me

← all repos

foundry-rs / forge-std

git clone https://github.com/foundry-rs/forge-std.git v1.17.0 · 20d ago 🔥 on GitHub Trending today

A collection of helpful contracts and libraries for use with Forge and Foundry

+0
stars, 24h · #623
+3
stars, 7 days · #1,618
+6
stars, 30 days · #10,032
1.1k
★ total · +0% this week
531
forks · 25 open issues

Star history starts 2026-10-20; the chart appears after the second daily snapshot.

LanguageSolidity
LicenseApache-2.0
Created2021-12-24 (4y ago)
Last push4d ago
Watchers17
OwnerOrganization

Seen on GitHub Trending

  • 2026-10-20 — #3 daily in solidity
  • 2026-10-20 — #3 monthly in solidity · +6 ★
  • 2026-10-20 — #2 weekly in solidity · +3 ★

GitHub topics

Links

README excerpt
# Forge Standard Library • 
Forge Standard Library is a collection of helpful contracts and libraries for use with Forge and Foundry. It leverages Forge's cheatcodes to make writing tests easier and faster, while improving the UX of cheatcodes.
**Learn how to use Forge-Std with the 📖 Foundry Book (Forge-Std Guide).**
## Install
 [code] 
## Contracts
### stdError
This is a helper contract for errors and reverts. In Forge, this contract is particularly helpful for the `expectRevert` cheatcode, as it provides all compiler built-in errors.
See the contract itself for all error codes.
#### Example usage
 [code] 
### stdStorage
This is a rather large contract due to all of the overloading to make the UX decent. Primarily, it is a wrapper around the `record` and `accesses` cheatcodes. It can _always_ find and write the storage slot(s) associated with a particular variable without knowing the storage layout. By default, writing to packed storage variables is not supported and will throw an error. However, you can enable packed slot support by calling `enable_packed_slots()` before using `find()` or `checked_write()`.
This works by recording all `SLOAD`s and `SSTORE`s during a function call. If there is a single slot read or written to, it immediately returns the slot. Otherwise, behind the scenes, we iterate through and check each one (assuming the user passed in a `depth` parameter). If the variable is a struct, you can pass in a `depth` parameter which is basically the field depth.
I.e.:
 [code] 
#### Example usage
 [code] 
### stdCheats
This is a wrapper around miscellaneous cheatcodes that need wrappers to be more dev-friendly. It includes functions for pranking, dealing with ETH and tokens, deploying contracts, creating test addresses, time manipulation, and fuzzing helpers. In general, users may expect ETH to be put into an address with `prank`, but this is not the case for safety reasons. Explicitly, this `hoax` function should only be used for addresses that have expected balances as it will get overwritten. If an address already has ETH, you should just use `prank`. If you want to change that balance explicitly, just use `deal`. If you want to do both, `hoax` is also right for you.
#### Example usage:
 [code] 
### Std Assertions
Provides comprehensive assertion functions for testing, including equality checks (assertEq, assertNotEq), comparisons (assertLt, assertGt, assertLe, assertGe), approximate equality (assertApproxEqAbs, assertApproxEqRel), and boolean assertions (assertTrue, assertFalse). All assertions support multiple data types and optional custom error messages.
### StdConfig
This is a contract that parses a TOML configuration file and loads its variables into storage, automatically casting them on deployment. It assumes a TOML structure where top-level keys represent chain IDs or aliases. Under each chain key, variables are organized by type in separate sub-tables like `[ . ]`, where type must be: `bool`, `address`, `bytes32`, `uint`