namehash function
- String name
Implementation
Uint8List namehash(String name) {
if (name.isEmpty) {
return Uint8List(32);
}
List<int> node;
if (name.contains('.')) {
var labels = name.split('.');
node = namehash(labels.sublist(1).join('.'));
} else {
node = Uint8List(32);
}
var label = name.split('.')[0];
var labelHash = keccak256(Uint8List.fromList(label.codeUnits));
return keccak256(Uint8List.fromList([...node, ...labelHash]));
}