The Ethereum Address Checksum?Test


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

  1. Take the Ethereum address and convert it to lowercase letters.
  2. Hash the lowercase address using the Keccak-256 algorithm, which generates a 32-byte hash value.
  3. Convert the hash value to hexadecimal and use it to create a checksum.

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:

  1. Convert the address to lowercase without the 0x prefix: 5aaeb6053f3e94c9b9a09f33669435e7ef1beaed.
  2. Hash the address using Keccak-256: d385650ce8fdc6db7ee3a091d34814dbc4ce18219ffae52182efff4034d707e5.
  3. Convert the hash to hexadecimal and use it to 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

  • The first character of the hash is d, which is greater than “8,” so the first character “5” of the checksum is uppercase: 0x5aaeb6053f3e94c9b9a09f33669435e7ef1beaed.
  • The second character of the hash is 3, which is less than “8,” so the second character “a” of the checksum is lowercase:?
  • Result: 0x5
  • The third character of the hash is 8, which is greater than or equal to “8,” so the third character “A” of the checksum is Uppercase:?
  • Result: 0x5aA
  • The fourth character of the hash is 5, which is less than “8,” so the second character “e” of the checksum is lowercase:?
  • Result: 0x5aAe
  • Repeat this process for each character of the address and the corresponding character of the hash to create the final checksum: 0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BEaEd.


要查看或添加评论,请登录

Prince Chisomaga的更多文章

社区洞察

其他会员也浏览了