hardhat-toolbox doubt #2603
-
I recently started using hardhat toolbox but when I try this const { ethers, network } = require("hardhat");
const dao = await ethers.getContract("Dao") I am getting this error: |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 3 replies
-
@adityabhattad2021 Use |
Beta Was this translation helpful? Give feedback.
-
The problem was solved when I added this package |
Beta Was this translation helpful? Give feedback.
-
To use getContract via Ethers, you need the contract's address/name and an interface (deployer), which (interface) is not present here So, since you just have the contract name--in this case "Dao"--you should use the hardhat-ethers package which is provided by Hardhat. Doing so will not lead to a "...not a function" error. Some commonly used functions which hardhat-ethers provides: function getContractFactory(name: string, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractFactory(name: string, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;
function getContractFactory(abi: any[], bytecode: ethers.utils.BytesLike, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractAt(name: string, address: string, signer?: ethers.Signer): Promise<ethers.Contract>;
function getContractAt(abi: any[], address: string, signer?: ethers.Signer): Promise<ethers.Contract>;
function getSigners() => Promise<ethers.Signer[]>;
function getSigner(address: string) => Promise<ethers.Signer>;
function getImpersonatedSigner(address: string) => Promise<ethers.Signer>;
function getContractFactoryFromArtifact(artifact: Artifact, signer?: ethers.Signer): Promise<ethers.ContractFactory>;
function getContractFactoryFromArtifact(artifact: Artifact, factoryOptions: FactoryOptions): Promise<ethers.ContractFactory>;
function getContractAtFromArtifact(artifact: Artifact, address: string, signer?: ethers.Signer): Promise<ethers.Contract>; |
Beta Was this translation helpful? Give feedback.
The problem was solved when I added this package
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",