Member-only story
This is going to be a super simple tutorial that will cover how to check if an Ethereum address is indeed a valid address.
Here is the video tutorial if you prefer that.
This tutorial starts from a newly created Next JS project. Also, make sure to install the web3 library.
I’ll paste the entire file below and talk about it below the code. So, replace your index.js file with this for a minimal example:
The code here has an input that can be typed in. On change of the input, it sets the address
variable.
The isValidAddress
method checks if the address is valid and then displays that in text.
This method is the valuable piece to this tutorial that most people are probably looking for. It just creates a web3
object and calls a utility method. If toChecksumAddress
passes without error then it is a valid address. Otherwise, the address is not valid.
That’s about it. If you have any questions, feel free to ask.
Follow my social media to keep up-to-date: