@chainlink/evm-gauntlet-vrfv2plus

中文文档
5.13.0发布于 2024/07/12TypeScriptCommonJS近 30 天下载 1万

EVM 勇士号VRFV2 加号

中文使用文档
文档目录11 节
  1. 仓库依赖性
  2. 所需工具
  3. 设置
  4. 运行测试
  5. 更新合同 ABIs 和字节代码
  6. 使用脚本
  7. 已知的脚本问题
  8. 手工步骤
  9. 为新合同添加命令
  10. 软件包发布
  11. 文档

evm-gauntlet-vrfv2plus

这个软件包执行各种部署和管理VRF V2+合同的命令.

见 这里 用于支助业务和相关文件.

仓库依赖性

  • 有合同的链路链接存储器 : 链路

所需工具

设置

# cd into gauntlet-evm repo
$ cd gauntlet-evm
$ nvm use
$ yarn # Installs node.js dependencies

运行测试

从根目录 gauntlet-evm 运行以下操作以触发所有测试 :

yarn test --selectProjects evm-gauntlet-vrfv2plus

或者,如果你想运行一个特定的测试:

yarn test packages/evm-gauntlet-vrfv2plus/tests/batchblockhashstore.test.ts

更新合同 ABIs 和字节代码

使用脚本

有一个脚本可以帮助您生成所有元数据文件( 您可以在 scripts 文件夹). 在运行脚本之前, 请确定您是否正确 foundry.toml 财务报告和审定财务报表 remappings.txt 配置设置 。 如果没有,则遵循以下手册步骤指南中的步骤1-4。 否则,剧本会警告您缺少配置. 还有 别忘了在使用脚本之前安装铸币局!

这样就可以运行取代下面所解释的所有手动步骤的脚本,生成所有必要的元数据 VRFCoordinatorV2_5.sol 合同:

$ ./gen-vrf-contract-metadata.sh \
     -m /path/to/chainlink \
     -c /path/to/chainlink/contracts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol \
     -g /path/to/gauntlet-evm
     -v /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm/v2
     -p vrfv2plus_coordinator

