The Ethereum Address Checksum?Test
Prince Chisomaga
Senior Backend Developer and Coach | Ethereum/Sui/Cardano Smart Contract Developer | Founder at Softzenith
The Ethereum network uses a 20-byte address to represent user accounts. Since addresses are generated as random strings of numbers and letters, the chances of accidentally entering the wrong address are high. To prevent users from losing funds due to typos and other errors, Ethereum implements a checksum test for address validation.
How it works
To do this, take each character of the lowercase address and the corresponding character of the hash value. If the character in the hash value is greater than or equal to “8”, make the corresponding character in the address uppercase. Otherwise, leave it lowercase.
For example, let’s say we have the Ethereum address 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed.?
Here’s how we can create the checksum:
领英推荐
Convert the hash value from step 2 to hexadecimal. This gives us d385650ce8fdc6db7ee3a091d34814dbc4ce18219ffae52182efff4034d707e5
We only need the first 20 bytes (40 characters) of the hash and ignore the rest, since the Ethereum address is 20 bytes.
So we have d385650ce8fdc6db7ee3a091d34814dbc4ce1821