UNPKG

478 BJavaScriptView Raw
1// Copyright 2017-2022 @polkadot/util-crypto authors & contributors
2// SPDX-License-Identifier: Apache-2.0
3import { isHex } from '@polkadot/util';
4import { isEthereumChecksum } from "./isChecksum.js";
5export function isEthereumAddress(address) {
6 if (!address || address.length !== 42 || !isHex(address)) {
7 return false;
8 } else if (/^(0x)?[0-9a-f]{40}$/.test(address) || /^(0x)?[0-9A-F]{40}$/.test(address)) {
9 return true;
10 }
11
12 return isEthereumChecksum(address);
13}
\No newline at end of file