旗帜如下:

  • -m: 本地链路链接寄存器复制的绝对路径( root)
  • -c: 本地链路库中合同文件的绝对路径
  • -g : 本地 grandlet- evm 寄存器的绝对路径( root)
  • -v: 保存所有生成文件的版本文件夹( 如 v1, v2)
  • -p: 要使用的创建配置文件( 如果未指定默认配置文件, 可使用可选参数, 设置为 vrfv2plus 用于使用 VRF v2.5 默认配置文件或设置为 vrfv2plus_coordinator 以使用 VRF 协调员V2 5 合同的简介)
  • -o: 优化器运行的次数( 可选参数, 默认值是 Foundry.toml " 文件 " Foundry.toml " 中来自 Frantry VRF 配置文件的一个)

已知的脚本问题

由于模块或锁文件已经被使用,脚本可能失败. 如果遇到这些问题,这是因为同时使用不同的依赖管理器导致相撞. 那样的话,去你的 chainlink 本地仓库在内部运行 contracts 文件夹并运行以下一些来清理 :

$ npm run clean # should be sufficient, you could also try yarn clean
$ rm -rf node_modules # in case nothing else works

手工步骤

这些步骤将指导你如何(重建)建立合同.

  1. 转到本地链路链链芯回波设置

    $ cd chainlink/contracts
    
  2. 更新 foundry.toml 在合同目录中包含以下配置文件(除非这些配置文件已经存在,否则不要更新任何东西!)

    [profile.vrfv2plus_coordinator]
    optimizer_runs = 500
    src = 'src/v0.8/vrf'
    solc_version = '0.8.19'
    
    [profile.vrfv2plus]
    optimizer_runs = 1_000_000
    src = 'src/v0.8/vrf'
    solc_version = '0.8.19'
    
  3. 更新 remappings.txt 合同目录中的文件,将 Openzeppelin 指向一个供应商目录而不是节点(如果需要,将 OpenZeppelin 版本调整为合同中使用的版本)

    @openzeppelin/=src/v0.8/vendor/openzeppelin-solidity/v4.9.3
    
  4. 下载和复制 @openzeppelin/[email protected] 本地供应商目录的代码

    $ nvm use
    $ npm install -g @openzeppelin/[email protected]
    # Update node.js version accordingly in the command below
    $ cp -r ~/.nvm/versions/node/18.12.0/lib/node_modules/@openzeppelin/contracts/ ./src/v0.8/vendor/openzeppelin-solidity/v4.9.3/contracts/
    
  5. 安装创建并运行伪造构建 VRF协调员V2 5, BlockhashStore和VRFV2PlusWrapper (变动) FOUNDRY_PROFILE 将配置名称从 foundry.toml 如果您想要使用默认配置文件, 文件或省略)

    $ FOUNDRY_PROFILE=<profile_name> forge build --contracts src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol --force --build-info-path=./build --build-info --skip test --skip scripts
    $ mv build/1d042417803331c5f14babf40ad6faee.json build/VRFCoordinatorV2_5.build.json
    

    以防您使用 Apple Clang 與您相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相關相 solcLongVersion 生成的构建文件中的参数( EtherScan 或其他一些区块链浏览器可能拒绝进行其他校验, 请检查 在 EtherScan 上支持的团结版本) (中文(简体) ). 你可以这样做:

    sed 's/.Darwin.appleclang//g' build/BatchVRFCoordinatorV2Plus.json > build/BatchVRFCoordinatorV2Plus_fixed.json
    mv build/BatchVRFCoordinatorV2Plus_fixed.json build/BatchVRFCoordinatorV2Plus.json 
    

    很少有最后的触摸:

    # now remove all whitespaces and make the build file more compact
    $ cat ./build/VRFCoordinatorV2_5.build.json | jq -c . > ./build/VRFCoordinatorV2_5_compact.build.json
    # copy the file to gauntlet-evm inside artifacts folder
    $ cp /path/to/chainlink/build/VRFCoordinatorV2_5_compact.build.json /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm/VRFCoordinatorV2_5.build.json
    

    重复BlockhashStore和VRFV2PlusWrapper合同(或任何其他合同)的这一过程.

  6. 运行 hardhat 编译生成元数据( 例如 VRFCoordinatorV2_5.sol(中文(简体) )

    # Make sure you are in the contrats folder (chainlink repo)
    $ cd ./contracts
    # The following command will use the settings for VRFCoordinatorV2_5 in hardhat.config.js
    # overrides section and the defaults (1 million optimizations) for wrapper and BHS
    
    $ nvm use
    # If specific node.js version not installed, install it using nvm install v16.16.0
    $ npm install -g [email protected]
    $ pnpm i
    $ pnpm hardhat compile
    
    # After running the above command, you should see the appropriate output in:
    # artifacts/src/v0.8/vrf/dev/<ContractName>.sol/<ContractName>.json
    
    # Example: artifacts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol/VRFCoordinatorV2_5.json
    
    # copy the metadata file to a correct location in the gauntlet-evm repo
    $ cp ./artifacts/src/v0.8/vrf/dev/VRFCoordinatorV2_5.sol/VRFCoordinatorV2_5.json /path/to/gauntlet-evm/packages/evm-gauntlet-vrfv2plus/artifacts/evm
    

为新合同添加命令

  1. 要添加新合同, 请在 commands 文件夹和每个命令添加一个文件+ 不要忘记添加 index.ts 文档.

  2. 增加新的合同类别 packages/evm-gauntlet-vrfv2plus/src/lib/categories.ts,合同装入器 packages/evm-gauntlet-vrfv2plus/src/lib/contracts.ts 新的合同类型(如有必要) packages/evm-gauntlet-vrfv2plus/src/lib/types.ts。 。 。 .

  3. 更新命令根索引 packages/evm-gauntlet-vrfv2plus/src/commands/index.ts 以新的命令扩展它.

  4. 运行时您应该可以看到新的命令 yarn gauntlet help。 。 。 .

软件包发布

  1. 在 gauntlet-evm 复发.

  2. 在同一 PR 中添加更改列表 yarn changeset add,编辑从主要到次要的更改器文件,并获得 PR 的接受并合并.

  3. 释放新的 gauntlet-evm 软件包: 一旦检测到更改器 develop 分支, CI 将自动创建一个新的 PR 以发布软件包, 批准此 PR并合并它( 合并将启动软件包的创建, 然后您可以在软件包的页面上找到)

  4. 如果您希望此更改可用于 勇士工具,然后,你必须确保 Gauntlet 更新 新的 gauntlet-evm-vrfv2plus 软件包版本

  5. 在 Gauntlet 仓库 通过升级 gauntlet-evm-vrfv2plus 软件包版本 packages/gauntlet-evm 运行以下命令:

    yarn add @chainlink/[email protected] # replace X.Y.Z with the correct version
    
  6. 在同一 PR 中添加更改列表 yarn changeset add,编辑从主要到次要的更改器文件,并获得 PR 的接受并合并.

  7. 释放新的 gauntlet 软件包: 一旦检测到更改器 develop 分支, CI 将自动创建一个新的 PR 以发布软件包, 批准此 PR并合并它( 合并将启动软件包的创建, 然后您可以在软件包的页面上找到)

文档

完成所有工作时,请确保更新以下文件:

VRF 业务使用案例

EngOps VRF 指南

版本与发布记录

@chainlink/evm-gauntlet-vrfv2plus 共发布 66 个版本,首次发布于 2023/10/17;过去 12 个月发布了 0 个版本。

版本发布日期距今
5.13.0latest2024/07/122 年前
0.0.0-develop-20240712121813develop2024/07/122 年前
0.0.0-develop-202407120815012024/07/122 年前
5.12.02024/07/062 年前
5.11.02024/05/232 年前
0.0.0-develop-202405230705122024/05/232 年前

关于 @chainlink/evm-gauntlet-vrfv2plus 的常见问题

@chainlink/evm-gauntlet-vrfv2plus 是什么?

EVM 勇士号VRFV2 加号

如何安装 @chainlink/evm-gauntlet-vrfv2plus?

在项目目录运行 npm install @chainlink/evm-gauntlet-vrfv2plus,或使用 pnpm add / yarn add / bun add。

@chainlink/evm-gauntlet-vrfv2plus 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chainlink/evm-gauntlet-vrfv2plus 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@chainlink/evm-gauntlet-vrfv2plus 可以商用吗?

@chainlink/evm-gauntlet-vrfv2plus 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@chainlink/evm-gauntlet-vrfv2plus 的下载量有多少?

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

@chainlink/evm-gauntlet-vrfv2plus 还在维护吗?

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