2

I need to hardcode a big list of addresses that don't verify checksum (they're all low caps).

address[] private list = [address(this), 0xabc...];

Compiler 0.8.17 ends with an error:

SyntaxError: This looks like an address but has an invalid checksum. Correct checksummed address: "0x...". If this is not used as an address, please prepend '00'.

How can I fix, and translate the big list into checksummed or turn the error into a warning.

The error message suggests the proper checksummed address syntax, but I can't manually fix hundreds of addresses.

5

2 Answers 2

1

I created this simple tool that you can use to convert a list of non-checksummed addresses to checksummed addresses.

You can preview it and use it here: https://raw.githack.com/jeremythen/emv-checksum-address-convertor/main/index.html

This is the GitHub repo: https://github.com/jeremythen/emv-checksum-address-convertor

Check the README.md file to learn how to use it. But I think it's straightforward. Simply paste the list of non-checksummed addresses and hit the Convert button. If your list of addresses has the format [0xa1..., 0xa2...], then check the Addresses in array? checkbox so it parses it and returns the result in the same format, ready to copy and paste.

Remember the chain Id. If it's Ethereum, then leave it empty. If it's any other chain, then check the correct chain Id to use here: https://chainlist.org/

You can also use the backend tool in the index.js file, to use it with nodejs or something like that.

I hope it helps.

Check the screenshots below for an example:

enter image description here

enter image description here

1

Read this

https://docs.soliditylang.org/en/develop/types.html#address-literals

'Hexadecimal literals that pass the address checksum test, for example 0xdCad3a6d3569DF655070DEd06cb7A1b2Ccd1D3AF are of address type. Hexadecimal literals that are between 39 and 41 digits long and do not pass the checksum test produce an error. You can prepend (for integer types) or append (for bytesNN types) zeros to remove the error.'

2
  • This doesn't answer the question.
    – Bebs V
    Dec 5, 2022 at 13:54
  • you need to evaluate wether or not the address being passed clears the checksum before you add it to your array - if it doesn't clear the checksum, prepend '00', then push
    – immaxkent
    Dec 5, 2022 at 15:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.