hardhat-starter-kit icon indicating copy to clipboard operation
hardhat-starter-kit copied to clipboard

ethers.getContract is not a function

Open nenadV91 opened this issue 2 years ago • 1 comments

On fresh clone when run hh run ./scripts/readPrice.js i get

TypeError: ethers.getContract is not a function

My dependencies

  "devDependencies": {
    "@chainlink/contracts": "0.5.1",
    "@ethersproject/abi": "^5.7.0",
    "@ethersproject/providers": "^5.7.1",
    "@nomicfoundation/hardhat-chai-matchers": "^1.0.3",
    "@nomicfoundation/hardhat-network-helpers": "^1.0.6",
    "@nomicfoundation/hardhat-toolbox": "^2.0.0",
    "@nomiclabs/hardhat-ethers": "^2.1.1",
    "@nomiclabs/hardhat-etherscan": "^3.1.0",
    "@typechain/ethers-v5": "^10.1.0",
    "@typechain/hardhat": "^6.1.3",
    "chai": "^4.3.6",
    "ethers": "^5.7.1",
    "hardhat": "^2.11.2",
    "hardhat-gas-reporter": "^1.0.9",
    "husky": "^8.0.1",
    "lint-staged": "^13.0.3",
    "prettier": "^2.7.1",
    "prettier-plugin-solidity": "^1.0.0-beta.24",
    "solhint": "^3.3.7",
    "solhint-plugin-prettier": "^0.0.5",
    "solidity-coverage": "^0.8.2",
    "typechain": "^8.1.0"
  },

nenadV91 avatar Aug 30 '23 11:08 nenadV91

Yeah, readPrice.js is broken. Latest version of hardhat does not provide a getContract function, it was replaced with getContractAt, but this one requires the contract address.

I guess that this script was was replaced by the read-price-feed task. The task requires an explicit contract address argument, it is not trying to read it from the deployment.

mscurtescu avatar Dec 16 '23 19:12 mscurtescu