Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

TypeError: (0 , ethers_1.getAddress) is not a function #175

Open
Sammycoderr opened this issue Aug 4, 2023 · 10 comments
Open

TypeError: (0 , ethers_1.getAddress) is not a function #175

Sammycoderr opened this issue Aug 4, 2023 · 10 comments

Comments

@Sammycoderr
Copy link

this seems to be the affected part,
I hope I can get your views as soon as you see this. Thanks

        const vrfCoordinatorV2Mock = await ethers.getContract("VRFCoordinatorV2Mock")
        vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address
        const transactionResponse = await vrfCoordinatorV2Mock.createSubscription()
        const transactionReceipt = await transactionResponse.wait(1)
        subscriptionId = transactionReceipt.events[0].args.subId
       
       }
@Sammycoderr
Copy link
Author

here is the whole error message

An unexpected error occurred:

Error: ERROR processing /home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/deploy/01-deploy-raffle.js:
TypeError: (0 , ethers_1.getAddress) is not a function
    at new HardhatEthersSigner (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:73:30)
    at Function.create (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:65:12)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:538:9)
    at processTimers (node:internal/timers:512:7)
    at getSigner (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:60:29)
    at async Promise.all (index 0)
    at getSigners (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:45:30)
    at getContractAt (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:327:21)
    at DeploymentsManager.executeDeployScripts (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1229:19)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at runNextTicks (node:internal/process/task_queues:64:3)
    at listOnTimeout (node:internal/timers:538:9)
    at processTimers (node:internal/timers:512:7)
    at DeploymentsManager.runDeploy (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1059:5)
    at SimpleTaskDefinition.action (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat-deploy/src/index.ts:438:5)
    at Environment._runTaskDefinition (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
    at Environment.run (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
    at SimpleTaskDefinition.action (/home/sammy/hh-fcc/hardhat-smartcontract-raffle-fcc/node_modules/hardhat-deploy/src/index.ts:584:32)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@rezowansifat
Copy link

rezowansifat commented Aug 4, 2023

Try to change vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address to vrfCoordinatorV2Address = vrfCoordinatorV2Mock.runner.address

@Sammycoderr
Copy link
Author

Try to change vrfCoordinatorV2Address = vrfCoordinatorV2Mock.address to vrfCoordinatorV2Address = vrfCoordinatorV2Mock.runner.address

Thank you, so I did that with both .getAddress and .runner.address but still giving the exact error

@CHANGLIFE
Copy link

Here, I ran into the same problem. I've tried everything on the internet and it still doesn't work.

@CHANGLIFE
Copy link

Bro, have you solved it?

@Sammycoderr
Copy link
Author

Bro, have you solved it?

oh yeah as a matter of fact I’ve solved it …if I remember correctly,
basically our package.json has a bunch of version updates so somethings have been moved around. so downgrading to the versions he used during the tutorial would help. just copy them from the repository and run yarn.

I guess that was all I did but if it doesn’t work let’s know, happy coding

@CHANGLIFE
Copy link

Thanks, I did the same.It works

@ilkinm03
Copy link

ilkinm03 commented Apr 17, 2024

Installing this will solve issue

"@nomiclabs/hardhat-ethers": "npm:hardhat-deploy-ethers@^0.3.0-beta.13s"

And please make sure you're using ethers v5 module not v6.

@Bethel-nz
Copy link

still using ethersv6, i tried something else, but i cant seem to get the subId, sadly, im getting the address and all btw but not the subId which is missing in the txReceipt:

// create VRFV2 Subscription
    const deploymentAddress = (await deployments.get('VRFCoordinatorV2Mock'))
      .address;
    const vrfCoordinatorV2Mock = await ethers.getContractAt(
      'VRFCoordinatorV2Mock',
      deploymentAddress
    );
    vrfCoordinatorV2Address = await vrfCoordinatorV2Mock.getAddress();
    const txResponse = await vrfCoordinatorV2Mock.createSubscription();
    const txReceipt = await txResponse.wait();
    console.log(
      'reciept',
      await txResponse ,
      txReceipt?.toJSON()
    );
    //   subscriptionId = transactionReceipt?.logs[0]!.data;
    //   // Fund the subscription
    //   // Our mock makes it so we don't actually have to worry about sending fund
    //   await vrfCoordinatorV2Mock.fundSubscription(subscriptionId!, FUND_AMOUNT);
   

@Bethel-nz
Copy link

found a workaround:

  if (chainId == 31337) {
    // create VRFV2 Subscription
    const deploymentAddress = (await deployments.get('VRFCoordinatorV2Mock'))
      .address;
    const vrfCoordinatorV2Mock = await ethers.getContractAt(
      'VRFCoordinatorV2Mock',
      deploymentAddress
    );
    vrfCoordinatorV2Address = await vrfCoordinatorV2Mock.getAddress();
    const txResponse = await vrfCoordinatorV2Mock.createSubscription({
      from: deployer,
    });
    const txReceipt = await txResponse.wait();
    const logs = await txReceipt?.logs[0]!;

    if (logs && 'args' in logs) {
      subscriptionId = logs.args[0];
    }
    //   // Fund the subscription
    //   // Our mock makes it so we don't actually have to worry about sending fund
    await vrfCoordinatorV2Mock.fundSubscription(subscriptionId!, FUND_AMOUNT);
  } else {
    vrfCoordinatorV2Address =
      networkConfig[network.config.chainId!]['vrfCoordinatorV2'];
    subscriptionId = networkConfig[network.config.chainId!]['subscriptionId'];
  }

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants