Blockchain Semantics Insights
Business Case | Deep Tech | Announcements | Blockchain Glossary |
Know how to validate an Ethereum AddressBy Viswanath Kapavarapu | April 6, 2018, 7:41 a.m. GMT
Ever wondered why your Ethereum Address has both upper case and lower case letters. This case-sensitivity of Ethereum Addresses is used for checksum validation. In simpler terms, checksum validation is a way to tell if an address is valid and prevent typos while entering an address.
In this article, we shall look into the details of how Ethereum addresses are checksummed. At the end of the article, we shall provide a tool that validates an address using the checksum.
Why Checksum is necessary for Ethereum Addresses:
Ethereum addresses are 160-bit hexadecimal addresses. Since each address is 40 characters long, a simple typo might transfer Ether to a different address than intended. In such cases, it is impossible to recover ethers or tokens from mistyped address. Therefore Vitalik Buterin, the founder of Ethereum, proposed and implemented some formatting rules for addresses via EIP 55(short form for Ethereum Improvement Protocol).
EIP-55 specifies mixed case checksum encoding for addresses to validate an address. At the time of writing this article, some wallets still do not support this validation mechanism. Therefore we provide a tool in this article that validates your address easily.
How does Checksum Validation work:
- Remove the 0x prefix of the hex address.
- Convert the rest of the address to lower-case.
- Hash the lowercase hexadecimal string from Step-2 using Keccak 256 algorithm.
- Compare the obtained hash with the original hex address:
- Change the nth letter of hexadecimal address to uppercase if the nth bit of the obtained hash is greater than 7.
- Otherwise, the nth letter of the hexadecimal address should be lowercased.
- If the address obtained from Step 5 matches with original, then the address is checksummed. If not, the address might have typos such as extra spacing at the start and the end.
Benefits of using Checksum Validation:
- Checksum validation makes sure that Ethereum addresses are exactly 40 characters long.
- Prevents mistyping of an Ethereum address, especially when hand typed. For reference, the probability that a mistyped address will pass through checksum validation is 0.027%. This means that you can be sure that the address is valid once validated through checksum.
For this reason, this tool warns you if an Ethereum address is not checksummed. Ether can still be transferred without checksummed, but make sure you double-check the address. Otherwise, you are at a risk of transferring Ether to no-man’s land.
If you like this article, be sure to check our Ethereum Validator tool by clicking here.