Lesson 9 : TypeError: (0 , ethers_1.getAddress) is not a function #5836
Unanswered
MrPositive0709
asked this question in
Q&A
Replies: 2 comments 1 reply
-
Make sure, you are using |
Beta Was this translation helpful? Give feedback.
0 replies
-
if you are using ethers v6: also instead of also this line is important so as to get the VRFCoordinatorV2Mock address so your code ends up looking like this
|
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
I have followed Patrick to 15:19:30 but when I deploy it returns this bug :
Nothing to compile
Local network detected ! Deploying mocks...
deploying "VRFCoordinatorV2Mock" (tx: 0x72a894d215f348b1e3a4d1665d1332c1096776aa1d6f2d3b0dacaafb1ae71b7f)...: deployed at 0x5FbDB2315678afecb367f032d93F642f64180aa3 with 2527447 gas
Mock Deployed
An unexpected error occurred:
Error: ERROR processing /root/hh-fcc/hardhat-smartcontract-lottery-fcc/deploy/01-deploy-raffle.js:
TypeError: (0 , ethers_1.getAddress) is not a function
at new HardhatEthersSigner (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:73:30)
at Function.create (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/signers.ts:65:12)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
at getSigner (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:60:29)
at async Promise.all (index 0)
at getSigners (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:45:30)
at getContractAt (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/@nomicfoundation/hardhat-ethers/src/internal/helpers.ts:327:21)
at DeploymentsManager.executeDeployScripts (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1229:19)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at runNextTicks (node:internal/process/task_queues:65:3)
at listOnTimeout (node:internal/timers:528:9)
at processTimers (node:internal/timers:502:7)
at DeploymentsManager.runDeploy (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1059:5)
at SimpleTaskDefinition.action (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/index.ts:438:5)
at Environment._runTaskDefinition (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:333:14)
at Environment.run (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:166:14)
at SimpleTaskDefinition.action (/root/hh-fcc/hardhat-smartcontract-lottery-fcc/node_modules/hardhat-deploy/src/index.ts:584:32)
const {
developmentChains,
networkConfig,
} = require("../helper-hardhat-config");
const VRF_SUB_FUND_AMOUNT = ethers.utils.parseEther("2");
module.exports = async function ({ getNamedAccounts, deployments }) {
const { deploy, log } = deployments;
const { deployer } = await getNamedAccounts();
const chainId = network.config.chainId;
let vrfCoordinatorV2Address, subscriptionId;
if (developmentChains.includes(network.name)) {
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;
//fund the subscription
// usually need the link token on a real network
await vrfCoordinatorV2Mock.fundSubscription(
subscriptionId,
VRF_SUB_FUND_AMOUNT
);
} else {
vrfCoordinatorV2Address = networkConfig[chainId]["vrfCoordinatorV2"];
subscriptionId = networkConfig[chainId]["subscriptionId"];
}
const gasLane = networkConfig[chainId]["gasLane"];
const entranceFee = networkConfig[chainId]["entranceFee"];
const callbackGasLimit = networkConfig[chainId]["callbackGasLimit"];
const interval = networkConfig[chainId]["interval"];
const args = [
vrfCoordinatorV2Address,
entranceFee,
gasLane,
subscriptionId,
callbackGasLimit,
];
const raffle = await deploy("Raffle", {
from: deployer,
args: args,
log: true,
waitComfirmations: network.config.blockConfirmations || 1,
});
if (
!developmentChains.includes(network.name) &&
process.env.ETHERSCAN_API_KEY
) {
log("Verifying...");
await verify(raffle.address, args);
}
log("-------------------------------");
};
module.exports.tags = ["all", "raffle"];
`
I have asked ChatGPT and it said that there is conflict between the version of Hardhat and the @nomiclabs/hardhat-ethers plugin and followed the instructs that ChatGPT gave me but it did not work
Beta Was this translation helpful? Give feedback.
All reactions