A utility to validate Ethereum wallet addresses for their correctness and existence on the Ethereum network.
You can install the Ethereum Address Validator package using npm:
npm install valid-wallet-address
- Import the isValidAddress function from the package:
import { isValidAddress } from 'valid-wallet-address'
- Provide an Ethereum address to the isValidAddress function:
const address = '0xaddress'
isValidAddress(address)
.then((valid) => {
if (valid) {
console.log('Valid Ethereum address')
} else {
console.log('Invalid Ethereum address')
}
})
.catch((error) => console.error('Error:', error))
The function returns a Promise that resolves to true for a valid Ethereum address and false for an invalid one.