登录 注册
其他
1,064
Stars
—
Forks
0
Watchers
—
Open Issues
待补全
许可证
Solidity
语言
—
创建时间
最近更新

项目能做什么

配合 Forge 和 Foundry 使用的智能合约与实用函数库集合。
来源:AI 基于仓库事实生成 · 内容以仓库实际 README 为准

使用说明 查看原始 README 原仓库文档

中文使用说明暂未生成。下面保留原仓库 README 摘录,命令与配置均以原文为准。
原始 README 摘录(英文原文,节选前 3000 字符)
# Forge Standard Library • [![CI status](https://github.com/foundry-rs/forge-std/actions/workflows/ci.yml/badge.svg)](https://github.com/foundry-rs/forge-std/actions/workflows/ci.yml)

Forge Standard Library is a collection of helpful contracts and libraries for use with [Forge and Foundry](https://github.com/foundry-rs/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)](https://getfoundry.sh/reference/forge-std/overview/).**

## Install

```bash
forge install foundry-rs/forge-std
```

## 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

```solidity

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;
    }
}
```

### 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.:

```solidity
struct T {
    // depth 0
    uint256 a;
    // depth 1
    uint256 b;
}
```

#### Example usage

```solidity
import "forge-std/Test.sol";

contract TestContract is Test {
    using stdStorage for StdStorage;

    Storage test;

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

    function testFindExists() public {
        // Let's say we want to find the slot for the public
        // variable `exists`. We just pass in the function selector
        // to the `find` command
        uint256 slot = stdstore.target(address(test)).sig("exists()").find();
        assertEq(slot, 0);
    }

    function testWriteExists() public {
        // Let's say we want to write to the slot for the public
        // variable `exists`. We just pass in the function se
阅读完整原文

项目深度分析 AI 生成

高级 DeFi 测试场景与 Mock 数据资产包(订阅制/买断)

产品构想基于 forge-std 开发开箱即用的复杂 DeFi 协议交互与高保真 Mock/Fork 测试脚手架(如 Uniswap V3/V4, Aave, Compound 等深度集成的测试套件和预置 Cheatcodes 扩展)。
核心功能一键本地 Fork 环境重现复杂交互;常见协议的接口 Mock 与状态速查库;预置套利、清算等边缘场景测试用例模板。
目标用户独立 DeFi 开发者、中小型 Web3 协议开发团队
难度/周期中等 · 1-2 个月 · 成本:极低(主要为开发和维护时间成本)
收费模式开源基础版,专业级复杂协议测试套件采用付费 License 或 GitHub Sponsors / Gumroad 售卖。
竞争风险DeFi 协议接口升级需频繁维护;开发者偏好自行编写简易 Mock。
依据 已验证事实

基于 Foundry 的安全审计辅助与断言规则库 (SaaS / CLI 工具)

产品构想结合 forge-std 的 cheatcodes,构建自动化不变性测试(Invariant Testing)与模糊测试(Fuzzing)模板生成器,生成可用于安全审计报告的回归验证脚本。
核心功能常见漏洞(重入、溢出、访问控制)的不变性断言规则库;一键导出覆盖率与攻击模拟结果;与 CI 深度集成的自动化审计检查脚本。
目标用户智能合约安全审计师、协议安全工程师
难度/周期高 · 2-3 个月 · 成本:低(云端测试运行节点或本地 CLI 分发)
收费模式SaaS 订阅制(按月收取 CI 分析费用)或针对审计团队的席位授权许可。
竞争风险安全工具市场竞争激烈(已有 Slither、Echidna、Certora 等成熟竞品)。
依据 数据支持的判断

企业级智能合约 CI/CD 测试加速与云端沙盒服务

产品构想提供围绕 Foundry/forge-std 的测试监控平台,提供主网状态快照缓存、测试用例并行化加速、覆盖率可视化报告展示。
核心功能私有 RPC 快照缓存加速 fork 测试;GitHub Actions / GitLab CI 无缝集成插件;详细的 Gas 消耗与回归性能对比面板。
目标用户中大型 Web3 项目团队、去中心化自治组织 (DAO) 核心开发组
难度/周期高 · 3-4 个月 · 成本:中等(RPC 节点成本、云服务器算力)
收费模式按测试构建时长与 RPC 流量阶梯计费(Usage-based SaaS)。
竞争风险需要维护稳定的 RPC 基础设施,运维成本相对较高。
依据 AI推测
AI 基于仓库公开数据分析生成,含推测成分,不构成收益承诺。
报告会保存到 个人中心

竞品与相似项目 GitHub Search 真实检索

相似项目数据正在完善中,暂不展示(避免误导)

项目优势与风险

技术成熟度创建时间待补全,最近推送 ,发布过 44 个 Release
社区活跃Star 1,064 / Fork 0 / Issue 0(数据支持,可自行核实)
许可证未检测到(需人工确认)
主要风险上游项目方向可能变化;同赛道竞争者较多(见竞品表);热度与需求不完全等价

安装与使用

此项目未提供 Docker 镜像,安装步骤以原仓库 README 为准(涉及依赖安装与环境配置,对新手门槛较高)。