Flutter Web3: Working with the Ethereum Name Service
Building decentralized applications in Flutter is not without its own quirks and portholes, as a lot of tools and SDKs for web3 are mostly built using Javascript and Typescript. I see this as both a disadvantage and an advantage. An advantage in the sense that we now have the opportunity to build/port these important tools/libraries/SDKs to native dart so we can have them ready for other developers to build upon, this is the beauty of Open Source.
I’ve embarked on a journey to build and port tools to dart for the web3, and I’ve also documented quite a few tools I feel will be essential to building decentralized applications with Flutter and Dart, Here they are: https://github.com/Zfinix/awesome-dart-web3
ENS Dart is one of my very successful attempts to port a JS package to Pure dart without any interop bindings.
It uses the web3dart package to interact directly with the ENS Smart Contract, calling functions, and listening to events.
Example Usage
Instantiating the ENS class,
All we need to do here is to pass the Web3Client instance to the ENS class and we are good to go.
final rpcUrl = 'https://mainnet.infura.io/v3/$infuraKey';
final wsUrl = 'wss://mainnet.infura.io/ws/v3/$infuraKey';
final client = Web3Client(rpcUrl, Client(), socketConnector: () {
return IOWebSocketChannel.connect(wsUrl).cast<String>();
});Get an ENS domain name from an ethereum address
final name = await ens.withAddress('0x1a5cdcFBA600e0c669795e0B65c344D5A37a4d5A').getName();Get an ethereum address and domain name from an ENS domain
/// Get address from name
final addr = await ens.withName('brantly.eth').getAddress();
print('name: $name'); // name: sea.eth
print('addr: $addr'); // addr: 0x324f9307b6d26881822c7c8692eeac39791a9756Get a textRecord from an ENS domain
/// Get text record
final textRecord = await ens.getTextRecord();print('textRecord: $textRecord'); /* EnsTextRecord {
email: me@brantly.xyz,
url: http://brantly.xyz/,
avatar: eip155:1/erc721:0xb7F7F6C52F2e2fdb1963Eab30438024864c313F6/2430,
description: "If anyone would come after me, let him deny himself and take up his cross daily and follow me. For whoever would save his life will lose it, but whoever loses his life for my sake will save it. For what does it profit a man if he gains the whole world and loses or forfeits himself?" - Jesus, Luke 9.23-25,
notice: Not for sale,
keywords: ,
com.discord: brantly.eth#9803,
com.github: brantlymillegan,
com.reddit: brantlymillegan,
com.twitter: brantlymillegan,
org.telegram: brantlymillegan,
eth.ens.delegate: https://discuss.ens.domains/t/ens-dao-delegate-applications/815/697?u=brantlymillegan
}If you’d like to open a PR about bugs or features, that would be awesome too.


