Navigate:
Forge Std
~$FOST0.3%

Forge Std: Standard library for Foundry testing

Collection of contracts and libraries that provide testing utilities and cheatcode wrappers for Forge and Foundry.

LIVE RANKINGS • 03:09 AM • STEADY
OVERALL
#308
125
CRYPTO
#13
19
30 DAY RANKING TREND
ovr#308
·Crypt#13
STARS
1.0K
FORKS
459
7D STARS
+3
7D FORKS
+5
Tags:
See Repo:
Share:

Learn more about Forge Std

Forge Std is a standard library that provides helper contracts and utilities for testing Solidity smart contracts with Forge and Foundry. It wraps Forge's cheatcodes in developer-friendly interfaces and includes utilities for error handling, storage manipulation, and test assertions. The library includes stdError for compiler built-in errors, stdStorage for finding and writing to storage slots without knowing the layout, and stdCheats for enhanced pranking functionality. It serves as the foundation for most Foundry-based smart contract testing workflows.

Forge Std

1

Storage Introspection

Automatically finds and writes to storage slots of any variable without requiring knowledge of the contract's storage layout, using SLOAD/SSTORE recording.

2

Cheatcode Wrappers

Provides developer-friendly interfaces around Forge's low-level cheatcodes, including enhanced pranking with automatic ETH provisioning and improved assertion utilities.

3

Built-in Error Handling

Includes comprehensive error definitions for all Solidity compiler built-in errors, making expectRevert testing more reliable and readable.


import "forge-std/Test.sol";

contract TestContract is Test {
    ErrorsTest test;

    function setUp() public {
        test = new ErrorsTest();
    }

    function testExpectArithmetic() public {
        vm.expectRevert(stdError.arithmeticError);
        test.arithmeticError(10);
    }
}

contract ErrorsTest {
    function arithmeticError(uint256 a) public {
        a = a - 100; // This will underflow
    }
}


vv1.14.0

This is the first release that requires `^0.8.13`.

  • fix: limit to ^0.8.13 compatibility by @zerosnacks in
  • chore(deps): bump crate-ci/typos from 1.40.0 to 1.41.0 by @dependabot[bot] in
  • feat: cover with tests LibVariable array coercions by @phrwlk in
  • chore(release): bump to v1.14.0 by @zerosnacks in
  • @phrwlk made their first contribution in
vv1.13.0

This is the final release compatible with versions `< 0.8.13` (support previously aimed to cover `>= 0.6.2`).

  • feat(stdchains): add ink and ink sepolia default rpc endpoints by @CruzMolina in
  • feat: add StdConfig::exists method to check if key exists by @nikollamalic in
  • chore: update `exposed <functionname>` be consistent with lint mixed-case-function rule by @zerosnacks in
  • fix: config test to use reth, remove log from bound by @grandizzy in
  • Update README.md by @MonkeyKing44 in
vv1.12.0

v1.12.0: feat: `get/setEvmVersion`, `signWithNonceUnsafe`, `getStorageSlots` cheatcodes by @grandizzy in

  • feat: `get/setEvmVersion`, `signWithNonceUnsafe`, `getStorageSlots` cheatcodes by @grandizzy in
  • feat: add zero-division checks to stdMath.percentDelta overloads by @viktorking7 in
  • feat: add Unichain and Unichain Sepolia RPC URLs by @lababidi in
  • fix: assume not precompiles for optimism sepolia by @grandizzy in
  • fix: add missing deprecated log to second changePrank implementation by @estarossa0 in

See how people are using Forge Std

Loading tweets...


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers