Skip to content

Instantly share code, notes, and snippets.

@eftalyurtseven
Created December 13, 2021 14:16
Show Gist options
  • Save eftalyurtseven/6694db1d13f43751e5b90a583f5ace5e to your computer and use it in GitHub Desktop.
Save eftalyurtseven/6694db1d13f43751e5b90a583f5ace5e to your computer and use it in GitHub Desktop.
How to check ETH address is valid or not? Tutorial is here: https://youtu.be/b_GnjbVWSo4
const Web3 = require('web3');
class Web3Helper {
constructor() {
this.web3 = new Web3();
}
isValidAddress = (address) => {
try {
this.web3.utils.toChecksumAddress(address);
return true;
} catch (ex) {
console.error(ex);
return false;
}
};
}
const web3Helper = new Web3Helper();
console.log(
web3Helper.isValidAddress('0xEA9D2766692e47be0c57Abb9C0225Acf33f763e7')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment