How to check if Ethereum address is valid or not
1 min readAug 21, 2018
--
With web3.js, you can check if Ethereum address is valid or not.
Code Example
const address = "0x0089d53F703f7E0843953D48133f74cE247184c2"
let result = Web3.utils.isAddress(address)
console.log(result) // => true
Notes
- Web3.utils.isAddress also checks the checksum, if address has upper and lowercase letters.
- The function works without the
0x
prefix.
Working Demo
References
- https://web3js.readthedocs.io/en/1.0/web3-utils.html#isaddress
- https://scrapbox.io/sushiether/web3.js_-_Ethereum_%E3%81%AE%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9%E3%81%8C%E6%AD%A3%E3%81%97%E3%81%84%E3%82%A2%E3%83%89%E3%83%AC%E3%82%B9%E3%81%8B%E3%81%A9%E3%81%86%E3%81%8B%E3%82%92%E7%A2%BA%E8%AA%8D%E3%81%99%E3%82%8B
Support
If you find this article is helpful, it would be greatly appreciated if you could tip Ether to the address below. Thank you!
0x0089d53F703f7E0843953D48133f74cE247184c2