smartcontractkit / hardhat-starter-kit

A repo for boilerplate code for testing, deploying, and shipping chainlink solidity code.
MIT License
1.2k stars 491 forks source link

ethers.getContract is not a function #173

Open nenadV91 opened 10 months ago

nenadV91 commented 10 months ago

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"
  },
mscurtescu commented 7 months ago

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.