I am trying to interact with a deployed contract at Sepolia in a hardhat test. Here's how I do it:

const provider= new ethers.providers.JsonRpcProvider(process.env.ALCHEMY_API_KEY);
const contract = await ethers.Contract("0xFd57b4ddBf88a4e07fF4e34C487b99af2Fe82a05",BnMABI,provider);

I still don't know why I am getting this error:

TypeError: Cannot read properties of null (reading 'constructor')

I have seen a lot of posts on Google and they do the same to interact with smart contracts from frontend. I don't know why it's not working in hardhat.

Does anyone know what I am doing wrong here?

1 Answer 1


Just change in the second line to const contract = new ethers.Contract so you'll call class constructor.

And no need in await on second line as constructor in synchronous

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.