credible-std
is the standard library for implementing assertions in the Credible Layer. It provides the core contracts and interfaces needed to create and manage assertions for smart contract security monitoring.
You can find the repository on GitHub.
Installation
credible-std
requires Foundry to be installed on your system.Option 1: Using Forge Install (Recommended)
The easiest way to installcredible-std
is to use forge install
:
Option 2: Using Git Submodules
For more control over the dependency, you can add it as a git submodule:Setting Up Remappings
After installation, add the following to yourremappings.txt
file:
Verifying Installation
To verify thatcredible-std
is properly installed, create a simple test file:
credible-std
is properly installed and configured.
Key Components
Thecredible-std
library provides several essential components for implementing assertions:
Core Contracts
Credible.sol
: Base contract that provides access to the PhEvm precompile for assertion validationAssertion.sol
: Abstract contract for implementing assertions with trigger registration and validation logicStateChanges.sol
: Utilities for tracking and validating contract state changes with type-safe conversionsTriggerRecorder.sol
: Manages assertion triggers for function calls, storage changes, and balance changesPhEvm.sol
: Interface for the PhEvm precompile that enables assertion validationCredibleTest.sol
: Testing utilities for assertion development and validation
Features
-
Trigger System
- Register triggers for function calls, storage changes, and balance changes
- Monitor specific contract behaviors
- Support for multiple trigger types
-
State Change Tracking
- Type-safe utilities for monitoring contract state changes
- Built-in conversion helpers
- Pre and post transaction state comparison
- Call stack level inspection of state changes
- Access to intermediate state during transaction execution
- Direct storage slot inspection and loading
-
Advanced Forking Capabilities
- Fork to pre/post transaction states
- Fork to specific call execution points
- Granular state inspection at any call level
-
Comprehensive Call Tracing
- Get all call inputs or filter by call type (CALL, STATICCALL, DELEGATECALL, CALLCODE)
- Avoid double-counting issues with proxy contracts
- Detailed call information including gas limits, values, and execution addresses
- Transaction log retrieval for assertion logic
-
Testing Framework
- Testing utilities for assertion development and validation
- Integration with Forge testing framework
-
Debugging Tools
- Console logging for assertion debugging
Solidity Integration
credible-std
is written in Solidity, making it seamlessly integrated with your existing smart contract development workflow. This means:
- No context switching or learning new languages
- Direct access to all Solidity features and tooling
- Familiar development experience
- Easy integration with existing contracts
- Full compatibility with Foundry testing framework
Getting Started
For installation and setup instructions, see the PCL Quickstart Guide.Missing a feature or cheatcode? Please open an issue with your feature request.