> ## Documentation Index
> Fetch the complete documentation index at: https://phylaxsystems-docs-project-incidents.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# credible-std Library

> Overview of the Phylax credible-std Library

`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](https://github.com/phylaxsystems/credible-std) and the [full API reference](https://phylaxsystems.github.io/credible-std/index.html).

## Installation

<Note>
  `credible-std` requires [Foundry](https://book.getfoundry.sh/getting-started/installation) to be installed on your system.
</Note>

### Option 1: Using Forge Install (Recommended)

The easiest way to install `credible-std` is to use `forge install`:

```bash theme={null}
forge install credible-std=https://github.com/phylaxsystems/credible-std/
```

### Option 2: Using Git Submodules

For more control over the dependency, you can add it as a git submodule:

```bash theme={null}
git submodule add https://github.com/phylaxsystems/credible-std.git lib/credible-std
```

### Setting Up Remappings

After installation, add the following to your `remappings.txt` file:

```bash theme={null}
credible-std/=lib/credible-std/src/
```

### Verifying Installation

To verify that `credible-std` is properly installed, create a simple test file:

```solidity theme={null}
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;

import {Assertion} from "credible-std/Assertion.sol";

contract TestAssertion is Assertion {
    function triggers() external view override {
        // Empty for testing
    }
}
```

If this compiles without errors, `credible-std` is properly installed and configured.

## Key Components

The `credible-std` library provides several essential components for implementing assertions:

### Core Contracts

* `Credible.sol`: Base contract that provides access to the PhEvm precompile for assertion validation
* `Assertion.sol`: Abstract contract for implementing assertions with trigger registration and validation logic
* `StateChanges.sol`: Utilities for tracking and validating contract state changes with type-safe conversions
* `TriggerRecorder.sol`: Manages assertion triggers for function calls, storage changes, and balance changes
* `PhEvm.sol`: Interface for the PhEvm precompile that enables assertion validation
* `CredibleTest.sol`: Testing utilities for assertion development and validation

### Features

1. **Trigger System**
   * Register triggers for function calls, storage changes, and balance changes
   * Monitor specific contract behaviors
   * Support for multiple trigger types

2. **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

3. **Advanced Forking Capabilities**
   * Fork to pre/post transaction states
   * Fork to specific call execution points
   * Granular state inspection at any call level

4. **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

5. **Testing Framework**
   * Testing utilities for assertion development and validation
   * Integration with Forge testing framework

6. **Debugging Tools**
   * Console logging for assertion debugging

For a detailed overview of currently supported use cases and examples, see our [Use Case Mappings](/credible/use-case-mappings/intro-use-case-mapping).

## 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](/credible/pcl-quickstart).

***

Missing a feature or cheatcode? Please [open an issue](https://github.com/phylaxsystems/credible-std/issues/new) with your feature request.
