PatrickAlphaC / hardhat-fund-me-fcc

82 stars 183 forks source link

Error occurs when deploying mockV3Aggregator contract #98

Closed RamanSB closed 1 year ago

RamanSB commented 1 year ago

In 00-deploy-mocks.js, I run:


 await deploy("MockV3Aggregator", {
            contract: "MockV3Aggregator",
            from: deployer,
            log: true,
            args: [DECIMALS, INITIAL_PRICE],
 });

The stacktrace looks as such so I'm assuming there is a null or empty object somewhere hence the cannot read property 'length' of undefined?

Error: ERROR processing /Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/deploy/00-deploy-mocks.js:
TypeError: Cannot read property 'length' of undefined
    at getFrom (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/helpers.ts:1713:14)
    at _deploy (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/helpers.ts:533:9)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at _deployOne (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/helpers.ts:1004:16)
    at Object.module.exports [as func] (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/deploy/00-deploy-mocks.js:38:9)
    at DeploymentsManager.executeDeployScripts (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1219:22)
    at DeploymentsManager.runDeploy (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/DeploymentsManager.ts:1052:5)
    at SimpleTaskDefinition.action (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat-deploy/src/index.ts:438:5)
    at Environment._runTaskDefinition (/Users/ramandeepbedi/Documents/Solidity-FCC/hardhat-fund-me-fcc/node_modules/hardhat/src/internal/core/runtime-environment.ts:30
RamanSB commented 1 year ago

Further analysis whilst debugging reveals that my deployer is undefined?

image

RamanSB commented 1 year ago

The issue has been resolved by noticing that my config did not include:

namedAccounts: {
        deployer: {
            default: 0, // here this will by default take the first account as deployer
            1: 0, // similarly on mainnet it will take the first account as deployer. Note though that depending on how hardhat network are configured, the account 0 on one network can be different than on another
        },
    }

🤕🤕🤕 Patrick did you mention this before running yarn hardhat deploy?

PatrickAlphaC commented 1 year ago

hmmm... it should be in there. Maybe I didn't mention it?