-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Chainlink VRF V2 升级至 VRF V2.5 #816
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@eddiehsu66 pr需要引用解决的相关问题 我已经帮你引用上了 下次希望能够引用一下解决的问题 你的代码这几天 我会去本地测试的 谢谢你的贡献 |
#607 是需要支持预言机本地化 如果可以的话 能否在这个pr中支持 |
okok,我重新看一下文档整理一下
|
好 辛苦大佬 |
OKOK,已支持预言机本地化测试,已提交 |
辛苦辛苦 争取下周 review完 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR upgrades the Chainlink VRF V2 integration to VRF V2.5, updating consumer contracts, type definitions, imports, and documentation accordingly.
- Swapped out
VRFConsumerBaseV2
forVRFConsumerBaseV2Plus
and updated all import paths and constructor calls. - Changed
subId
fromuint64
touint256
and updated coordinator addresses and key hashes. - Refactored
requestRandomWords
calls to useVRFV2PlusClient.RandomWordsRequest
withExtraArgsV1
, added a mock contract for local testing, and expanded the README with remix setup instructions.
Reviewed Changes
Copilot reviewed 4 out of 10 changed files in this pull request and generated 3 comments.
File | Description |
---|---|
39_Random/readme.md | Updated docs for VRF V2.5 usage, added local test guide, corrected addresses and sample calls |
39_Random/VRFCoordinatorV2_5Mock.sol | Introduced mock import for VRFCoordinatorV2_5Mock to enable local testing in remix |
39_Random/RandomNumberConsumer.sol | Migrated consumer contract to use VRFConsumerBaseV2Plus , updated types, imports, and request API |
39_Random/Random.sol | Migrated NFT contract to use VRFConsumerBaseV2Plus , updated types, imports, and request API |
Comments suppressed due to low confidence (2)
39_Random/RandomNumberConsumer.sol:63
- [nitpick] The parameter
s_randomWords
uses thes_
prefix (typically for storage); consider renaming torandomWords
or similar for clarity and consistency with_requestId
.
function fulfillRandomWords(uint256 _requestId, uint256[] calldata s_randomWords) internal override {
39_Random/Random.sol:110
- [nitpick] Similarly here,
s_randomWords
could be renamed to avoid the storage-prefix convention and match the_requestId
style.
function fulfillRandomWords(uint256 _requestId, uint256[] calldata s_randomWords) internal override{
@@ -353,6 +362,78 @@ contract Random is ERC721, VRFConsumerBaseV2{ | |||
当合约不使用后可以在`Chainlink VRF`上取消订阅,取出剩余的`LINK`代币 | |||
 | |||
|
|||
## `remix`本地测试网验证 | |||
|
|||
ChainLink也提供了在remix本地进行测试的方案。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consistently capitalize 'Chainlink' instead of 'ChainLink' to match product branding.
ChainLink也提供了在remix本地进行测试的方案。 | |
Chainlink也提供了在remix本地进行测试的方案。 |
Copilot uses AI. Check for mistakes.
|
||
### 5. 发起随机数请求 | ||
|
||
点击左侧`mintRandomVRF`,发起随机数请求,可以通过查询`requesetid`来查看发起的请求ID。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in 'requesetid
'—it should be 'requestId
' to match the code examples.
点击左侧`mintRandomVRF`,发起随机数请求,可以通过查询`requesetid`来查看发起的请求ID。 | |
点击左侧`mintRandomVRF`,发起随机数请求,可以通过查询`requestId`来查看发起的请求ID。 |
Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <[email protected]>
What type of PR is this (这是什么类型的PR)
Which issue(s) this PR fixes(Optional) (这个PR 修复了什么问题 (可选择))
What this PR does / why we need it (这个PR 做了什么/ 我们为什么需要这个PR)
当前Chainlink官网不支持VRF V2,获取的subId从uint64变为了uint256,需要进行迁移