mas*_*ara 9 solidity web3js ethers.js hardhat
有人可以给我指出解释该功能的文档(官方或其他)吗ethers.getContractAt():
其原始上下文如下:
vrfCoordinator = await ethers.getContractAt('VRFCoordinatorMock', VRFCoordinatorMock.address, signer)
Run Code Online (Sandbox Code Playgroud)
完整的代码可以在这里找到... https://github.com/PatrickAlphaC/all-on-chain- generated-nft/blob/main/deploy/02_Deploy_RandomSVG.js
如果没有此类文档,我们将不胜感激。谢谢你!
Pet*_*jda 19
该函数是Hardhat 插件的getContractAt()一部分,扩展了对象。hardhat-ethersethers
它不是核心 Ethers 包的一部分,因此它不包含在其文档中。
Hardhat 文档提到了该插件:https ://hardhat.org/plugins/nomiclabs-hardhat-ethers.html#helpers
小智 5
基本上,它在做同样的事情,attach只是在一行中做。即您实际上可以与已部署的合约进行交互。
如果您使用的是以下代码,供参考attach
let xyzContract = await hre.ethers.getContractFactory("Name of the contract");
let xyzContractInstance = xyzContract.attach('Address of the contract');
Run Code Online (Sandbox Code Playgroud)
getContractAt()使用安全帽时,您可以在一行中完成同样的事情
let xyzContractInstance = await hre.ethers.getContractAt(
"Contract Name",
deployed contract address
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
13650 次 |
| 最近记录: |