ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.97k stars 1.85k forks source link

Add a custom errors for `contract.deployed()` and `contract.address` #4194

Open fvictorio opened 1 year ago

fvictorio commented 1 year ago

Describe the Feature

Users following guides that were written for ethers v5 normally run into this error:

TypeError: no matching function (argument="key", value="deployed", code=INVALID_ARGUMENT, version=6.6.2)
    at makeError...
    ...

It would be nice to show a different error in this case, saying something like:

No matching function 'deployed'. If you want to wait until the contract is deployed, use 'contract.waitForDeployment()'

A similar error happens with the .address property. In that case I think ethers should say something like:

No matching function 'address'. If you are trying to get the contract's address, use 'await contract.getAddress()'.

Code Example

No response

shubhamshd commented 1 year ago

Hi @fvictorio I would like to contribute by implementing the suggested changes to the error messages I kindly request your permission to proceed with this issue and contribute to the project's improvement. If there are any specific instructions or considerations I should be aware of, please let me know.

Thank you for your time and consideration. I look forward to your response.