wighawag / hardhat-deploy-ethers

MIT License
70 stars 25 forks source link

How can we use hardhat-ethers 'getImpersonatedSigner' ? #31

Closed vdaubry closed 1 year ago

vdaubry commented 1 year ago

Hello,

I'm trying to use 'getImpersonatedSigner' function : https://hardhat.org/hardhat-network/docs/guides/forking-other-networks#impersonating-accounts

Here is a sample script that only works with ethers.getImpersonatedSigner :

const usdc = await ethers.getContractAt(
    usdcAbi,
    usdcTokenAddress,
    deployer
  );

  const usdcOwner = await usdc.owner();
  const impersonatedUsdcOwner = await ethers.getImpersonatedSigner(usdcOwner);
  const connectedUsdcOwner = await usdc.connect(impersonatedUsdcOwner);

• If I use the regular ethers.getSigner => I get a ProviderError: HttpProviderError • If I use ethers.getImpersonatedSigner => This works

For getImpersonatedSigner to be available I need to remove the NPM alias "@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers", But then I cant use ethers.getContract in my deployment scripts...

Is there a workaround ?

vdaubry commented 1 year ago

Ok forget it the alternative from the hardhat doc actually works fine, my bad, sorry for the noise 😅