hexEip55 property

String hexEip55

Returns this address in a hexadecimal representation, like with hex. The hexadecimal characters A-F in the address will be in lower- or uppercase depending on EIP 55.

Implementation

String get hexEip55 {
  // https://eips.ethereum.org/EIPS/eip-55#implementation
  final hex = hexNo0x.toLowerCase();
  final hash = bytesToHex(keccakAscii(hexNo0x));

  final eip55 = StringBuffer('0x');
  for (var i = 0; i < hex.length; i++) {
    if (int.parse(hash[i], radix: 16) >= 8) {
      eip55.write(hex[i].toUpperCase());
    } else {
      eip55.write(hex[i]);
    }
  }

  return eip55.toString();
}