Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: target.getAddress is not a function #3947

Closed
SyedImam1998 opened this issue Apr 4, 2023 · 3 comments
Closed

TypeError: target.getAddress is not a function #3947

SyedImam1998 opened this issue Apr 4, 2023 · 3 comments
Assignees
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6

Comments

@SyedImam1998
Copy link

SyedImam1998 commented Apr 4, 2023

Ethers Version

^6.2.3

Search Terms

No response

Describe the Problem

I am getting this error on the front end but i am not using .getAddress() anywhere in my directory.

Error:

TypeError: target.getAddress is not a function
    at new _BaseContract (contract.ts:727:34)
    at new Contract (contract.ts:986:7)
    at connectWallet (App.jsx:195:30)

my code:

const connectWallet=async()=>{
try{
    const accounts=await window.ethereum.request({
      method:"eth_requestAccounts",
    });
  const provider = new ethers.BrowserProvider(window.ethereum);
  setProvider(provider);
  const  signer = await provider.getSigner();
  setAccount(signer);
  const contractInstance = new ethers.Contract(contractAddress,contractAbi, signer);
  setContract(contractInstance);
  }catch(error){
    console.log(error)
    alert("something went wrong #1");
  }
}

Code Snippet

No response

Contract ABI

No response

Errors

No response

Environment

No response

Environment (Other)

No response

@SyedImam1998 SyedImam1998 added investigate Under investigation and may be a bug. v6 Issues regarding v6 labels Apr 4, 2023
@ricmoo
Copy link
Member

ricmoo commented Apr 4, 2023

Can you console.log the contractAddress to see what you are passing in?

@ricmoo
Copy link
Member

ricmoo commented Apr 24, 2023

I am suspecting the value for contractAddress was passed in as undefined (often happens with typos in a .env or loading from a similar source).

Closing this, but if you have more info, please re-open.

Thanks! :)

@ricmoo
Copy link
Member

ricmoo commented May 20, 2023

I've added a check in the top of contract to throw a more intuitive error in the event the target isn't a valid value.

Hopefully this helps future folks. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
investigate Under investigation and may be a bug. v6 Issues regarding v6
Projects
None yet
Development

No branches or pull requests

2 participants