I would like a formula that take a blockchain address in string form and converts it to its case-sensitive checksum format.
For instance calling this function on ‘0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2’ would return ‘0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2’
The process is fairly simple
- Convert the original Ethereum address into lowercase.
- Compute the SHA-3 hash of the lowercases address.
- Take the first 40 characters of the hash (which is a 64-character hexadecimal string) and replace the corresponding characters in the original lowercase address. If a character in the hash is a letter (A-F), then the corresponding character in the address should be uppercase. If a character in the hash is a number (0-9), then the corresponding character in the address should be left as lowercase.
- The final result is the checksummed version of the address.
https://www.alchemy.com/docs/how-to-handle-checksum-addresses#what-are-checksum-addresses
