Skip to content

docs: clarify isHexChecksumAddress checks shape, not the checksum - #301

Open
gomesalexandre wants to merge 1 commit into
MetaMask:mainfrom
gomesalexandre:docs_ishexchecksumaddress_shape_not_checksum
Open

docs: clarify isHexChecksumAddress checks shape, not the checksum#301
gomesalexandre wants to merge 1 commit into
MetaMask:mainfrom
gomesalexandre:docs_ishexchecksumaddress_shape_not_checksum

Conversation

@gomesalexandre

@gomesalexandregomesalexandre commented Aug 17, 2026

Copy link
Copy Markdown

closes#250

what

isHexChecksumAddress's doc claims it checks for a "valid hex checksum address", but it only tests the shape - 0x followed by 40 hex characters, upper- or lower-case (HEX_CHECKSUM_ADDRESS_REGEX = /^0x[0-9a-fA-F]{40}$/u). It never keccak-hashes to verify the ERC-55 checksum, so a non-checksummed (for example all-lowercase) address passes:

isHexChecksumAddress('0x' + 'a'.repeat(40)) // => true, but not a valid ERC-55 checksum

This matches how the function is actually used - in getChecksumAddress, to assert the input address has a valid (mixed-case-allowing) shape before computing the checksum.

how

Corrects the JSDoc to describe what the function actually validates (shape, allowing the mixed case of a checksummed address) and notes it does not verify the ERC-55 checksum, pointing to getChecksumAddress for that. No behavior or name change - a rename/behavior change would be breaking and per the issue thread wants a broader look at how the function is used, so this is scoped to the documentation accuracy the issue calls out.

references

Addresses the "and documented" half of #250.


Note

Cursor Bugbot is generating a summary for commit c96211b. Configure here.

isHexChecksumAddress's doc said it checks for a "valid hex checksum
address", but it only tests the shape - 0x followed by 40 hex characters,
upper- or lower-case (HEX_CHECKSUM_ADDRESS_REGEX). It never verifies the
ERC-55 checksum, so a non-checksummed (e.g. all-lowercase) address passes.
Correct the JSDoc to describe what it actually validates and point to
getChecksumAddress for computing the checksum. No behavior or name change.
closesMetaMask#250
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

isHexChecksumAddress is poorly named and documented

1 participant

@gomesalexandre