isValidChecksum static method

bool isValidChecksum(
  1. String address,
  2. Uint8List keccak256(
    1. Uint8List
    )
)

Validates if a checksummed address has the correct checksum.

Returns true if the address is all lowercase, all uppercase, or has a valid EIP-55 checksum.

Implementation

static bool isValidChecksum(
    String address, Uint8List Function(Uint8List) keccak256) {
  if (!isValid(address)) return false;

  final stripped = HexUtils.strip0x(address);

  // All lowercase or all uppercase is valid
  if (stripped == stripped.toLowerCase() ||
      stripped == stripped.toUpperCase()) {
    return true;
  }

  // Check EIP-55 checksum
  final addr = EthereumAddress.fromHex(address);
  return addr.toChecksum(keccak256) == address;
}