EthereumAddress.fromHex constructor
EthereumAddress.fromHex(
- String hex
Creates an EthereumAddress from a hex string.
The input can be checksummed or lowercase.
Throws InvalidAddressException if the address is invalid.
Implementation
factory EthereumAddress.fromHex(String hex) {
final stripped = HexUtils.strip0x(hex);
if (stripped.length != 40) {
throw InvalidAddressException(hex, 'Address must be 40 hex characters');
}
if (!HexUtils.isValid(stripped)) {
throw InvalidAddressException(hex, 'Invalid hex characters');
}
return EthereumAddress(HexUtils.decode(stripped));
}