npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gate-evm-check-code

v1.0.0

Published

检查链下合约代码和链上合约代码是否一致的 CLI 工具

Readme

Bytecode Checker CLI

🔍 检查链下合约代码和链上合约代码是否一致的 CLI 工具

功能特性

  • ✅ 支持检查单个合约、指定网络或所有合约
  • ✅ 智能识别 Constructor 参数差异和 Immutable 变量差异
  • ✅ 自动移除元数据进行比较
  • ✅ 生成详细的 JSON 报告
  • ✅ 支持增量更新报告

一、发布 NPM 包

1. 准备发布

# 进入项目目录
cd evm-checkcode-cli

# 安装依赖
npm install

# 编译 TypeScript
npm run build

2. 配置 NPM 账户

# 登录 NPM(如果还未登录)
npm login

# 输入用户名、密码、邮箱

3. 发布到 NPM

# 检查包信息
npm pack --dry-run

# 发布包
npm publish

# 如果包名已被占用,可以发布到作用域下
# 先修改 package.json 中的 name 为 "@your-username/bytecode-checker-cli"
# 然后执行:
npm publish --access public

4. 更新版本

# 更新补丁版本(1.0.0 -> 1.0.1)
npm version patch

# 更新小版本(1.0.0 -> 1.1.0)
npm version minor

# 更新大版本(1.0.0 -> 2.0.0)
npm version major

# 发布新版本
npm publish

二、使用 NPM 包

1. 安装

在你的 Hardhat 项目中安装:

npm install --save-dev bytecode-check

或全局安装:

npm install -g bytecode-check

2. 创建配置文件

在项目根目录创建 contractInfo.json 文件:

{
  "eth": {
    "Vault": "0x80aaf2e4636c510e067a5d300d8bafd48027addf",
    "VaultCrossChainRelay": "0x060194eec4556096baaabd6bf553d2658d6a66ab"
  },
  "bsc": {
    "Vault": "0x2cb7d2603a5f43b9fe79e98f09fe3eec40b6765d",
    "VaultCrossChainRelay": "0x23ae3a565e0896866e7725fe6d49fd777359c162"
  }
}

格式说明:

  • 第一层 key 是网络名称(必须与 hardhat.config.js 中的网络名称一致)
  • 第二层 key 是合约名称(必须与编译的合约名称一致)
  • value 是合约地址

3. 配置 Hardhat

确保 hardhat.config.js 中配置了相应的网络:

module.exports = {
  networks: {
    eth: {
      url: "https://eth-mainnet.g.alchemy.com/v2/YOUR-API-KEY",
    },
    bsc: {
      url: "https://bsc-dataseed.binance.org/",
    }
  }
};

4. 编译合约

npx hardhat compile

5. 执行检查

# 检查所有合约
npx bytecode-check check

# 检查指定合约
npx bytecode-check check --contract Vault

# 检查指定网络
npx bytecode-check check --network eth

# 指定配置文件路径
npx bytecode-check check --config ./config/contracts.json

# 指定输出报告路径
npx bytecode-check check --output ./reports/result.json

6. 命令选项

| 选项 | 简写 | 说明 | 默认值 | |------|------|------|--------| | --contract <name> | -c | 指定要检查的合约名称 | - | | --network <name> | -n | 指定要检查的网络名称 | - | | --config <path> | - | 指定配置文件路径 | ./contractInfo.json | | --output <path> | -o | 指定输出报告文件路径 | ./bytecode-check-report.json |

三、输出示例

✓ 已加载配置文件: /path/to/contractInfo.json

配置文件: /path/to/contractInfo.json
网络数量: 2
  - eth: 2 个合约
  - bsc: 2 个合约

ℹ 检查所有合约...
✓ 检查完成,共 4 个合约

================================================================================
字节码检查报告
================================================================================

总计检查: 4
✓ 匹配: 4
✗ 不匹配: 0
⚠ 错误: 0

✅ 匹配的合约:
--------------------------------------------------------------------------------
Vault (eth): 完全匹配
VaultCrossChainRelay (eth): Constructor参数差异
Vault (bsc): 完全匹配
VaultCrossChainRelay (bsc): 完全匹配

✓ 报告已保存: /path/to/bytecode-check-report.json

四、报告文件格式

生成的 bytecode-check-report.json 文件格式:

{
  "eth": {
    "Vault": {
      "contract": "Vault",
      "address": "0x80aaf2e4636c510e067a5d300d8bafd48027addf",
      "matches": true,
      "error": null,
      "reason": "完全匹配",
      "onChainBytecodeLength": 12345,
      "localBytecodeLength": 12345
    }
  },
  "bsc": {
    "Vault": {
      "contract": "Vault",
      "address": "0x2cb7d2603a5f43b9fe79e98f09fe3eec40b6765d",
      "matches": true,
      "error": null,
      "reason": "完全匹配",
      "onChainBytecodeLength": 12345,
      "localBytecodeLength": 12345
    }
  }
}

五、常见问题

Q: 提示找不到配置文件怎么办?

A: 确保在项目根目录创建了 contractInfo.json 文件,或使用 --config 参数指定路径。

Q: 提示不是 Hardhat 项目怎么办?

A: 确保在 Hardhat 项目根目录下运行命令,并且存在 hardhat.config.jshardhat.config.ts 文件。

Q: 如何处理 Constructor 参数差异?

A: Constructor 参数差异是正常的,工具会智能识别并标记为"匹配"。

许可证

MIT

作者

kiro