Correct Checksummed Format (Mixed Case)
- Consists of 40 hexadecimal characters (0-9 and A-F or a-f).
- The “0x” prefix is optional but commonly used to denote that it’s a hexadecimal value.
- Characters in the address can be either uppercase (A-F) or lowercase (a-f).
- This mixed-case format is designed to provide more specificity and reduce the likelihood of typographical errors.
- There are no spaces or special characters in the address.
- It does not use the letters O, I, l, or the number 0 to avoid visual ambiguity.
Ethereum Address Validation Using Regular Expressions
ETHEREUM address is a 40-character hexadecimal identifier that receives and sends Ether (ETH) and other Ethereum-based tokens. Ethereum addresses come in two main formats: the standard hexadecimal representation and the checksummed format.
Examples:
Input: 0x742d35Cc6634C0532925a3b844Bc454e4438f44e
Output: True
Explanation: This is a valid Ethereum address. It starts with “0x” and consists of 40 hexadecimal characters.
Input: 0x742d35cc6634c0532925a3b844bc454e4438f44e
Output: True
Explanation: This address is valid because it follows the correct format with “0x” at the beginning.
Input: 742d35Cc6634C0532925a3b844Bc454e4438f44e
Output: True
Explanation: Ethereum addresses are usually represented with “0x” at the start, but it’s not strictly required.
This address is valid because it consists of 40 hexadecimal characters, and the absence of “0x” doesn’t make it invalid.
Input: 0x123
Output: False
Explanation: This address is not valid because it lacks the required 40-character length.
Ethereum addresses must contain 40 hexadecimal characters after “0x.”
Input: 0123456789012345678901234567890
Output: True
Explanation: This address is valid because it contains 40 hexadecimal characters following “0x,”.