πŸ“ˆ GH Trending Explorer 🎲 Surprise me

← all repos

foundry-rs / forge-std

git clone https://github.com/foundry-rs/forge-std.git v1.17.0 Β· 22d ago πŸ”₯ on GitHub Trending today

Solidity test helper library providing cheatcode wrappers, error constants, storage utilities, and assertions for Foundry tests.

Why you might care

Use it when writing Solidity tests with Forge or Foundry to get ergonomic wrappers around cheatcodes like prank, deal, and expectRevert. stdStorage can locate and write storage slots without knowing the layout, and stdError exposes compiler built-in error codes.

Categories

Alternatives

Hardhat Chai MatchersDSTestSolmate
+2
stars, 24h Β· #9,864
+3
stars, 7 days Β· #22,535
+8
stars, 30 days Β· #35,717
1.1k
β˜… total Β· +0% this week
533
forks Β· 25 open issues

Star history (as recorded here)

2026-10-20 Β· 1,058 β˜… 2026-10-23 Β· 1,062 β˜…
LanguageSolidity
LicenseApache-2.0
Created2021-12-24 (4y ago)
Last push6d ago
Watchers17
OwnerOrganization

Seen on GitHub Trending

  • 2026-10-23 β€” #2 daily in solidity
  • 2026-10-23 β€” #3 monthly in solidity Β· +8 β˜…
  • 2026-10-23 β€” #2 weekly in solidity Β· +2 β˜…
  • 2026-10-22 β€” #2 daily in solidity Β· +1 β˜…
  • 2026-10-22 β€” #3 monthly in solidity Β· +8 β˜…
  • 2026-10-22 β€” #2 weekly in solidity Β· +3 β˜…
  • 2026-10-21 β€” #3 daily in solidity
  • 2026-10-21 β€” #3 monthly in solidity Β· +6 β˜…
  • 2026-10-21 β€” #2 weekly in solidity Β· +2 β˜…
  • 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`

Blurb generated by claude-haiku-5-5 today. Star deltas marked ~ are extrapolated from partial history.