Foundry Asserts

Solidity Programming Language
2 min readMay 5, 2023


Foundry Asserts

Foundry asserts statements are assertEq, assertLt, assertLe, assertGt, assertGe, assertEqDecimal and assertTrue.

Solidity, a programming language tailored for developing smart contracts on blockchain platforms like Ethereum, has become integral to the burgeoning field of decentralized applications (dApps). A critical aspect of Solidity development is testing, ensuring that smart contracts function as intended in a secure, efficient manner. Foundry, a robust development toolkit for Ethereum, stands out in this landscape. It includes Foundry Asserts, a suite of testing tools designed to streamline and enhance the testing process for Solidity contracts. By employing Foundry Asserts, developers can write comprehensive, reliable tests, which are crucial for verifying contract logic, handling edge cases, and maintaining the integrity and security of decentralized applications.


We import assert from DSTest

Dappsys Test (DSTest for short) provides basic logging and assertion functionality. It is included in the Forge Standard Library.

To get access to the functions, import forge-std/Test.sol and inherit from Test in your test contract:

import “forge-std/Test.sol”;

contract AccessModifiers is Test {

// … tests …



  • assertEq, assert equal

(Where <type> can be address, bytes32, int, uint)

  • assertLt, assert less than

(Where <type> can be int, uint)

  • assertLe, assert less than or equal to

(Where <type> can be int, uint)

  • assertGt, assert greater than

(Where <type> can be int, uint)

  • assertGe, assert greater than or equal to

(Where <type> can be int, uint)

  • assertEqDecimal, assert equal decimals

(Where <type> can be int, uint)

  • assertTrue, assert to be true

(Asserts the condition is true.)



forge test -vvvv

Source: DSTest Reference





Solidity Programming Language

Solidity basics for beginners: Learn the fundamentals of smart contract development and build your first DApp! #Solidity #Foundry #Ethereum #Opcodes #DApps