@celo/devchain-anvil

中文文档
17.0.7发布于 2026/06/17LGPL-3.0零依赖构建来源已验证近 30 天下载 3445

Anvil based devchain that contains core smart contracts of celo

原始使用文档
文档目录5 节
  1. Usage
  2. Example
  3. Background
  4. Limitations
  5. How we work

@celo/devchain-anvil

This package contains anvil state that allows you to start an anvil instance in seconds.

This anvil instance serves at localhost:8545 on your machine, and comes pre-configured with core contracts like the Registry contract (at 0x000000000000000000000000000000000000ce10). You can make RPC calls against this anvil instance as if you were interacting with Celo on Alfajores or Mainnet.

Usage

npm install --save-dev @celo/devchain-anvil
anvil --state <path_to_devchain.json>

Files in this package:

  1. Use devchain.json for a Celo L1-like devchain.
  2. Use l2-devchain.json for a Celo L2-like devchain.

Example

  1. Make a test directory

    # Create a demo directory
    $ mkdir ~/Documents/local-anvil-demo
    
    # Move into the demo directory
    $ cd ~/Documents/local-anvil-demo
    
  2. Install the package

    $ npm install --save-dev @celo/devchain-anvil
    
  3. Start an anvil instance with the state file from the package

    $ anvil --state node_modules/@celo/devchain-anvil/devchain.json
    
                                 _   _
                                (_) | |
          __ _   _ __   __   __  _  | |
         / _` | | '_ \  \ \ / / | | | |
        | (_| | | | | |  \ V /  | | | |
         \__,_| |_| |_|   \_/   |_| |_|
    
        0.2.0 (f625d0f 2024-04-02T00:16:42.824772000Z)
        https://github.com/foundry-rs/foundry
    
    Available Accounts
    ==================
    
    (0) 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266 (10000.000000000000000000 ETH)
    
    # ...
    Listening on 127.0.0.1:8545
    
  4. Make RPC calls against the anvil instance serving at http://127.0.0.1:8545

Background

Foundry allows you to start anvil instances with state you read from json files. The idea is to save the state of an anvil instance at a certain point in time, and then load it back up later.

$ anvil --state <PATH>
    This is an alias for both --load-state and --dump-state.

    It initializes the chain with the state and block environment stored at the file, if it
    exists, and dumps the chain's state on exit.

Source: Anvil docs

We use this feature to pre-configure an anvil instance with core contracts and other state, and then start it up in seconds for testing. We call this a "devchain". The scripts we use to configure the devchain are here: celo-org/celo-monorepo/ > packages/protocol/migrations_sol

Limitations

The anvil instance is not a full Celo node. It is a lightweight, in-memory instance that you can use for testing.

  1. It does not sync with the Celo network ❌
  2. It does not persist data between sessions ❌
  3. It does not support all RPC methods ❌
  4. It does not support fee currency transactions (like CIP64 or CIP66) ❌
  5. It does not support all Celo pre-compiles ❌

How we work

We are a GitHub-first team, which means we have a strong preference for communicating via GitHub. Please use GitHub to:

🐞 File a bug report

💬 Ask a question

✨ Suggest a feature

🧑‍💻 Contribute!

🚔 Report a security vulnerability

[!TIP]

Please avoid messaging us via Slack, Telegram, or email. We are more likely to respond to you on GitHub than if you message us anywhere else. We actively monitor GitHub, and will get back to you shortly 🌟

版本与发布记录

@celo/devchain-anvil 共发布 157 个版本,首次发布于 2024/05/27;过去 12 个月发布了 27 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
17.0.7latest2026/06/174 个月前
17.0.62026/06/174 个月前
17.0.52026/06/174 个月前
17.0.42026/06/174 个月前
17.0.32026/06/174 个月前
17.0.22026/06/174 个月前

其他发布通道:layer-two-devchain-test → 2.0.0-layer-two-devchain-test.0,fix-supply-test → 10.0.0-fix-supply-test.0,epoch-manager → 12.0.0-epoch-manager.1,debug → 12.0.0-debug.1,pre-audit → 13.0.0-pre-audit.0,canary → 16.0.0-canary.10。

关于 @celo/devchain-anvil 的常见问题

@celo/devchain-anvil 是什么?

Anvil based devchain that contains core smart contracts of celo

如何安装 @celo/devchain-anvil?

在项目目录运行 npm install @celo/devchain-anvil,或使用 pnpm add / yarn add / bun add。

@celo/devchain-anvil 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/celo__devchain-anvil 是否存在。

@celo/devchain-anvil 可以商用吗?

@celo/devchain-anvil 使用 LGPL-3.0 许可。弱 Copyleft:作为库被调用时通常不要求开源你自己的代码,但修改库本身需以 LGPL 开源;前端打包合并后的适用边界存在不同理解。以上为概括,不构成法律意见,请以许可原文为准。

@celo/devchain-anvil 的下载量有多少?

根据 npm 官方下载统计,@celo/devchain-anvil 在 2026/10/10 – 2026/11/08 这 30 天内被下载 3,445 次,日均约 115 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@celo/devchain-anvil 还在维护吗?

最新版本 17.0.7 发布于 2026/06/17(4 个月前);至今共发布 157 个版本,其中过去 12 个月发布了 27 个;首次发布于 2024/05/27。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。