Skip to content

TypeError: contractAddresses[chainId].includes is not a function #6234

Answered by Nlferu
kihiuFrank asked this question in Q&A
Discussion options

You must be logged in to vote

Hello @kihiuFrank

The error message indicates that contractAddresses[chainId] is not an array, and that's why you're encountering the error when trying to use the .includes() method on it. To fix this, you need to ensure that contractAddresses[chainId] is an array before calling .includes() on it. Here's how you can modify your code to handle this:

async function updateContractAddresses() {
  const saveAKid = await ethers.getContract("SaveAKid");
  const chainId = network.config.chainId.toString();
  const contractAddresses = JSON.parse(
    fs.readFileSync(frontEndContractFile, "utf8")
  );

  if (contractAddresses[chainId]) {
    // Check if it's already an array
    if (Array.isArray(c…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@kihiuFrank
Comment options

@Nlferu
Comment options

@kihiuFrank
Comment options

@Nlferu
Comment options

Answer selected by kihiuFrank
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants