ens_normalize 1.0.4 ens_normalize: ^1.0.4 copied to clipboard
Ethereum Name Service (ENS) Name Normalizer adapted from namehash labs and adraffy.
ENS Normalize Dart #
- Dart implementation of ENSIP-15 - the ENS Name Normalization Standard.
- This library is being maintained by the team at Variance.
- Passes 100% of the official validation tests.
- Javascript reference implementation.
- Adapted from JavaScript implementation version 1.9.0 and Python implementation version 3.0.7.
Getting started #
dart pub add ens_normalize
Usage #
import 'package:ens_normalize/ens_normalize.dart';
void main() async {
ENSNormalize ensn = await ENSNormalize.getInstance(); // parses normalization in separate Isolate
// OR
ENSNormalize ensn = ENSNormalize(); // Passes normalization synchronously
ensn.normalize('Nick.ETH');
// nick.eth
ensn.isNormalizable('Nick.ETH');
// true
ensn.cure('Nick?.ETH');
// nick.eth
ensn.beautify('1⃣2⃣.eth');
// 1️⃣2️⃣.eth
ensn.tokenize('Nàme🧙♂.eth');
// [
// Instance of 'TokenMapped',
// Instance of 'TokenNFC',
// Instance of 'TokenValid',
// Instance of 'TokenDisallowed',
// Instance of 'TokenEmoji',
// Instance of 'TokenStop',
// Instance of 'TokenValid']
ensn.normalizations('Nàme🧙♂️.eth');
// [
// NormalizableSequence(code="NormalizableSequenceType", index=0, sequence="N", suggested="n"),
// NormalizableSequence(code="NormalizableSequenceType", index=1, sequence="🧙♂️", suggested="🧙♂")
// ]
ensn.ensProcess(
"Nàme🧙♂️1⃣.eth",
doNormalize: true,
doBeautify: true,
doTokenize: true,
doNormalizations: true,
doCure: true,
);
// Instance of 'ENSProcessResult'
}