Closed naddison36 closed 3 years ago
Could it be that you also use a plugin that depends on @nomiclabs/hardhat-ethers
?
If so, you ll need to alias @nomiclabs/hardhat-ethers
to hardhat-ethers-deploy
This might not solve the typing issue, but worth a try
With npm : npm i -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers
Recently hardhat team made @nomiclabs/hardhat-ethers
itself extensible so my plan is to update hardhat-deploy-ethers
to extend it instead of being a fork of it. No timeline yet though.
Thanks, @wighawag. Using the above alias worked
It didn't fully work for me though...
yarn add @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers
warning Pattern ["@nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers"] is trying to unpack in the same destination "/home/manu/.cache/yarn/v6/npm-@nomiclabs-hardhat-ethers-0.3.0-beta.7-860d86b84ed3c4fdef64283ccf1e8d5623454d02-integrity/node_modules/@nomiclabs/hardhat-ethers" as pattern ["hardhat-deploy-ethers@^0.3.0-beta.7"]. This could result in non-deterministic behavior, skipping. ... warning " > @nomiclabs/hardhat-waffle@2.0.1" has incorrect peer dependency "@nomiclabs/hardhat-ethers@^2.0.0".
yarn upgrade-interactive
error Couldn't find any versions for "@nomiclabs/hardhat-ethers" that matches "^0.3.0-beta.7"
package.json
{
"dependencies": {
"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers",
"hardhat": "^2.1.2",
"hardhat-deploy": "^0.7.0-beta.56",
"hardhat-deploy-ethers": "^0.3.0-beta.7"
}
}
Any ideas?
you need to remove that line "hardhat-deploy-ethers": "^0.3.0-beta.7"
and then you need to import @nomiclabs/hardhat-ethers
in your hardhat.config.js instead of hardhat-deploy-ethers. I need to add that to the doc actually.
For people experiencing this issue in the future, you can implement this workaround instead of using ethers.getContract(), and it should be the same.
await deployments.fixture(["MyContract"]);
const myContract = await deployments.get("MyContract");
const contract = await ethers.getContractAt(
myContract.abi,
myContract.address
);
});
For people experiencing this issue in the future, you can implement this workaround instead of using ethers.getContract(), and it should be the same.
await deployments.fixture(["MyContract"]); const myContract = await deployments.get("MyContract"); const contract = await ethers.getContractAt( myContract.abi, myContract.address ); });
Thanks rodrigoherrerai, this worked perfectly.
This:
With npm :
npm i -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers
With this:
yarn upgrade-interactive
Fixed it for me in 2 repos already 🙏🏻
npm i -D @nomiclabs/hardhat-ethers@npm:hardhat-deploy-ethers
Thanks bro you save me
you need to remove that line
"hardhat-deploy-ethers": "^0.3.0-beta.7"
and then you need to import
@nomiclabs/hardhat-ethers
in your hardhat.config.js instead of hardhat-deploy-ethers. I need to add that to the doc actually.
Thanks bro
deployer = (await getNamedAccounts()).deployer;
await deployments.fixture(["all"]);
console.log('deployer',deployer)
// fundMe = await ethers.getContract("FundMe", deployer);
const contract = await deployments.get("FundMe");
fundMe = await ethers.getContractAt(
contract.abi,
contract.address
);
});
how to apply the deployer though
I've installed the
hardhat-deploy-ethers
extension into my TyoeScript project and imported it in myhardhat.config.ts
fileWhen I try and use the
getContract
function in a deploy script like the followingI get the following TypeScript error
If I put in a
// @ts-ignore
before the line with thegetContract
function, the deploy scripts work fine.My
tsconfig.ts
file looks like