ethers.getContractAt() 的文档
有人可以向我指出解释函数 ethers.getContractAt():
的文档(官方或其他):
其原始上下文如下:
vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock', VRFCoordinatorMock.address, signer)
完整的代码可以在这里找到... https://github.com/PatrickAlphaC /all-on-chain- generated-nft/blob/main/deploy/02_Deploy_RandomSVG.js
如果没有这样的文档,解释就会很多赞赏。谢谢你!
Can somebody please point me to the documentation (official or otherwise ) that explains the function ethers.getContractAt():
the original context of this is as follows:
vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock', VRFCoordinatorMock.address, signer)
and the full code can be found here...
https://github.com/PatrickAlphaC/all-on-chain-generated-nft/blob/main/deploy/02_Deploy_RandomSVG.js
In the absence of such documentation, an explanation would be much appreciated. Thank you!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
getContractAt()
函数是 Hardhat 的hardhat-ethers
插件的一部分,扩展了ethers
对象。它不是核心 Ethers 包的一部分,因此它不包含在其文档中。
Hardhat 文档提到了该插件: https://hardhat.org/plugins/nomiclabs-hardhat -ethers.html#helpers
The
getContractAt()
function is part of thehardhat-ethers
plugin for Hardhat, expanding theethers
object.It's not a part of the core Ethers package, so it's not included in their documentation.
Hardhat docs mentioning the plugin: https://hardhat.org/plugins/nomiclabs-hardhat-ethers.html#helpers
基本上,它所做的事情与
attach
所做的事情相同,但在一行中。即您实际上可以与已部署的合约进行交互。如果您使用
attach
,下面的代码可供参考。使用安全帽时,您可以通过
getContractAt()
在一行中完成相同的操作Basically, it is doing the same thing, that
attach
do but in one line. i.e you can actually interact with an already deployed contract.For reference below is the code if you are using
attach
You can accomplish the same thing in one line via
getContractAt()
when using hardhat