├── .gitignore ├── .metadata ├── CHANGELOG.md ├── LICENSE ├── README.md ├── analysis_options.yaml ├── example └── main.dart ├── lib ├── ens_dart.dart └── src │ ├── const │ └── const.dart │ ├── contracts │ ├── contracts.dart │ ├── ens.g.dart │ ├── ens_registry_fallback.g.dart │ ├── ens_resolver.g.dart │ ├── ens_reverse_registrar.g.dart │ ├── ens_reverse_resolver.g.dart │ ├── ens_root.g.dart │ ├── ens_service.g.dart │ └── ens_token.g.dart │ ├── ens_dart.dart │ ├── ens_resolver.dart │ ├── models │ ├── coin_types.dart │ ├── ens_text_record.dart │ └── models.dart │ └── utils.dart ├── pubspec.yaml └── test └── ens_dart_test.dart /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | **/.env 18 | .env 19 | 20 | # The .vscode folder contains launch configuration and tasks you configure in 21 | # VS Code which you may wish to be included in version control, so this line 22 | # is commented out by default. 23 | #.vscode/ 24 | 25 | # Flutter/Dart/Pub related 26 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 27 | /pubspec.lock 28 | **/doc/api/ 29 | .dart_tool/ 30 | .packages 31 | build/ 32 | -------------------------------------------------------------------------------- /.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 262b70ece1aebf84f132c51ec4cf90be605ce61b 8 | channel: beta 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2022 Chiziaruhoma Ogbonda 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ⚡️ ENS Dart 2 | 3 | A dart library that wraps the Ethereum Name Service. 4 | 5 | The Ethereum Name Service is analogous to the Domain Name Service. It enables users and developers to use human-friendly names in place of error-prone hexadecimal addresses, content hashes, and more. 6 | 7 | - Interop with `web3dart` package 8 | - Get ENS name from ETH address 9 | - Get address from ENS name 10 | - Get contentHash 11 | - Get textRecord 12 | - Call functions on ENS smart contracts and listen for contract events 13 | 14 | ## Usage 15 | 16 | ### Get ENS name and address 17 | 18 | ENS Dart provides an interface to look up an address from a name, the reverse, and more. 19 | 20 | ```dart 21 | Future main() async { 22 | env.load('../.env'); 23 | final infuraKey = env.env['INFURA_KEY']; 24 | 25 | final rpcUrl = 'https://mainnet.infura.io/v3/$infuraKey'; 26 | final wsUrl = 'wss://mainnet.infura.io/ws/v3/$infuraKey'; 27 | 28 | final client = Web3Client(rpcUrl, Client(), socketConnector: () { 29 | return IOWebSocketChannel.connect(wsUrl).cast(); 30 | }); 31 | 32 | /// ENS client 33 | final ens = Ens(client: client); 34 | 35 | /// Get name from address 36 | final name = await ens 37 | .withAddress('0x1a5cdcFBA600e0c669795e0B65c344D5A37a4d5A') 38 | .getName(); 39 | 40 | /// Get address from name 41 | final addr = await ens.withName('brantly.eth').getAddress(); 42 | 43 | /// Get text record 44 | final textRecord = await ens.getTextRecord(); 45 | 46 | print('name: $name'); // name: sea.eth 47 | print('addr: $addr'); // addr: 0x324f9307b6d26881822c7c8692eeac39791a9756 48 | print( 49 | 'textRecord: $textRecord'); /* EnsTextRecord { 50 | email: me@brantly.xyz, 51 | url: http://brantly.xyz/, 52 | avatar: eip155:1/erc721:0xb7F7F6C52F2e2fdb1963Eab30438024864c313F6/2430, 53 | 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, 54 | notice: Not for sale, 55 | keywords: , 56 | com.discord: brantly.eth#9803, 57 | com.github: brantlymillegan, 58 | com.reddit: brantlymillegan, 59 | com.twitter: brantlymillegan, 60 | org.telegram: brantlymillegan, 61 | eth.ens.delegate: https://discuss.ens.domains/t/ens-dao-delegate-applications/815/697?u=brantlymillegan 62 | } 63 | } 64 | 65 | ``` 66 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:ens_dart/ens_dart.dart'; 2 | import 'package:dotenv/dotenv.dart' as env; 3 | 4 | import 'package:http/http.dart'; 5 | import 'package:web3dart/web3dart.dart'; 6 | import 'package:web_socket_channel/io.dart'; 7 | 8 | Future main() async { 9 | env.load('../.env'); 10 | final infuraKey = env.env['INFURA_KEY']; 11 | 12 | final rpcUrl = 'https://mainnet.infura.io/v3/$infuraKey'; 13 | final wsUrl = 'wss://mainnet.infura.io/ws/v3/$infuraKey'; 14 | 15 | final client = Web3Client(rpcUrl, Client(), socketConnector: () { 16 | return IOWebSocketChannel.connect(wsUrl).cast(); 17 | }); 18 | 19 | final ens = Ens(client: client); 20 | 21 | // ENS supports reverse resolution to allow applications to display 22 | // ENS names in place of hexadecimal addresses. 23 | final name = await ens 24 | .withAddress('0x1a5cdcFBA600e0c669795e0B65c344D5A37a4d5A') 25 | .getName(); 26 | 27 | final addr = await ens.withName('brantly.eth').getAddress(); 28 | final content = await ens.getTextRecord(); 29 | 30 | print('name: $name'); // name: sea.eth 31 | print('addr: $addr'); // addr: 0x324f9307b6d26881822c7c8692eeac39791a9756 32 | 33 | print( 34 | 'content: $content'); /* EnsTextRecord { 35 | email: me@brantly.xyz, 36 | url: http://brantly.xyz/, 37 | avatar: eip155:1/erc721:0xb7F7F6C52F2e2fdb1963Eab30438024864c313F6/2430, 38 | 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, 39 | notice: Not for sale, 40 | keywords: , 41 | com.discord: brantly.eth#9803, 42 | com.github: brantlymillegan, 43 | com.reddit: brantlymillegan, 44 | com.twitter: brantlymillegan, 45 | org.telegram: brantlymillegan, 46 | eth.ens.delegate: https://discuss.ens.domains/t/ens-dao-delegate-applications/815/697?u=brantlymillegan 47 | } */ 48 | } 49 | -------------------------------------------------------------------------------- /lib/ens_dart.dart: -------------------------------------------------------------------------------- 1 | export 'src/ens_dart.dart'; 2 | -------------------------------------------------------------------------------- /lib/src/const/const.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: non_constant_identifier_names 2 | 3 | import 'package:web3dart/web3dart.dart'; 4 | 5 | final ENS = 6 | EthereumAddress.fromHex('0xC18360217D8F7Ab5e7c516566761Ea12Ce7F9D72'); 7 | final ENS_FALLBACK_REGISTRY = 8 | EthereumAddress.fromHex('0x00000000000c2e074ec69a0dfb2997ba6c7d2e1e'); 9 | final ENS_RESOLVER = 10 | EthereumAddress.fromHex('0x4976fb03c32e5b8cfe2b6ccb31c09ba78ebaba41'); 11 | final ENS_REVERSE_RESOLVER = 12 | EthereumAddress.fromHex('0xa2c122be93b0074270ebee7f6b7292c7deb45047'); 13 | final ENS_REVERSE_REGISTRAR = 14 | EthereumAddress.fromHex('0x084b1c3c81545d370f3634392de611caabff8148'); 15 | -------------------------------------------------------------------------------- /lib/src/contracts/contracts.dart: -------------------------------------------------------------------------------- 1 | export 'ens.g.dart'; 2 | export 'ens_root.g.dart'; 3 | export 'ens_token.g.dart' hide Transfer; 4 | export 'ens_service.g.dart' hide Transfer, NewTTL, NewResolver, NewOwner; 5 | export 'ens_resolver.g.dart'; 6 | export 'ens_reverse_registrar.g.dart'; 7 | export 'ens_reverse_resolver.g.dart'; 8 | export 'ens_registry_fallback.g.dart' 9 | hide ApprovalForAll, NewTTL, Transfer, NewResolver, NewOwner; 10 | -------------------------------------------------------------------------------- /lib/src/contracts/ens.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:web3dart/web3dart.dart' as _i1; 4 | import 'dart:typed_data' as _i2; 5 | 6 | final _contractAbi = _i1.ContractAbi.fromJson( 7 | '[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"recordExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setRecord","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setSubnodeRecord","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setTTL","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"ttl","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"}]', 8 | 'EnsContract'); 9 | 10 | class EnsContract extends _i1.GeneratedContract { 11 | EnsContract( 12 | {required _i1.EthereumAddress address, 13 | required _i1.Web3Client client, 14 | int? chainId}) 15 | : super(_i1.DeployedContract(_contractAbi, address), client, chainId); 16 | 17 | /// The optional [atBlock] parameter can be used to view historical data. When 18 | /// set, the function will be evaluated in the specified block. By default, the 19 | /// latest on-chain block will be used. 20 | Future isApprovedForAll( 21 | _i1.EthereumAddress owner, _i1.EthereumAddress operator, 22 | {_i1.BlockNum? atBlock}) async { 23 | final function = self.abi.functions[0]; 24 | assert(checkSignature(function, 'e985e9c5')); 25 | final params = [owner, operator]; 26 | final response = await read(function, params, atBlock); 27 | return (response[0] as bool); 28 | } 29 | 30 | /// The optional [atBlock] parameter can be used to view historical data. When 31 | /// set, the function will be evaluated in the specified block. By default, the 32 | /// latest on-chain block will be used. 33 | Future<_i1.EthereumAddress> owner(_i2.Uint8List node, 34 | {_i1.BlockNum? atBlock}) async { 35 | final function = self.abi.functions[1]; 36 | assert(checkSignature(function, '02571be3')); 37 | final params = [node]; 38 | final response = await read(function, params, atBlock); 39 | return (response[0] as _i1.EthereumAddress); 40 | } 41 | 42 | /// The optional [atBlock] parameter can be used to view historical data. When 43 | /// set, the function will be evaluated in the specified block. By default, the 44 | /// latest on-chain block will be used. 45 | Future recordExists(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 46 | final function = self.abi.functions[2]; 47 | assert(checkSignature(function, 'f79fe538')); 48 | final params = [node]; 49 | final response = await read(function, params, atBlock); 50 | return (response[0] as bool); 51 | } 52 | 53 | /// The optional [atBlock] parameter can be used to view historical data. When 54 | /// set, the function will be evaluated in the specified block. By default, the 55 | /// latest on-chain block will be used. 56 | Future<_i1.EthereumAddress> resolver(_i2.Uint8List node, 57 | {_i1.BlockNum? atBlock}) async { 58 | final function = self.abi.functions[3]; 59 | assert(checkSignature(function, '0178b8bf')); 60 | final params = [node]; 61 | final response = await read(function, params, atBlock); 62 | return (response[0] as _i1.EthereumAddress); 63 | } 64 | 65 | /// The optional [transaction] parameter can be used to override parameters 66 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 67 | /// set by the contract. 68 | Future setApprovalForAll(_i1.EthereumAddress operator, bool approved, 69 | {required _i1.Credentials credentials, 70 | _i1.Transaction? transaction}) async { 71 | final function = self.abi.functions[4]; 72 | assert(checkSignature(function, 'a22cb465')); 73 | final params = [operator, approved]; 74 | return write(credentials, transaction, function, params); 75 | } 76 | 77 | /// The optional [transaction] parameter can be used to override parameters 78 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 79 | /// set by the contract. 80 | Future setOwner(_i2.Uint8List node, _i1.EthereumAddress owner, 81 | {required _i1.Credentials credentials, 82 | _i1.Transaction? transaction}) async { 83 | final function = self.abi.functions[5]; 84 | assert(checkSignature(function, '5b0fc9c3')); 85 | final params = [node, owner]; 86 | return write(credentials, transaction, function, params); 87 | } 88 | 89 | /// The optional [transaction] parameter can be used to override parameters 90 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 91 | /// set by the contract. 92 | Future setRecord(_i2.Uint8List node, _i1.EthereumAddress owner, 93 | _i1.EthereumAddress resolver, BigInt ttl, 94 | {required _i1.Credentials credentials, 95 | _i1.Transaction? transaction}) async { 96 | final function = self.abi.functions[6]; 97 | assert(checkSignature(function, 'cf408823')); 98 | final params = [node, owner, resolver, ttl]; 99 | return write(credentials, transaction, function, params); 100 | } 101 | 102 | /// The optional [transaction] parameter can be used to override parameters 103 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 104 | /// set by the contract. 105 | Future setResolver(_i2.Uint8List node, _i1.EthereumAddress resolver, 106 | {required _i1.Credentials credentials, 107 | _i1.Transaction? transaction}) async { 108 | final function = self.abi.functions[7]; 109 | assert(checkSignature(function, '1896f70a')); 110 | final params = [node, resolver]; 111 | return write(credentials, transaction, function, params); 112 | } 113 | 114 | /// The optional [transaction] parameter can be used to override parameters 115 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 116 | /// set by the contract. 117 | Future setSubnodeOwner( 118 | _i2.Uint8List node, _i2.Uint8List label, _i1.EthereumAddress owner, 119 | {required _i1.Credentials credentials, 120 | _i1.Transaction? transaction}) async { 121 | final function = self.abi.functions[8]; 122 | assert(checkSignature(function, '06ab5923')); 123 | final params = [node, label, owner]; 124 | return write(credentials, transaction, function, params); 125 | } 126 | 127 | /// The optional [transaction] parameter can be used to override parameters 128 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 129 | /// set by the contract. 130 | Future setSubnodeRecord(_i2.Uint8List node, _i2.Uint8List label, 131 | _i1.EthereumAddress owner, _i1.EthereumAddress resolver, BigInt ttl, 132 | {required _i1.Credentials credentials, 133 | _i1.Transaction? transaction}) async { 134 | final function = self.abi.functions[9]; 135 | assert(checkSignature(function, '5ef2c7f0')); 136 | final params = [node, label, owner, resolver, ttl]; 137 | return write(credentials, transaction, function, params); 138 | } 139 | 140 | /// The optional [transaction] parameter can be used to override parameters 141 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 142 | /// set by the contract. 143 | Future setTTL(_i2.Uint8List node, BigInt ttl, 144 | {required _i1.Credentials credentials, 145 | _i1.Transaction? transaction}) async { 146 | final function = self.abi.functions[10]; 147 | assert(checkSignature(function, '14ab9038')); 148 | final params = [node, ttl]; 149 | return write(credentials, transaction, function, params); 150 | } 151 | 152 | /// The optional [atBlock] parameter can be used to view historical data. When 153 | /// set, the function will be evaluated in the specified block. By default, the 154 | /// latest on-chain block will be used. 155 | Future ttl(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 156 | final function = self.abi.functions[11]; 157 | assert(checkSignature(function, '16a25cbd')); 158 | final params = [node]; 159 | final response = await read(function, params, atBlock); 160 | return (response[0] as BigInt); 161 | } 162 | 163 | /// Returns a live stream of all ApprovalForAll events emitted by this contract. 164 | Stream approvalForAllEvents( 165 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 166 | final event = self.event('ApprovalForAll'); 167 | final filter = _i1.FilterOptions.events( 168 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 169 | return client.events(filter).map((_i1.FilterEvent result) { 170 | final decoded = event.decodeResults(result.topics!, result.data!); 171 | return ApprovalForAll(decoded); 172 | }); 173 | } 174 | 175 | /// Returns a live stream of all NewOwner events emitted by this contract. 176 | Stream newOwnerEvents( 177 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 178 | final event = self.event('NewOwner'); 179 | final filter = _i1.FilterOptions.events( 180 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 181 | return client.events(filter).map((_i1.FilterEvent result) { 182 | final decoded = event.decodeResults(result.topics!, result.data!); 183 | return NewOwner(decoded); 184 | }); 185 | } 186 | 187 | /// Returns a live stream of all NewResolver events emitted by this contract. 188 | Stream newResolverEvents( 189 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 190 | final event = self.event('NewResolver'); 191 | final filter = _i1.FilterOptions.events( 192 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 193 | return client.events(filter).map((_i1.FilterEvent result) { 194 | final decoded = event.decodeResults(result.topics!, result.data!); 195 | return NewResolver(decoded); 196 | }); 197 | } 198 | 199 | /// Returns a live stream of all NewTTL events emitted by this contract. 200 | Stream newTTLEvents( 201 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 202 | final event = self.event('NewTTL'); 203 | final filter = _i1.FilterOptions.events( 204 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 205 | return client.events(filter).map((_i1.FilterEvent result) { 206 | final decoded = event.decodeResults(result.topics!, result.data!); 207 | return NewTTL(decoded); 208 | }); 209 | } 210 | 211 | /// Returns a live stream of all Transfer events emitted by this contract. 212 | Stream transferEvents( 213 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 214 | final event = self.event('Transfer'); 215 | final filter = _i1.FilterOptions.events( 216 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 217 | return client.events(filter).map((_i1.FilterEvent result) { 218 | final decoded = event.decodeResults(result.topics!, result.data!); 219 | return Transfer(decoded); 220 | }); 221 | } 222 | } 223 | 224 | class ApprovalForAll { 225 | ApprovalForAll(List response) 226 | : owner = (response[0] as _i1.EthereumAddress), 227 | operator = (response[1] as _i1.EthereumAddress), 228 | approved = (response[2] as bool); 229 | 230 | final _i1.EthereumAddress owner; 231 | 232 | final _i1.EthereumAddress operator; 233 | 234 | final bool approved; 235 | } 236 | 237 | class NewOwner { 238 | NewOwner(List response) 239 | : node = (response[0] as _i2.Uint8List), 240 | label = (response[1] as _i2.Uint8List), 241 | owner = (response[2] as _i1.EthereumAddress); 242 | 243 | final _i2.Uint8List node; 244 | 245 | final _i2.Uint8List label; 246 | 247 | final _i1.EthereumAddress owner; 248 | } 249 | 250 | class NewResolver { 251 | NewResolver(List response) 252 | : node = (response[0] as _i2.Uint8List), 253 | resolver = (response[1] as _i1.EthereumAddress); 254 | 255 | final _i2.Uint8List node; 256 | 257 | final _i1.EthereumAddress resolver; 258 | } 259 | 260 | class NewTTL { 261 | NewTTL(List response) 262 | : node = (response[0] as _i2.Uint8List), 263 | ttl = (response[1] as BigInt); 264 | 265 | final _i2.Uint8List node; 266 | 267 | final BigInt ttl; 268 | } 269 | 270 | class Transfer { 271 | Transfer(List response) 272 | : node = (response[0] as _i2.Uint8List), 273 | owner = (response[1] as _i1.EthereumAddress); 274 | 275 | final _i2.Uint8List node; 276 | 277 | final _i1.EthereumAddress owner; 278 | } 279 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_registry_fallback.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:web3dart/web3dart.dart' as _i1; 4 | import 'dart:typed_data' as _i2; 5 | 6 | final _contractAbi = _i1.ContractAbi.fromJson( 7 | '[{"inputs":[{"internalType":"contract ENS","name":"_old","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"old","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"recordExists","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setRecord","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setSubnodeRecord","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint64","name":"ttl","type":"uint64"}],"name":"setTTL","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"ttl","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"payable":false,"stateMutability":"view","type":"function"}]', 8 | 'EnsRegistryFallback'); 9 | 10 | class EnsRegistryFallback extends _i1.GeneratedContract { 11 | EnsRegistryFallback({ 12 | required _i1.EthereumAddress address, 13 | required _i1.Web3Client client, 14 | int? chainId, 15 | }) : super(_i1.DeployedContract(_contractAbi, address), client, chainId); 16 | 17 | /// The optional [atBlock] parameter can be used to view historical data. When 18 | /// set, the function will be evaluated in the specified block. By default, the 19 | /// latest on-chain block will be used. 20 | Future isApprovedForAll( 21 | _i1.EthereumAddress owner, _i1.EthereumAddress operator, 22 | {_i1.BlockNum? atBlock}) async { 23 | final function = self.abi.functions[1]; 24 | assert(checkSignature(function, 'e985e9c5')); 25 | final params = [owner, operator]; 26 | final response = await read(function, params, atBlock); 27 | return (response[0] as bool); 28 | } 29 | 30 | /// The optional [atBlock] parameter can be used to view historical data. When 31 | /// set, the function will be evaluated in the specified block. By default, the 32 | /// latest on-chain block will be used. 33 | Future<_i1.EthereumAddress> old({_i1.BlockNum? atBlock}) async { 34 | final function = self.abi.functions[2]; 35 | assert(checkSignature(function, 'b83f8663')); 36 | final params = []; 37 | final response = await read(function, params, atBlock); 38 | return (response[0] as _i1.EthereumAddress); 39 | } 40 | 41 | /// The optional [atBlock] parameter can be used to view historical data. When 42 | /// set, the function will be evaluated in the specified block. By default, the 43 | /// latest on-chain block will be used. 44 | Future<_i1.EthereumAddress> owner(_i2.Uint8List node, 45 | {_i1.BlockNum? atBlock}) async { 46 | final function = self.abi.functions[3]; 47 | assert(checkSignature(function, '02571be3')); 48 | final params = [node]; 49 | final response = await read(function, params, atBlock); 50 | return (response[0] as _i1.EthereumAddress); 51 | } 52 | 53 | /// The optional [atBlock] parameter can be used to view historical data. When 54 | /// set, the function will be evaluated in the specified block. By default, the 55 | /// latest on-chain block will be used. 56 | Future recordExists(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 57 | final function = self.abi.functions[4]; 58 | assert(checkSignature(function, 'f79fe538')); 59 | final params = [node]; 60 | final response = await read(function, params, atBlock); 61 | return (response[0] as bool); 62 | } 63 | 64 | /// The optional [atBlock] parameter can be used to view historical data. When 65 | /// set, the function will be evaluated in the specified block. By default, the 66 | /// latest on-chain block will be used. 67 | Future<_i1.EthereumAddress> resolver(_i2.Uint8List node, 68 | {_i1.BlockNum? atBlock}) async { 69 | final function = self.abi.functions[5]; 70 | assert(checkSignature(function, '0178b8bf')); 71 | final params = [node]; 72 | final response = await read(function, params, atBlock); 73 | return (response[0] as _i1.EthereumAddress); 74 | } 75 | 76 | /// The optional [transaction] parameter can be used to override parameters 77 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 78 | /// set by the contract. 79 | Future setApprovalForAll(_i1.EthereumAddress operator, bool approved, 80 | {required _i1.Credentials credentials, 81 | _i1.Transaction? transaction}) async { 82 | final function = self.abi.functions[6]; 83 | assert(checkSignature(function, 'a22cb465')); 84 | final params = [operator, approved]; 85 | return write(credentials, transaction, function, params); 86 | } 87 | 88 | /// The optional [transaction] parameter can be used to override parameters 89 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 90 | /// set by the contract. 91 | Future setOwner(_i2.Uint8List node, _i1.EthereumAddress owner, 92 | {required _i1.Credentials credentials, 93 | _i1.Transaction? transaction}) async { 94 | final function = self.abi.functions[7]; 95 | assert(checkSignature(function, '5b0fc9c3')); 96 | final params = [node, owner]; 97 | return write(credentials, transaction, function, params); 98 | } 99 | 100 | /// The optional [transaction] parameter can be used to override parameters 101 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 102 | /// set by the contract. 103 | Future setRecord(_i2.Uint8List node, _i1.EthereumAddress owner, 104 | _i1.EthereumAddress resolver, BigInt ttl, 105 | {required _i1.Credentials credentials, 106 | _i1.Transaction? transaction}) async { 107 | final function = self.abi.functions[8]; 108 | assert(checkSignature(function, 'cf408823')); 109 | final params = [node, owner, resolver, ttl]; 110 | return write(credentials, transaction, function, params); 111 | } 112 | 113 | /// The optional [transaction] parameter can be used to override parameters 114 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 115 | /// set by the contract. 116 | Future setResolver(_i2.Uint8List node, _i1.EthereumAddress resolver, 117 | {required _i1.Credentials credentials, 118 | _i1.Transaction? transaction}) async { 119 | final function = self.abi.functions[9]; 120 | assert(checkSignature(function, '1896f70a')); 121 | final params = [node, resolver]; 122 | return write(credentials, transaction, function, params); 123 | } 124 | 125 | /// The optional [transaction] parameter can be used to override parameters 126 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 127 | /// set by the contract. 128 | Future setSubnodeOwner( 129 | _i2.Uint8List node, _i2.Uint8List label, _i1.EthereumAddress owner, 130 | {required _i1.Credentials credentials, 131 | _i1.Transaction? transaction}) async { 132 | final function = self.abi.functions[10]; 133 | assert(checkSignature(function, '06ab5923')); 134 | final params = [node, label, owner]; 135 | return write(credentials, transaction, function, params); 136 | } 137 | 138 | /// The optional [transaction] parameter can be used to override parameters 139 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 140 | /// set by the contract. 141 | Future setSubnodeRecord(_i2.Uint8List node, _i2.Uint8List label, 142 | _i1.EthereumAddress owner, _i1.EthereumAddress resolver, BigInt ttl, 143 | {required _i1.Credentials credentials, 144 | _i1.Transaction? transaction}) async { 145 | final function = self.abi.functions[11]; 146 | assert(checkSignature(function, '5ef2c7f0')); 147 | final params = [node, label, owner, resolver, ttl]; 148 | return write(credentials, transaction, function, params); 149 | } 150 | 151 | /// The optional [transaction] parameter can be used to override parameters 152 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 153 | /// set by the contract. 154 | Future setTTL(_i2.Uint8List node, BigInt ttl, 155 | {required _i1.Credentials credentials, 156 | _i1.Transaction? transaction}) async { 157 | final function = self.abi.functions[12]; 158 | assert(checkSignature(function, '14ab9038')); 159 | final params = [node, ttl]; 160 | return write(credentials, transaction, function, params); 161 | } 162 | 163 | /// The optional [atBlock] parameter can be used to view historical data. When 164 | /// set, the function will be evaluated in the specified block. By default, the 165 | /// latest on-chain block will be used. 166 | Future ttl(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 167 | final function = self.abi.functions[13]; 168 | assert(checkSignature(function, '16a25cbd')); 169 | final params = [node]; 170 | final response = await read(function, params, atBlock); 171 | return (response[0] as BigInt); 172 | } 173 | 174 | /// Returns a live stream of all ApprovalForAll events emitted by this contract. 175 | Stream approvalForAllEvents( 176 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 177 | final event = self.event('ApprovalForAll'); 178 | final filter = _i1.FilterOptions.events( 179 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 180 | return client.events(filter).map((_i1.FilterEvent result) { 181 | final decoded = event.decodeResults(result.topics!, result.data!); 182 | return ApprovalForAll(decoded); 183 | }); 184 | } 185 | 186 | /// Returns a live stream of all NewOwner events emitted by this contract. 187 | Stream newOwnerEvents( 188 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 189 | final event = self.event('NewOwner'); 190 | final filter = _i1.FilterOptions.events( 191 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 192 | return client.events(filter).map((_i1.FilterEvent result) { 193 | final decoded = event.decodeResults(result.topics!, result.data!); 194 | return NewOwner(decoded); 195 | }); 196 | } 197 | 198 | /// Returns a live stream of all NewResolver events emitted by this contract. 199 | Stream newResolverEvents( 200 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 201 | final event = self.event('NewResolver'); 202 | final filter = _i1.FilterOptions.events( 203 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 204 | return client.events(filter).map((_i1.FilterEvent result) { 205 | final decoded = event.decodeResults(result.topics!, result.data!); 206 | return NewResolver(decoded); 207 | }); 208 | } 209 | 210 | /// Returns a live stream of all NewTTL events emitted by this contract. 211 | Stream newTTLEvents( 212 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 213 | final event = self.event('NewTTL'); 214 | final filter = _i1.FilterOptions.events( 215 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 216 | return client.events(filter).map((_i1.FilterEvent result) { 217 | final decoded = event.decodeResults(result.topics!, result.data!); 218 | return NewTTL(decoded); 219 | }); 220 | } 221 | 222 | /// Returns a live stream of all Transfer events emitted by this contract. 223 | Stream transferEvents( 224 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 225 | final event = self.event('Transfer'); 226 | final filter = _i1.FilterOptions.events( 227 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 228 | return client.events(filter).map((_i1.FilterEvent result) { 229 | final decoded = event.decodeResults(result.topics!, result.data!); 230 | return Transfer(decoded); 231 | }); 232 | } 233 | } 234 | 235 | class ApprovalForAll { 236 | ApprovalForAll(List response) 237 | : owner = (response[0] as _i1.EthereumAddress), 238 | operator = (response[1] as _i1.EthereumAddress), 239 | approved = (response[2] as bool); 240 | 241 | final _i1.EthereumAddress owner; 242 | 243 | final _i1.EthereumAddress operator; 244 | 245 | final bool approved; 246 | } 247 | 248 | class NewOwner { 249 | NewOwner(List response) 250 | : node = (response[0] as _i2.Uint8List), 251 | label = (response[1] as _i2.Uint8List), 252 | owner = (response[2] as _i1.EthereumAddress); 253 | 254 | final _i2.Uint8List node; 255 | 256 | final _i2.Uint8List label; 257 | 258 | final _i1.EthereumAddress owner; 259 | } 260 | 261 | class NewResolver { 262 | NewResolver(List response) 263 | : node = (response[0] as _i2.Uint8List), 264 | resolver = (response[1] as _i1.EthereumAddress); 265 | 266 | final _i2.Uint8List node; 267 | 268 | final _i1.EthereumAddress resolver; 269 | } 270 | 271 | class NewTTL { 272 | NewTTL(List response) 273 | : node = (response[0] as _i2.Uint8List), 274 | ttl = (response[1] as BigInt); 275 | 276 | final _i2.Uint8List node; 277 | 278 | final BigInt ttl; 279 | } 280 | 281 | class Transfer { 282 | Transfer(List response) 283 | : node = (response[0] as _i2.Uint8List), 284 | owner = (response[1] as _i1.EthereumAddress); 285 | 286 | final _i2.Uint8List node; 287 | 288 | final _i1.EthereumAddress owner; 289 | } 290 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_resolver.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:ens_dart/src/ens_dart.dart'; 4 | import 'package:web3dart/web3dart.dart' as _i1; 5 | import 'dart:typed_data' as _i2; 6 | 7 | final _contractAbi = _i1.ContractAbi.fromJson( 8 | '[{"inputs":[{"internalType":"contract ENS","name":"_ens","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"contentType","type":"uint256"}],"name":"ABIChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"address","name":"a","type":"address"}],"name":"AddrChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"coinType","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"newAddress","type":"bytes"}],"name":"AddressChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"target","type":"address"},{"indexed":false,"internalType":"bool","name":"isAuthorised","type":"bool"}],"name":"AuthorisationChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"hash","type":"bytes"}],"name":"ContenthashChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"},{"indexed":false,"internalType":"bytes","name":"record","type":"bytes"}],"name":"DNSRecordChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes","name":"name","type":"bytes"},{"indexed":false,"internalType":"uint16","name":"resource","type":"uint16"}],"name":"DNSRecordDeleted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"DNSZoneCleared","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"indexed":false,"internalType":"address","name":"implementer","type":"address"}],"name":"InterfaceChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"string","name":"name","type":"string"}],"name":"NameChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"x","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"PubkeyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"node","type":"bytes32"},{"indexed":true,"internalType":"string","name":"indexedKey","type":"string"},{"indexed":false,"internalType":"string","name":"key","type":"string"}],"name":"TextChanged","type":"event"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentTypes","type":"uint256"}],"name":"ABI","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"addr","outputs":[{"internalType":"address payable","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"}],"name":"addr","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"}],"name":"authorisations","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"clearDNSZone","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"contenthash","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"},{"internalType":"uint16","name":"resource","type":"uint16"}],"name":"dnsRecord","outputs":[{"internalType":"bytes","name":"","type":"bytes"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"name","type":"bytes32"}],"name":"hasDNSRecords","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"interfaceImplementer","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"}],"name":"pubkey","outputs":[{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"contentType","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setABI","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"uint256","name":"coinType","type":"uint256"},{"internalType":"bytes","name":"a","type":"bytes"}],"name":"setAddr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"a","type":"address"}],"name":"setAddr","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"address","name":"target","type":"address"},{"internalType":"bool","name":"isAuthorised","type":"bool"}],"name":"setAuthorisation","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"hash","type":"bytes"}],"name":"setContenthash","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"setDNSRecords","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes4","name":"interfaceID","type":"bytes4"},{"internalType":"address","name":"implementer","type":"address"}],"name":"setInterface","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"bytes32","name":"x","type":"bytes32"},{"internalType":"bytes32","name":"y","type":"bytes32"}],"name":"setPubkey","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"},{"internalType":"string","name":"value","type":"string"}],"name":"setText","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"key","type":"string"}],"name":"text","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"}]', 9 | 'Ens'); 10 | 11 | class Ens extends _i1.GeneratedContract { 12 | Ens( 13 | {_i1.EthereumAddress? address, 14 | required _i1.Web3Client client, 15 | int? chainId}) 16 | : super( 17 | _i1.DeployedContract( 18 | _contractAbi, 19 | address ?? ENS_RESOLVER, 20 | ), 21 | client, 22 | chainId, 23 | ); 24 | 25 | String? _ensName; 26 | String? get ensName => _ensName; 27 | Ens withName(String? _name) { 28 | _ensName = _name; 29 | return this; 30 | } 31 | 32 | EnsTextRecord? _textRecord; 33 | EnsTextRecord? get textRecord => _textRecord; 34 | void setEnsTextRecord(EnsTextRecord? _) { 35 | _textRecord = _; 36 | } 37 | 38 | Ens reverseEns(_i1.EthereumAddress addr) => Ens( 39 | address: addr, 40 | client: client, 41 | ); 42 | 43 | _i1.EthereumAddress? _ensAddress; 44 | _i1.EthereumAddress? get ensAddress => _ensAddress; 45 | Ens withAddress(Object? _) { 46 | if (_.runtimeType == _i1.EthereumAddress) { 47 | _ensAddress = _ as _i1.EthereumAddress; 48 | } else { 49 | _ensAddress = _i1.EthereumAddress.fromHex('${_ ?? ''}'); 50 | } 51 | return this; 52 | } 53 | 54 | /// The optional [atBlock] parameter can be used to view historical data. When 55 | /// set, the function will be evaluated in the specified block. By default, the 56 | /// latest on-chain block will be used. 57 | Future abi(_i2.Uint8List node, BigInt contentTypes, 58 | {_i1.BlockNum? atBlock}) async { 59 | final function = self.abi.functions[1]; 60 | assert(checkSignature(function, '2203ab56')); 61 | final params = [node, contentTypes]; 62 | final response = await read(function, params, atBlock); 63 | return ABI(response); 64 | } 65 | 66 | /// The optional [atBlock] parameter can be used to view historical data. When 67 | /// set, the function will be evaluated in the specified block. By default, the 68 | /// latest on-chain block will be used. 69 | Future<_i1.EthereumAddress> addr(_i2.Uint8List node, 70 | {_i1.BlockNum? atBlock}) async { 71 | final function = self.abi.functions[2]; 72 | assert(checkSignature(function, '3b3b57de')); 73 | final params = [node]; 74 | final response = await read(function, params, atBlock); 75 | return (response[0] as _i1.EthereumAddress); 76 | } 77 | 78 | /// The optional [atBlock] parameter can be used to view historical data. When 79 | /// set, the function will be evaluated in the specified block. By default, the 80 | /// latest on-chain block will be used. 81 | Future<_i2.Uint8List> addr$2(_i2.Uint8List node, BigInt coinType, 82 | {_i1.BlockNum? atBlock}) async { 83 | final function = self.abi.functions[3]; 84 | assert(checkSignature(function, 'f1cb7e06')); 85 | final params = [node, coinType]; 86 | final response = await read(function, params, atBlock); 87 | return (response[0] as _i2.Uint8List); 88 | } 89 | 90 | /// The optional [atBlock] parameter can be used to view historical data. When 91 | /// set, the function will be evaluated in the specified block. By default, the 92 | /// latest on-chain block will be used. 93 | Future authorisations(_i2.Uint8List $param5, 94 | _i1.EthereumAddress $param6, _i1.EthereumAddress $param7, 95 | {_i1.BlockNum? atBlock}) async { 96 | final function = self.abi.functions[4]; 97 | assert(checkSignature(function, 'f86bc879')); 98 | final params = [$param5, $param6, $param7]; 99 | final response = await read(function, params, atBlock); 100 | return (response[0] as bool); 101 | } 102 | 103 | /// The optional [transaction] parameter can be used to override parameters 104 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 105 | /// set by the contract. 106 | Future clearDNSZone(_i2.Uint8List node, 107 | {required _i1.Credentials credentials, 108 | _i1.Transaction? transaction}) async { 109 | final function = self.abi.functions[5]; 110 | assert(checkSignature(function, 'ad5780af')); 111 | final params = [node]; 112 | return write(credentials, transaction, function, params); 113 | } 114 | 115 | /// The optional [atBlock] parameter can be used to view historical data. When 116 | /// set, the function will be evaluated in the specified block. By default, the 117 | /// latest on-chain block will be used. 118 | Future<_i2.Uint8List> contenthash(_i2.Uint8List node, 119 | {_i1.BlockNum? atBlock}) async { 120 | final function = self.abi.functions[6]; 121 | assert(checkSignature(function, 'bc1c58d1')); 122 | final params = [node]; 123 | final response = await read(function, params, atBlock); 124 | return (response[0] as _i2.Uint8List); 125 | } 126 | 127 | /// The optional [atBlock] parameter can be used to view historical data. When 128 | /// set, the function will be evaluated in the specified block. By default, the 129 | /// latest on-chain block will be used. 130 | Future<_i2.Uint8List> dnsRecord( 131 | _i2.Uint8List node, _i2.Uint8List name, BigInt resource, 132 | {_i1.BlockNum? atBlock}) async { 133 | final function = self.abi.functions[7]; 134 | assert(checkSignature(function, 'a8fa5682')); 135 | final params = [node, name, resource]; 136 | final response = await read(function, params, atBlock); 137 | return (response[0] as _i2.Uint8List); 138 | } 139 | 140 | /// The optional [atBlock] parameter can be used to view historical data. When 141 | /// set, the function will be evaluated in the specified block. By default, the 142 | /// latest on-chain block will be used. 143 | Future hasDNSRecords(_i2.Uint8List node, _i2.Uint8List name, 144 | {_i1.BlockNum? atBlock}) async { 145 | final function = self.abi.functions[8]; 146 | assert(checkSignature(function, '4cbf6ba4')); 147 | final params = [node, name]; 148 | final response = await read(function, params, atBlock); 149 | return (response[0] as bool); 150 | } 151 | 152 | /// The optional [atBlock] parameter can be used to view historical data. When 153 | /// set, the function will be evaluated in the specified block. By default, the 154 | /// latest on-chain block will be used. 155 | Future<_i1.EthereumAddress> interfaceImplementer( 156 | _i2.Uint8List node, _i2.Uint8List interfaceID, 157 | {_i1.BlockNum? atBlock}) async { 158 | final function = self.abi.functions[9]; 159 | assert(checkSignature(function, '124a319c')); 160 | final params = [node, interfaceID]; 161 | final response = await read(function, params, atBlock); 162 | return (response[0] as _i1.EthereumAddress); 163 | } 164 | 165 | /// The optional [atBlock] parameter can be used to view historical data. When 166 | /// set, the function will be evaluated in the specified block. By default, the 167 | /// latest on-chain block will be used. 168 | Future name(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 169 | final function = self.abi.functions[10]; 170 | assert(checkSignature(function, '691f3431')); 171 | final params = [node]; 172 | final response = await read(function, params, atBlock); 173 | return (response[0] as String); 174 | } 175 | 176 | /// The optional [atBlock] parameter can be used to view historical data. When 177 | /// set, the function will be evaluated in the specified block. By default, the 178 | /// latest on-chain block will be used. 179 | Future pubkey(_i2.Uint8List node, {_i1.BlockNum? atBlock}) async { 180 | final function = self.abi.functions[11]; 181 | assert(checkSignature(function, 'c8690233')); 182 | final params = [node]; 183 | final response = await read(function, params, atBlock); 184 | return Pubkey(response); 185 | } 186 | 187 | /// The optional [transaction] parameter can be used to override parameters 188 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 189 | /// set by the contract. 190 | Future setABI( 191 | _i2.Uint8List node, BigInt contentType, _i2.Uint8List data, 192 | {required _i1.Credentials credentials, 193 | _i1.Transaction? transaction}) async { 194 | final function = self.abi.functions[12]; 195 | assert(checkSignature(function, '623195b0')); 196 | final params = [node, contentType, data]; 197 | return write(credentials, transaction, function, params); 198 | } 199 | 200 | /// The optional [transaction] parameter can be used to override parameters 201 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 202 | /// set by the contract. 203 | Future setAddr(_i2.Uint8List node, BigInt coinType, _i2.Uint8List a, 204 | {required _i1.Credentials credentials, 205 | _i1.Transaction? transaction}) async { 206 | final function = self.abi.functions[13]; 207 | assert(checkSignature(function, '8b95dd71')); 208 | final params = [node, coinType, a]; 209 | return write(credentials, transaction, function, params); 210 | } 211 | 212 | /// The optional [transaction] parameter can be used to override parameters 213 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 214 | /// set by the contract. 215 | Future setAddr$2(_i2.Uint8List node, _i1.EthereumAddress a, 216 | {required _i1.Credentials credentials, 217 | _i1.Transaction? transaction}) async { 218 | final function = self.abi.functions[14]; 219 | assert(checkSignature(function, 'd5fa2b00')); 220 | final params = [node, a]; 221 | return write(credentials, transaction, function, params); 222 | } 223 | 224 | /// The optional [transaction] parameter can be used to override parameters 225 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 226 | /// set by the contract. 227 | Future setAuthorisation( 228 | _i2.Uint8List node, _i1.EthereumAddress target, bool isAuthorised, 229 | {required _i1.Credentials credentials, 230 | _i1.Transaction? transaction}) async { 231 | final function = self.abi.functions[15]; 232 | assert(checkSignature(function, '3e9ce794')); 233 | final params = [node, target, isAuthorised]; 234 | return write(credentials, transaction, function, params); 235 | } 236 | 237 | /// The optional [transaction] parameter can be used to override parameters 238 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 239 | /// set by the contract. 240 | Future setContenthash(_i2.Uint8List node, _i2.Uint8List hash, 241 | {required _i1.Credentials credentials, 242 | _i1.Transaction? transaction}) async { 243 | final function = self.abi.functions[16]; 244 | assert(checkSignature(function, '304e6ade')); 245 | final params = [node, hash]; 246 | return write(credentials, transaction, function, params); 247 | } 248 | 249 | /// The optional [transaction] parameter can be used to override parameters 250 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 251 | /// set by the contract. 252 | Future setDNSRecords(_i2.Uint8List node, _i2.Uint8List data, 253 | {required _i1.Credentials credentials, 254 | _i1.Transaction? transaction}) async { 255 | final function = self.abi.functions[17]; 256 | assert(checkSignature(function, '0af179d7')); 257 | final params = [node, data]; 258 | return write(credentials, transaction, function, params); 259 | } 260 | 261 | /// The optional [transaction] parameter can be used to override parameters 262 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 263 | /// set by the contract. 264 | Future setInterface(_i2.Uint8List node, _i2.Uint8List interfaceID, 265 | _i1.EthereumAddress implementer, 266 | {required _i1.Credentials credentials, 267 | _i1.Transaction? transaction}) async { 268 | final function = self.abi.functions[18]; 269 | assert(checkSignature(function, 'e59d895d')); 270 | final params = [node, interfaceID, implementer]; 271 | return write(credentials, transaction, function, params); 272 | } 273 | 274 | /// The optional [transaction] parameter can be used to override parameters 275 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 276 | /// set by the contract. 277 | Future setName(_i2.Uint8List node, String name, 278 | {required _i1.Credentials credentials, 279 | _i1.Transaction? transaction}) async { 280 | final function = self.abi.functions[19]; 281 | assert(checkSignature(function, '77372213')); 282 | final params = [node, name]; 283 | return write(credentials, transaction, function, params); 284 | } 285 | 286 | /// The optional [transaction] parameter can be used to override parameters 287 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 288 | /// set by the contract. 289 | Future setPubkey(_i2.Uint8List node, _i2.Uint8List x, _i2.Uint8List y, 290 | {required _i1.Credentials credentials, 291 | _i1.Transaction? transaction}) async { 292 | final function = self.abi.functions[20]; 293 | assert(checkSignature(function, '29cd62ea')); 294 | final params = [node, x, y]; 295 | return write(credentials, transaction, function, params); 296 | } 297 | 298 | /// The optional [transaction] parameter can be used to override parameters 299 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 300 | /// set by the contract. 301 | Future setText(_i2.Uint8List node, String key, String value, 302 | {required _i1.Credentials credentials, 303 | _i1.Transaction? transaction}) async { 304 | final function = self.abi.functions[21]; 305 | assert(checkSignature(function, '10f13a8c')); 306 | final params = [node, key, value]; 307 | return write(credentials, transaction, function, params); 308 | } 309 | 310 | /// The optional [atBlock] parameter can be used to view historical data. When 311 | /// set, the function will be evaluated in the specified block. By default, the 312 | /// latest on-chain block will be used. 313 | Future supportsInterface(_i2.Uint8List interfaceID, 314 | {_i1.BlockNum? atBlock}) async { 315 | final function = self.abi.functions[22]; 316 | assert(checkSignature(function, '01ffc9a7')); 317 | final params = [interfaceID]; 318 | final response = await read(function, params, atBlock); 319 | return (response[0] as bool); 320 | } 321 | 322 | /// The optional [atBlock] parameter can be used to view historical data. When 323 | /// set, the function will be evaluated in the specified block. By default, the 324 | /// latest on-chain block will be used. 325 | Future text(_i2.Uint8List node, String key, 326 | {_i1.BlockNum? atBlock}) async { 327 | final function = self.abi.functions[23]; 328 | assert(checkSignature(function, '59d1d43c')); 329 | final params = [node, key]; 330 | final response = await read(function, params, atBlock); 331 | return (response[0] as String); 332 | } 333 | 334 | /// Returns a live stream of all ABIChanged events emitted by this contract. 335 | Stream aBIChangedEvents( 336 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 337 | final event = self.event('ABIChanged'); 338 | final filter = _i1.FilterOptions.events( 339 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 340 | return client.events(filter).map((_i1.FilterEvent result) { 341 | final decoded = event.decodeResults(result.topics!, result.data!); 342 | return ABIChanged(decoded); 343 | }); 344 | } 345 | 346 | /// Returns a live stream of all AddrChanged events emitted by this contract. 347 | Stream addrChangedEvents( 348 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 349 | final event = self.event('AddrChanged'); 350 | final filter = _i1.FilterOptions.events( 351 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 352 | return client.events(filter).map((_i1.FilterEvent result) { 353 | final decoded = event.decodeResults(result.topics!, result.data!); 354 | return AddrChanged(decoded); 355 | }); 356 | } 357 | 358 | /// Returns a live stream of all AddressChanged events emitted by this contract. 359 | Stream addressChangedEvents( 360 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 361 | final event = self.event('AddressChanged'); 362 | final filter = _i1.FilterOptions.events( 363 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 364 | return client.events(filter).map((_i1.FilterEvent result) { 365 | final decoded = event.decodeResults(result.topics!, result.data!); 366 | return AddressChanged(decoded); 367 | }); 368 | } 369 | 370 | /// Returns a live stream of all AuthorisationChanged events emitted by this contract. 371 | Stream authorisationChangedEvents( 372 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 373 | final event = self.event('AuthorisationChanged'); 374 | final filter = _i1.FilterOptions.events( 375 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 376 | return client.events(filter).map((_i1.FilterEvent result) { 377 | final decoded = event.decodeResults(result.topics!, result.data!); 378 | return AuthorisationChanged(decoded); 379 | }); 380 | } 381 | 382 | /// Returns a live stream of all ContenthashChanged events emitted by this contract. 383 | Stream contenthashChangedEvents( 384 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 385 | final event = self.event('ContenthashChanged'); 386 | final filter = _i1.FilterOptions.events( 387 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 388 | return client.events(filter).map((_i1.FilterEvent result) { 389 | final decoded = event.decodeResults(result.topics!, result.data!); 390 | return ContenthashChanged(decoded); 391 | }); 392 | } 393 | 394 | /// Returns a live stream of all DNSRecordChanged events emitted by this contract. 395 | Stream dNSRecordChangedEvents( 396 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 397 | final event = self.event('DNSRecordChanged'); 398 | final filter = _i1.FilterOptions.events( 399 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 400 | return client.events(filter).map((_i1.FilterEvent result) { 401 | final decoded = event.decodeResults(result.topics!, result.data!); 402 | return DNSRecordChanged(decoded); 403 | }); 404 | } 405 | 406 | /// Returns a live stream of all DNSRecordDeleted events emitted by this contract. 407 | Stream dNSRecordDeletedEvents( 408 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 409 | final event = self.event('DNSRecordDeleted'); 410 | final filter = _i1.FilterOptions.events( 411 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 412 | return client.events(filter).map((_i1.FilterEvent result) { 413 | final decoded = event.decodeResults(result.topics!, result.data!); 414 | return DNSRecordDeleted(decoded); 415 | }); 416 | } 417 | 418 | /// Returns a live stream of all DNSZoneCleared events emitted by this contract. 419 | Stream dNSZoneClearedEvents( 420 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 421 | final event = self.event('DNSZoneCleared'); 422 | final filter = _i1.FilterOptions.events( 423 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 424 | return client.events(filter).map((_i1.FilterEvent result) { 425 | final decoded = event.decodeResults(result.topics!, result.data!); 426 | return DNSZoneCleared(decoded); 427 | }); 428 | } 429 | 430 | /// Returns a live stream of all InterfaceChanged events emitted by this contract. 431 | Stream interfaceChangedEvents( 432 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 433 | final event = self.event('InterfaceChanged'); 434 | final filter = _i1.FilterOptions.events( 435 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 436 | return client.events(filter).map((_i1.FilterEvent result) { 437 | final decoded = event.decodeResults(result.topics!, result.data!); 438 | return InterfaceChanged(decoded); 439 | }); 440 | } 441 | 442 | /// Returns a live stream of all NameChanged events emitted by this contract. 443 | Stream nameChangedEvents( 444 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 445 | final event = self.event('NameChanged'); 446 | final filter = _i1.FilterOptions.events( 447 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 448 | return client.events(filter).map((_i1.FilterEvent result) { 449 | final decoded = event.decodeResults(result.topics!, result.data!); 450 | return NameChanged(decoded); 451 | }); 452 | } 453 | 454 | /// Returns a live stream of all PubkeyChanged events emitted by this contract. 455 | Stream pubkeyChangedEvents( 456 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 457 | final event = self.event('PubkeyChanged'); 458 | final filter = _i1.FilterOptions.events( 459 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 460 | return client.events(filter).map((_i1.FilterEvent result) { 461 | final decoded = event.decodeResults(result.topics!, result.data!); 462 | return PubkeyChanged(decoded); 463 | }); 464 | } 465 | 466 | /// Returns a live stream of all TextChanged events emitted by this contract. 467 | Stream textChangedEvents( 468 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 469 | final event = self.event('TextChanged'); 470 | final filter = _i1.FilterOptions.events( 471 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 472 | return client.events(filter).map((_i1.FilterEvent result) { 473 | final decoded = event.decodeResults(result.topics!, result.data!); 474 | return TextChanged(decoded); 475 | }); 476 | } 477 | } 478 | 479 | class ABI { 480 | ABI(List response) 481 | : var1 = (response[0] as BigInt), 482 | var2 = (response[1] as _i2.Uint8List); 483 | 484 | final BigInt var1; 485 | 486 | final _i2.Uint8List var2; 487 | } 488 | 489 | class Pubkey { 490 | Pubkey(List response) 491 | : x = (response[0] as _i2.Uint8List), 492 | y = (response[1] as _i2.Uint8List); 493 | 494 | final _i2.Uint8List x; 495 | 496 | final _i2.Uint8List y; 497 | } 498 | 499 | class ABIChanged { 500 | ABIChanged(List response) 501 | : node = (response[0] as _i2.Uint8List), 502 | contentType = (response[1] as BigInt); 503 | 504 | final _i2.Uint8List node; 505 | 506 | final BigInt contentType; 507 | } 508 | 509 | class AddrChanged { 510 | AddrChanged(List response) 511 | : node = (response[0] as _i2.Uint8List), 512 | a = (response[1] as _i1.EthereumAddress); 513 | 514 | final _i2.Uint8List node; 515 | 516 | final _i1.EthereumAddress a; 517 | } 518 | 519 | class AddressChanged { 520 | AddressChanged(List response) 521 | : node = (response[0] as _i2.Uint8List), 522 | coinType = (response[1] as BigInt), 523 | newAddress = (response[2] as _i2.Uint8List); 524 | 525 | final _i2.Uint8List node; 526 | 527 | final BigInt coinType; 528 | 529 | final _i2.Uint8List newAddress; 530 | } 531 | 532 | class AuthorisationChanged { 533 | AuthorisationChanged(List response) 534 | : node = (response[0] as _i2.Uint8List), 535 | owner = (response[1] as _i1.EthereumAddress), 536 | target = (response[2] as _i1.EthereumAddress), 537 | isAuthorised = (response[3] as bool); 538 | 539 | final _i2.Uint8List node; 540 | 541 | final _i1.EthereumAddress owner; 542 | 543 | final _i1.EthereumAddress target; 544 | 545 | final bool isAuthorised; 546 | } 547 | 548 | class ContenthashChanged { 549 | ContenthashChanged(List response) 550 | : node = (response[0] as _i2.Uint8List), 551 | hash = (response[1] as _i2.Uint8List); 552 | 553 | final _i2.Uint8List node; 554 | 555 | final _i2.Uint8List hash; 556 | } 557 | 558 | class DNSRecordChanged { 559 | DNSRecordChanged(List response) 560 | : node = (response[0] as _i2.Uint8List), 561 | name = (response[1] as _i2.Uint8List), 562 | resource = (response[2] as BigInt), 563 | record = (response[3] as _i2.Uint8List); 564 | 565 | final _i2.Uint8List node; 566 | 567 | final _i2.Uint8List name; 568 | 569 | final BigInt resource; 570 | 571 | final _i2.Uint8List record; 572 | } 573 | 574 | class DNSRecordDeleted { 575 | DNSRecordDeleted(List response) 576 | : node = (response[0] as _i2.Uint8List), 577 | name = (response[1] as _i2.Uint8List), 578 | resource = (response[2] as BigInt); 579 | 580 | final _i2.Uint8List node; 581 | 582 | final _i2.Uint8List name; 583 | 584 | final BigInt resource; 585 | } 586 | 587 | class DNSZoneCleared { 588 | DNSZoneCleared(List response) 589 | : node = (response[0] as _i2.Uint8List); 590 | 591 | final _i2.Uint8List node; 592 | } 593 | 594 | class InterfaceChanged { 595 | InterfaceChanged(List response) 596 | : node = (response[0] as _i2.Uint8List), 597 | interfaceID = (response[1] as _i2.Uint8List), 598 | implementer = (response[2] as _i1.EthereumAddress); 599 | 600 | final _i2.Uint8List node; 601 | 602 | final _i2.Uint8List interfaceID; 603 | 604 | final _i1.EthereumAddress implementer; 605 | } 606 | 607 | class NameChanged { 608 | NameChanged(List response) 609 | : node = (response[0] as _i2.Uint8List), 610 | name = (response[1] as String); 611 | 612 | final _i2.Uint8List node; 613 | 614 | final String name; 615 | } 616 | 617 | class PubkeyChanged { 618 | PubkeyChanged(List response) 619 | : node = (response[0] as _i2.Uint8List), 620 | x = (response[1] as _i2.Uint8List), 621 | y = (response[2] as _i2.Uint8List); 622 | 623 | final _i2.Uint8List node; 624 | 625 | final _i2.Uint8List x; 626 | 627 | final _i2.Uint8List y; 628 | } 629 | 630 | class TextChanged { 631 | TextChanged(List response) 632 | : node = (response[0] as _i2.Uint8List), 633 | indexedKey = (response[1] as String), 634 | key = (response[2] as String); 635 | 636 | final _i2.Uint8List node; 637 | 638 | final String indexedKey; 639 | 640 | final String key; 641 | } 642 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_reverse_registrar.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:ens_dart/src/const/const.dart'; 4 | import 'package:web3dart/web3dart.dart' as _i1; 5 | import 'dart:typed_data' as _i2; 6 | 7 | final _contractAbi = _i1.ContractAbi.fromJson( 8 | '[{"inputs":[{"internalType":"contract ENS","name":"ensAddr","type":"address"},{"internalType":"contract Resolver","name":"resolverAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"ADDR_REVERSE_NODE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"claim","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"resolver","type":"address"}],"name":"claimWithResolver","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"defaultResolver","outputs":[{"internalType":"contract Resolver","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"node","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"string","name":"name","type":"string"}],"name":"setName","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"payable":false,"stateMutability":"nonpayable","type":"function"}]', 9 | 'EnsReverseRegistrar'); 10 | 11 | class EnsReverseRegistrar extends _i1.GeneratedContract { 12 | EnsReverseRegistrar( 13 | {_i1.EthereumAddress? address, 14 | required _i1.Web3Client client, 15 | int? chainId}) 16 | : super( 17 | _i1.DeployedContract( 18 | _contractAbi, address ?? ENS_REVERSE_REGISTRAR), 19 | client, 20 | chainId); 21 | 22 | /// The optional [atBlock] parameter can be used to view historical data. When 23 | /// set, the function will be evaluated in the specified block. By default, the 24 | /// latest on-chain block will be used. 25 | Future<_i2.Uint8List> aDDRkREVERSEkNODE({_i1.BlockNum? atBlock}) async { 26 | final function = self.abi.functions[1]; 27 | assert(checkSignature(function, '7cf8a2eb')); 28 | final params = []; 29 | final response = await read(function, params, atBlock); 30 | return (response[0] as _i2.Uint8List); 31 | } 32 | 33 | /// The optional [transaction] parameter can be used to override parameters 34 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 35 | /// set by the contract. 36 | Future claim(_i1.EthereumAddress owner, 37 | {required _i1.Credentials credentials, 38 | _i1.Transaction? transaction}) async { 39 | final function = self.abi.functions[2]; 40 | assert(checkSignature(function, '1e83409a')); 41 | final params = [owner]; 42 | return write(credentials, transaction, function, params); 43 | } 44 | 45 | /// The optional [transaction] parameter can be used to override parameters 46 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 47 | /// set by the contract. 48 | Future claimWithResolver( 49 | _i1.EthereumAddress owner, _i1.EthereumAddress resolver, 50 | {required _i1.Credentials credentials, 51 | _i1.Transaction? transaction}) async { 52 | final function = self.abi.functions[3]; 53 | assert(checkSignature(function, '0f5a5466')); 54 | final params = [owner, resolver]; 55 | return write(credentials, transaction, function, params); 56 | } 57 | 58 | /// The optional [atBlock] parameter can be used to view historical data. When 59 | /// set, the function will be evaluated in the specified block. By default, the 60 | /// latest on-chain block will be used. 61 | Future<_i1.EthereumAddress> defaultResolver({_i1.BlockNum? atBlock}) async { 62 | final function = self.abi.functions[4]; 63 | assert(checkSignature(function, '828eab0e')); 64 | final params = []; 65 | final response = await read(function, params, atBlock); 66 | return (response[0] as _i1.EthereumAddress); 67 | } 68 | 69 | /// The optional [atBlock] parameter can be used to view historical data. When 70 | /// set, the function will be evaluated in the specified block. By default, the 71 | /// latest on-chain block will be used. 72 | Future<_i1.EthereumAddress> ens({_i1.BlockNum? atBlock}) async { 73 | final function = self.abi.functions[5]; 74 | assert(checkSignature(function, '3f15457f')); 75 | final params = []; 76 | final response = await read(function, params, atBlock); 77 | return (response[0] as _i1.EthereumAddress); 78 | } 79 | 80 | /// The optional [atBlock] parameter can be used to view historical data. When 81 | /// set, the function will be evaluated in the specified block. By default, the 82 | /// latest on-chain block will be used. 83 | Future<_i2.Uint8List> node(_i1.EthereumAddress addr, 84 | {_i1.BlockNum? atBlock}) async { 85 | final function = self.abi.functions[6]; 86 | assert(checkSignature(function, 'bffbe61c')); 87 | final params = [addr]; 88 | final response = await read(function, params, atBlock); 89 | return (response[0] as _i2.Uint8List); 90 | } 91 | 92 | /// The optional [transaction] parameter can be used to override parameters 93 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 94 | /// set by the contract. 95 | Future setName(String name, 96 | {required _i1.Credentials credentials, 97 | _i1.Transaction? transaction}) async { 98 | final function = self.abi.functions[7]; 99 | assert(checkSignature(function, 'c47f0027')); 100 | final params = [name]; 101 | return write(credentials, transaction, function, params); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_reverse_resolver.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:ens_dart/src/const/const.dart'; 4 | import 'package:web3dart/web3dart.dart' as _i1; 5 | import 'dart:typed_data' as _i2; 6 | 7 | final _contractAbi = _i1.ContractAbi.fromJson( 8 | '[{"inputs":[{"internalType":"contract ENS","name":"ensAddr","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"node","type":"bytes32"},{"internalType":"string","name":"_name","type":"string"}],"name":"setName","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]', 9 | 'EnsReverseResolver'); 10 | 11 | class EnsReverseResolver extends _i1.GeneratedContract { 12 | EnsReverseResolver({ 13 | _i1.EthereumAddress? address, 14 | required _i1.Web3Client client, 15 | int? chainId, 16 | }) : super( 17 | _i1.DeployedContract( 18 | _contractAbi, 19 | address ?? ENS_REVERSE_RESOLVER, 20 | ), 21 | client, 22 | chainId, 23 | ); 24 | 25 | /// The optional [atBlock] parameter can be used to view historical data. When 26 | /// set, the function will be evaluated in the specified block. By default, the 27 | /// latest on-chain block will be used. 28 | Future<_i1.EthereumAddress> ens({_i1.BlockNum? atBlock}) async { 29 | final function = self.abi.functions[1]; 30 | assert(checkSignature(function, '3f15457f')); 31 | final params = []; 32 | final response = await read(function, params, atBlock); 33 | return (response[0] as _i1.EthereumAddress); 34 | } 35 | 36 | /// The optional [atBlock] parameter can be used to view historical data. When 37 | /// set, the function will be evaluated in the specified block. By default, the 38 | /// latest on-chain block will be used. 39 | Future name(_i2.Uint8List $param0, {_i1.BlockNum? atBlock}) async { 40 | final function = self.abi.functions[2]; 41 | assert(checkSignature(function, '691f3431')); 42 | final params = [$param0]; 43 | final response = await read(function, params, atBlock); 44 | return (response[0] as String); 45 | } 46 | 47 | /// The optional [transaction] parameter can be used to override parameters 48 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 49 | /// set by the contract. 50 | Future setName(_i2.Uint8List node, String _name, 51 | {required _i1.Credentials credentials, 52 | _i1.Transaction? transaction}) async { 53 | final function = self.abi.functions[3]; 54 | assert(checkSignature(function, '77372213')); 55 | final params = [node, _name]; 56 | return write(credentials, transaction, function, params); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_root.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:web3dart/web3dart.dart' as _i1; 4 | import 'dart:typed_data' as _i2; 5 | 6 | final _contractAbi = _i1.ContractAbi.fromJson( 7 | '[{"inputs":[{"internalType":"contract ENS","name":"_ens","type":"address"}],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"label","type":"bytes32"}],"name":"TLDLocked","type":"event"},{"constant":true,"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"controllers","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"ens","outputs":[{"internalType":"contract ENS","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"addr","type":"address"}],"name":"isOwner","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"label","type":"bytes32"}],"name":"lock","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"locked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"controller","type":"address"},{"internalType":"bool","name":"enabled","type":"bool"}],"name":"setController","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"bytes32","name":"label","type":"bytes32"},{"internalType":"address","name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"bytes4","name":"interfaceID","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"pure","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}]', 8 | 'ENSRoot'); 9 | 10 | class ENSRoot extends _i1.GeneratedContract { 11 | ENSRoot({required _i1.Web3Client client, int? chainId}) 12 | : super( 13 | _i1.DeployedContract( 14 | _contractAbi, 15 | _i1.EthereumAddress.fromHex( 16 | '0xaB528d626EC275E3faD363fF1393A41F581c5897', 17 | ), 18 | ), 19 | client, 20 | chainId); 21 | 22 | /// The optional [atBlock] parameter can be used to view historical data. When 23 | /// set, the function will be evaluated in the specified block. By default, the 24 | /// latest on-chain block will be used. 25 | Future controllers(_i1.EthereumAddress $param0, 26 | {_i1.BlockNum? atBlock}) async { 27 | final function = self.abi.functions[1]; 28 | assert(checkSignature(function, 'da8c229e')); 29 | final params = [$param0]; 30 | final response = await read(function, params, atBlock); 31 | return (response[0] as bool); 32 | } 33 | 34 | /// The optional [atBlock] parameter can be used to view historical data. When 35 | /// set, the function will be evaluated in the specified block. By default, the 36 | /// latest on-chain block will be used. 37 | Future<_i1.EthereumAddress> ens({_i1.BlockNum? atBlock}) async { 38 | final function = self.abi.functions[2]; 39 | assert(checkSignature(function, '3f15457f')); 40 | final params = []; 41 | final response = await read(function, params, atBlock); 42 | return (response[0] as _i1.EthereumAddress); 43 | } 44 | 45 | /// The optional [atBlock] parameter can be used to view historical data. When 46 | /// set, the function will be evaluated in the specified block. By default, the 47 | /// latest on-chain block will be used. 48 | Future isOwner(_i1.EthereumAddress addr, 49 | {_i1.BlockNum? atBlock}) async { 50 | final function = self.abi.functions[3]; 51 | assert(checkSignature(function, '2f54bf6e')); 52 | final params = [addr]; 53 | final response = await read(function, params, atBlock); 54 | return (response[0] as bool); 55 | } 56 | 57 | /// The optional [transaction] parameter can be used to override parameters 58 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 59 | /// set by the contract. 60 | Future lock(_i2.Uint8List label, 61 | {required _i1.Credentials credentials, 62 | _i1.Transaction? transaction}) async { 63 | final function = self.abi.functions[4]; 64 | assert(checkSignature(function, '01670ba9')); 65 | final params = [label]; 66 | return write(credentials, transaction, function, params); 67 | } 68 | 69 | /// The optional [atBlock] parameter can be used to view historical data. When 70 | /// set, the function will be evaluated in the specified block. By default, the 71 | /// latest on-chain block will be used. 72 | Future locked(_i2.Uint8List $param3, {_i1.BlockNum? atBlock}) async { 73 | final function = self.abi.functions[5]; 74 | assert(checkSignature(function, 'cbe9e764')); 75 | final params = [$param3]; 76 | final response = await read(function, params, atBlock); 77 | return (response[0] as bool); 78 | } 79 | 80 | /// The optional [atBlock] parameter can be used to view historical data. When 81 | /// set, the function will be evaluated in the specified block. By default, the 82 | /// latest on-chain block will be used. 83 | Future<_i1.EthereumAddress> owner({_i1.BlockNum? atBlock}) async { 84 | final function = self.abi.functions[6]; 85 | assert(checkSignature(function, '8da5cb5b')); 86 | final params = []; 87 | final response = await read(function, params, atBlock); 88 | return (response[0] as _i1.EthereumAddress); 89 | } 90 | 91 | /// The optional [transaction] parameter can be used to override parameters 92 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 93 | /// set by the contract. 94 | Future setController(_i1.EthereumAddress controller, bool enabled, 95 | {required _i1.Credentials credentials, 96 | _i1.Transaction? transaction}) async { 97 | final function = self.abi.functions[7]; 98 | assert(checkSignature(function, 'e0dba60f')); 99 | final params = [controller, enabled]; 100 | return write(credentials, transaction, function, params); 101 | } 102 | 103 | /// The optional [transaction] parameter can be used to override parameters 104 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 105 | /// set by the contract. 106 | Future setResolver(_i1.EthereumAddress resolver, 107 | {required _i1.Credentials credentials, 108 | _i1.Transaction? transaction}) async { 109 | final function = self.abi.functions[8]; 110 | assert(checkSignature(function, '4e543b26')); 111 | final params = [resolver]; 112 | return write(credentials, transaction, function, params); 113 | } 114 | 115 | /// The optional [transaction] parameter can be used to override parameters 116 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 117 | /// set by the contract. 118 | Future setSubnodeOwner(_i2.Uint8List label, _i1.EthereumAddress owner, 119 | {required _i1.Credentials credentials, 120 | _i1.Transaction? transaction}) async { 121 | final function = self.abi.functions[9]; 122 | assert(checkSignature(function, '8cb8ecec')); 123 | final params = [label, owner]; 124 | return write(credentials, transaction, function, params); 125 | } 126 | 127 | /// The optional [atBlock] parameter can be used to view historical data. When 128 | /// set, the function will be evaluated in the specified block. By default, the 129 | /// latest on-chain block will be used. 130 | Future supportsInterface(_i2.Uint8List interfaceID, 131 | {_i1.BlockNum? atBlock}) async { 132 | final function = self.abi.functions[10]; 133 | assert(checkSignature(function, '01ffc9a7')); 134 | final params = [interfaceID]; 135 | final response = await read(function, params, atBlock); 136 | return (response[0] as bool); 137 | } 138 | 139 | /// The optional [transaction] parameter can be used to override parameters 140 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 141 | /// set by the contract. 142 | Future transferOwnership(_i1.EthereumAddress newOwner, 143 | {required _i1.Credentials credentials, 144 | _i1.Transaction? transaction}) async { 145 | final function = self.abi.functions[11]; 146 | assert(checkSignature(function, 'f2fde38b')); 147 | final params = [newOwner]; 148 | return write(credentials, transaction, function, params); 149 | } 150 | 151 | /// Returns a live stream of all TLDLocked events emitted by this contract. 152 | Stream tLDLockedEvents( 153 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 154 | final event = self.event('TLDLocked'); 155 | final filter = _i1.FilterOptions.events( 156 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 157 | return client.events(filter).map((_i1.FilterEvent result) { 158 | final decoded = event.decodeResults(result.topics!, result.data!); 159 | return TLDLocked(decoded); 160 | }); 161 | } 162 | } 163 | 164 | class TLDLocked { 165 | TLDLocked(List response) : label = (response[0] as _i2.Uint8List); 166 | 167 | final _i2.Uint8List label; 168 | } 169 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_service.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:web3dart/web3dart.dart' as _i1; 4 | import 'dart:typed_data' as _i2; 5 | 6 | final _contractAbi = _i1.ContractAbi.fromJson( 7 | '[{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"resolver","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"owner","outputs":[{"name":"","type":"address"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"label","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setSubnodeOwner","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"ttl","type":"uint64"}],"name":"setTTL","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"node","type":"bytes32"}],"name":"ttl","outputs":[{"name":"","type":"uint64"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"resolver","type":"address"}],"name":"setResolver","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"node","type":"bytes32"},{"name":"owner","type":"address"}],"name":"setOwner","outputs":[],"payable":false,"type":"function"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":true,"name":"label","type":"bytes32"},{"indexed":false,"name":"owner","type":"address"}],"name":"NewOwner","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"resolver","type":"address"}],"name":"NewResolver","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"name":"node","type":"bytes32"},{"indexed":false,"name":"ttl","type":"uint64"}],"name":"NewTTL","type":"event"}]', 8 | 'EnsService'); 9 | 10 | class EnsService extends _i1.GeneratedContract { 11 | EnsService( 12 | {required _i1.EthereumAddress address, 13 | required _i1.Web3Client client, 14 | int? chainId}) 15 | : super(_i1.DeployedContract(_contractAbi, address), client, chainId); 16 | 17 | /// The optional [transaction] parameter can be used to override parameters 18 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 19 | /// set by the contract. 20 | Future resolver(_i2.Uint8List node, 21 | {required _i1.Credentials credentials, 22 | _i1.Transaction? transaction}) async { 23 | final function = self.abi.functions[0]; 24 | assert(checkSignature(function, '0178b8bf')); 25 | final params = [node]; 26 | return write(credentials, transaction, function, params); 27 | } 28 | 29 | /// The optional [transaction] parameter can be used to override parameters 30 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 31 | /// set by the contract. 32 | Future owner(_i2.Uint8List node, 33 | {required _i1.Credentials credentials, 34 | _i1.Transaction? transaction}) async { 35 | final function = self.abi.functions[1]; 36 | assert(checkSignature(function, '02571be3')); 37 | final params = [node]; 38 | return write(credentials, transaction, function, params); 39 | } 40 | 41 | /// The optional [transaction] parameter can be used to override parameters 42 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 43 | /// set by the contract. 44 | Future setSubnodeOwner( 45 | _i2.Uint8List node, _i2.Uint8List label, _i1.EthereumAddress owner, 46 | {required _i1.Credentials credentials, 47 | _i1.Transaction? transaction}) async { 48 | final function = self.abi.functions[2]; 49 | assert(checkSignature(function, '06ab5923')); 50 | final params = [node, label, owner]; 51 | return write(credentials, transaction, function, params); 52 | } 53 | 54 | /// The optional [transaction] parameter can be used to override parameters 55 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 56 | /// set by the contract. 57 | Future setTTL(_i2.Uint8List node, BigInt ttl, 58 | {required _i1.Credentials credentials, 59 | _i1.Transaction? transaction}) async { 60 | final function = self.abi.functions[3]; 61 | assert(checkSignature(function, '14ab9038')); 62 | final params = [node, ttl]; 63 | return write(credentials, transaction, function, params); 64 | } 65 | 66 | /// The optional [transaction] parameter can be used to override parameters 67 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 68 | /// set by the contract. 69 | Future ttl(_i2.Uint8List node, 70 | {required _i1.Credentials credentials, 71 | _i1.Transaction? transaction}) async { 72 | final function = self.abi.functions[4]; 73 | assert(checkSignature(function, '16a25cbd')); 74 | final params = [node]; 75 | return write(credentials, transaction, function, params); 76 | } 77 | 78 | /// The optional [transaction] parameter can be used to override parameters 79 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 80 | /// set by the contract. 81 | Future setResolver(_i2.Uint8List node, _i1.EthereumAddress resolver, 82 | {required _i1.Credentials credentials, 83 | _i1.Transaction? transaction}) async { 84 | final function = self.abi.functions[5]; 85 | assert(checkSignature(function, '1896f70a')); 86 | final params = [node, resolver]; 87 | return write(credentials, transaction, function, params); 88 | } 89 | 90 | /// The optional [transaction] parameter can be used to override parameters 91 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 92 | /// set by the contract. 93 | Future setOwner(_i2.Uint8List node, _i1.EthereumAddress owner, 94 | {required _i1.Credentials credentials, 95 | _i1.Transaction? transaction}) async { 96 | final function = self.abi.functions[6]; 97 | assert(checkSignature(function, '5b0fc9c3')); 98 | final params = [node, owner]; 99 | return write(credentials, transaction, function, params); 100 | } 101 | 102 | /// Returns a live stream of all Transfer events emitted by this contract. 103 | Stream transferEvents( 104 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 105 | final event = self.event('Transfer'); 106 | final filter = _i1.FilterOptions.events( 107 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 108 | return client.events(filter).map((_i1.FilterEvent result) { 109 | final decoded = event.decodeResults(result.topics!, result.data!); 110 | return Transfer(decoded); 111 | }); 112 | } 113 | 114 | /// Returns a live stream of all NewOwner events emitted by this contract. 115 | Stream newOwnerEvents( 116 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 117 | final event = self.event('NewOwner'); 118 | final filter = _i1.FilterOptions.events( 119 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 120 | return client.events(filter).map((_i1.FilterEvent result) { 121 | final decoded = event.decodeResults(result.topics!, result.data!); 122 | return NewOwner(decoded); 123 | }); 124 | } 125 | 126 | /// Returns a live stream of all NewResolver events emitted by this contract. 127 | Stream newResolverEvents( 128 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 129 | final event = self.event('NewResolver'); 130 | final filter = _i1.FilterOptions.events( 131 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 132 | return client.events(filter).map((_i1.FilterEvent result) { 133 | final decoded = event.decodeResults(result.topics!, result.data!); 134 | return NewResolver(decoded); 135 | }); 136 | } 137 | 138 | /// Returns a live stream of all NewTTL events emitted by this contract. 139 | Stream newTTLEvents( 140 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 141 | final event = self.event('NewTTL'); 142 | final filter = _i1.FilterOptions.events( 143 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 144 | return client.events(filter).map((_i1.FilterEvent result) { 145 | final decoded = event.decodeResults(result.topics!, result.data!); 146 | return NewTTL(decoded); 147 | }); 148 | } 149 | } 150 | 151 | class Transfer { 152 | Transfer(List response) 153 | : node = (response[0] as _i2.Uint8List), 154 | owner = (response[1] as _i1.EthereumAddress); 155 | 156 | final _i2.Uint8List node; 157 | 158 | final _i1.EthereumAddress owner; 159 | } 160 | 161 | class NewOwner { 162 | NewOwner(List response) 163 | : node = (response[0] as _i2.Uint8List), 164 | label = (response[1] as _i2.Uint8List), 165 | owner = (response[2] as _i1.EthereumAddress); 166 | 167 | final _i2.Uint8List node; 168 | 169 | final _i2.Uint8List label; 170 | 171 | final _i1.EthereumAddress owner; 172 | } 173 | 174 | class NewResolver { 175 | NewResolver(List response) 176 | : node = (response[0] as _i2.Uint8List), 177 | resolver = (response[1] as _i1.EthereumAddress); 178 | 179 | final _i2.Uint8List node; 180 | 181 | final _i1.EthereumAddress resolver; 182 | } 183 | 184 | class NewTTL { 185 | NewTTL(List response) 186 | : node = (response[0] as _i2.Uint8List), 187 | ttl = (response[1] as BigInt); 188 | 189 | final _i2.Uint8List node; 190 | 191 | final BigInt ttl; 192 | } 193 | -------------------------------------------------------------------------------- /lib/src/contracts/ens_token.g.dart: -------------------------------------------------------------------------------- 1 | // Generated code, do not modify. Run `build_runner build` to re-generate! 2 | // @dart=2.12 3 | import 'package:web3dart/web3dart.dart' as _i1; 4 | import 'dart:typed_data' as _i2; 5 | 6 | final _contractAbi = _i1.ContractAbi.fromJson( 7 | '[{"inputs":[{"internalType":"uint256","name":"freeSupply","type":"uint256"},{"internalType":"uint256","name":"airdropSupply","type":"uint256"},{"internalType":"uint256","name":"_claimPeriodEnds","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"claimant","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Claim","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegator","type":"address"},{"indexed":true,"internalType":"address","name":"fromDelegate","type":"address"},{"indexed":true,"internalType":"address","name":"toDelegate","type":"address"}],"name":"DelegateChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"delegate","type":"address"},{"indexed":false,"internalType":"uint256","name":"previousBalance","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newBalance","type":"uint256"}],"name":"DelegateVotesChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes32","name":"merkleRoot","type":"bytes32"}],"name":"MerkleRootChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint32","name":"pos","type":"uint32"}],"name":"checkpoints","outputs":[{"components":[{"internalType":"uint32","name":"fromBlock","type":"uint32"},{"internalType":"uint224","name":"votes","type":"uint224"}],"internalType":"struct ERC20Votes.Checkpoint","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"claimPeriodEnds","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"delegate","type":"address"},{"internalType":"bytes32[]","name":"merkleProof","type":"bytes32[]"}],"name":"claimTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"}],"name":"delegate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"delegatee","type":"address"},{"internalType":"uint256","name":"nonce","type":"uint256"},{"internalType":"uint256","name":"expiry","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"delegateBySig","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"delegates","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPastTotalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"uint256","name":"blockNumber","type":"uint256"}],"name":"getPastVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"getVotes","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"isClaimed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"merkleRoot","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minimumMintInterval","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"dest","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintCap","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"nextMint","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numCheckpoints","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"_merkleRoot","type":"bytes32"}],"name":"setMerkleRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"dest","type":"address"}],"name":"sweep","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]', 8 | 'EnsToken'); 9 | 10 | class EnsToken extends _i1.GeneratedContract { 11 | EnsToken( 12 | {required _i1.EthereumAddress address, 13 | required _i1.Web3Client client, 14 | int? chainId}) 15 | : super(_i1.DeployedContract(_contractAbi, address), client, chainId); 16 | 17 | /// The optional [atBlock] parameter can be used to view historical data. When 18 | /// set, the function will be evaluated in the specified block. By default, the 19 | /// latest on-chain block will be used. 20 | Future<_i2.Uint8List> dOMAINkSEPARATOR({_i1.BlockNum? atBlock}) async { 21 | final function = self.abi.functions[1]; 22 | assert(checkSignature(function, '3644e515')); 23 | final params = []; 24 | final response = await read(function, params, atBlock); 25 | return (response[0] as _i2.Uint8List); 26 | } 27 | 28 | /// The optional [atBlock] parameter can be used to view historical data. When 29 | /// set, the function will be evaluated in the specified block. By default, the 30 | /// latest on-chain block will be used. 31 | Future allowance( 32 | _i1.EthereumAddress owner, _i1.EthereumAddress spender, 33 | {_i1.BlockNum? atBlock}) async { 34 | final function = self.abi.functions[2]; 35 | assert(checkSignature(function, 'dd62ed3e')); 36 | final params = [owner, spender]; 37 | final response = await read(function, params, atBlock); 38 | return (response[0] as BigInt); 39 | } 40 | 41 | /// The optional [transaction] parameter can be used to override parameters 42 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 43 | /// set by the contract. 44 | Future approve(_i1.EthereumAddress spender, BigInt amount, 45 | {required _i1.Credentials credentials, 46 | _i1.Transaction? transaction}) async { 47 | final function = self.abi.functions[3]; 48 | assert(checkSignature(function, '095ea7b3')); 49 | final params = [spender, amount]; 50 | return write(credentials, transaction, function, params); 51 | } 52 | 53 | /// The optional [atBlock] parameter can be used to view historical data. When 54 | /// set, the function will be evaluated in the specified block. By default, the 55 | /// latest on-chain block will be used. 56 | Future balanceOf(_i1.EthereumAddress account, 57 | {_i1.BlockNum? atBlock}) async { 58 | final function = self.abi.functions[4]; 59 | assert(checkSignature(function, '70a08231')); 60 | final params = [account]; 61 | final response = await read(function, params, atBlock); 62 | return (response[0] as BigInt); 63 | } 64 | 65 | /// The optional [atBlock] parameter can be used to view historical data. When 66 | /// set, the function will be evaluated in the specified block. By default, the 67 | /// latest on-chain block will be used. 68 | Future checkpoints(_i1.EthereumAddress account, BigInt pos, 69 | {_i1.BlockNum? atBlock}) async { 70 | final function = self.abi.functions[5]; 71 | assert(checkSignature(function, 'f1127ed8')); 72 | final params = [account, pos]; 73 | final response = await read(function, params, atBlock); 74 | return (response[0] as dynamic); 75 | } 76 | 77 | /// The optional [atBlock] parameter can be used to view historical data. When 78 | /// set, the function will be evaluated in the specified block. By default, the 79 | /// latest on-chain block will be used. 80 | Future claimPeriodEnds({_i1.BlockNum? atBlock}) async { 81 | final function = self.abi.functions[6]; 82 | assert(checkSignature(function, '66deac47')); 83 | final params = []; 84 | final response = await read(function, params, atBlock); 85 | return (response[0] as BigInt); 86 | } 87 | 88 | /// The optional [transaction] parameter can be used to override parameters 89 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 90 | /// set by the contract. 91 | Future claimTokens(BigInt amount, _i1.EthereumAddress delegate, 92 | List<_i2.Uint8List> merkleProof, 93 | {required _i1.Credentials credentials, 94 | _i1.Transaction? transaction}) async { 95 | final function = self.abi.functions[7]; 96 | assert(checkSignature(function, '76122903')); 97 | final params = [amount, delegate, merkleProof]; 98 | return write(credentials, transaction, function, params); 99 | } 100 | 101 | /// The optional [atBlock] parameter can be used to view historical data. When 102 | /// set, the function will be evaluated in the specified block. By default, the 103 | /// latest on-chain block will be used. 104 | Future decimals({_i1.BlockNum? atBlock}) async { 105 | final function = self.abi.functions[8]; 106 | assert(checkSignature(function, '313ce567')); 107 | final params = []; 108 | final response = await read(function, params, atBlock); 109 | return (response[0] as BigInt); 110 | } 111 | 112 | /// The optional [transaction] parameter can be used to override parameters 113 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 114 | /// set by the contract. 115 | Future decreaseAllowance( 116 | _i1.EthereumAddress spender, BigInt subtractedValue, 117 | {required _i1.Credentials credentials, 118 | _i1.Transaction? transaction}) async { 119 | final function = self.abi.functions[9]; 120 | assert(checkSignature(function, 'a457c2d7')); 121 | final params = [spender, subtractedValue]; 122 | return write(credentials, transaction, function, params); 123 | } 124 | 125 | /// The optional [transaction] parameter can be used to override parameters 126 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 127 | /// set by the contract. 128 | Future delegate(_i1.EthereumAddress delegatee, 129 | {required _i1.Credentials credentials, 130 | _i1.Transaction? transaction}) async { 131 | final function = self.abi.functions[10]; 132 | assert(checkSignature(function, '5c19a95c')); 133 | final params = [delegatee]; 134 | return write(credentials, transaction, function, params); 135 | } 136 | 137 | /// The optional [transaction] parameter can be used to override parameters 138 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 139 | /// set by the contract. 140 | Future delegateBySig(_i1.EthereumAddress delegatee, BigInt nonce, 141 | BigInt expiry, BigInt v, _i2.Uint8List r, _i2.Uint8List s, 142 | {required _i1.Credentials credentials, 143 | _i1.Transaction? transaction}) async { 144 | final function = self.abi.functions[11]; 145 | assert(checkSignature(function, 'c3cda520')); 146 | final params = [delegatee, nonce, expiry, v, r, s]; 147 | return write(credentials, transaction, function, params); 148 | } 149 | 150 | /// The optional [atBlock] parameter can be used to view historical data. When 151 | /// set, the function will be evaluated in the specified block. By default, the 152 | /// latest on-chain block will be used. 153 | Future<_i1.EthereumAddress> delegates(_i1.EthereumAddress account, 154 | {_i1.BlockNum? atBlock}) async { 155 | final function = self.abi.functions[12]; 156 | assert(checkSignature(function, '587cde1e')); 157 | final params = [account]; 158 | final response = await read(function, params, atBlock); 159 | return (response[0] as _i1.EthereumAddress); 160 | } 161 | 162 | /// The optional [atBlock] parameter can be used to view historical data. When 163 | /// set, the function will be evaluated in the specified block. By default, the 164 | /// latest on-chain block will be used. 165 | Future getPastTotalSupply(BigInt blockNumber, 166 | {_i1.BlockNum? atBlock}) async { 167 | final function = self.abi.functions[13]; 168 | assert(checkSignature(function, '8e539e8c')); 169 | final params = [blockNumber]; 170 | final response = await read(function, params, atBlock); 171 | return (response[0] as BigInt); 172 | } 173 | 174 | /// The optional [atBlock] parameter can be used to view historical data. When 175 | /// set, the function will be evaluated in the specified block. By default, the 176 | /// latest on-chain block will be used. 177 | Future getPastVotes(_i1.EthereumAddress account, BigInt blockNumber, 178 | {_i1.BlockNum? atBlock}) async { 179 | final function = self.abi.functions[14]; 180 | assert(checkSignature(function, '3a46b1a8')); 181 | final params = [account, blockNumber]; 182 | final response = await read(function, params, atBlock); 183 | return (response[0] as BigInt); 184 | } 185 | 186 | /// The optional [atBlock] parameter can be used to view historical data. When 187 | /// set, the function will be evaluated in the specified block. By default, the 188 | /// latest on-chain block will be used. 189 | Future getVotes(_i1.EthereumAddress account, 190 | {_i1.BlockNum? atBlock}) async { 191 | final function = self.abi.functions[15]; 192 | assert(checkSignature(function, '9ab24eb0')); 193 | final params = [account]; 194 | final response = await read(function, params, atBlock); 195 | return (response[0] as BigInt); 196 | } 197 | 198 | /// The optional [transaction] parameter can be used to override parameters 199 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 200 | /// set by the contract. 201 | Future increaseAllowance( 202 | _i1.EthereumAddress spender, BigInt addedValue, 203 | {required _i1.Credentials credentials, 204 | _i1.Transaction? transaction}) async { 205 | final function = self.abi.functions[16]; 206 | assert(checkSignature(function, '39509351')); 207 | final params = [spender, addedValue]; 208 | return write(credentials, transaction, function, params); 209 | } 210 | 211 | /// The optional [atBlock] parameter can be used to view historical data. When 212 | /// set, the function will be evaluated in the specified block. By default, the 213 | /// latest on-chain block will be used. 214 | Future isClaimed(BigInt index, {_i1.BlockNum? atBlock}) async { 215 | final function = self.abi.functions[17]; 216 | assert(checkSignature(function, '9e34070f')); 217 | final params = [index]; 218 | final response = await read(function, params, atBlock); 219 | return (response[0] as bool); 220 | } 221 | 222 | /// The optional [atBlock] parameter can be used to view historical data. When 223 | /// set, the function will be evaluated in the specified block. By default, the 224 | /// latest on-chain block will be used. 225 | Future<_i2.Uint8List> merkleRoot({_i1.BlockNum? atBlock}) async { 226 | final function = self.abi.functions[18]; 227 | assert(checkSignature(function, '2eb4a7ab')); 228 | final params = []; 229 | final response = await read(function, params, atBlock); 230 | return (response[0] as _i2.Uint8List); 231 | } 232 | 233 | /// The optional [atBlock] parameter can be used to view historical data. When 234 | /// set, the function will be evaluated in the specified block. By default, the 235 | /// latest on-chain block will be used. 236 | Future minimumMintInterval({_i1.BlockNum? atBlock}) async { 237 | final function = self.abi.functions[19]; 238 | assert(checkSignature(function, '515b612a')); 239 | final params = []; 240 | final response = await read(function, params, atBlock); 241 | return (response[0] as BigInt); 242 | } 243 | 244 | /// The optional [transaction] parameter can be used to override parameters 245 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 246 | /// set by the contract. 247 | Future mint(_i1.EthereumAddress dest, BigInt amount, 248 | {required _i1.Credentials credentials, 249 | _i1.Transaction? transaction}) async { 250 | final function = self.abi.functions[20]; 251 | assert(checkSignature(function, '40c10f19')); 252 | final params = [dest, amount]; 253 | return write(credentials, transaction, function, params); 254 | } 255 | 256 | /// The optional [atBlock] parameter can be used to view historical data. When 257 | /// set, the function will be evaluated in the specified block. By default, the 258 | /// latest on-chain block will be used. 259 | Future mintCap({_i1.BlockNum? atBlock}) async { 260 | final function = self.abi.functions[21]; 261 | assert(checkSignature(function, '76c71ca1')); 262 | final params = []; 263 | final response = await read(function, params, atBlock); 264 | return (response[0] as BigInt); 265 | } 266 | 267 | /// The optional [atBlock] parameter can be used to view historical data. When 268 | /// set, the function will be evaluated in the specified block. By default, the 269 | /// latest on-chain block will be used. 270 | Future name({_i1.BlockNum? atBlock}) async { 271 | final function = self.abi.functions[22]; 272 | assert(checkSignature(function, '06fdde03')); 273 | final params = []; 274 | final response = await read(function, params, atBlock); 275 | return (response[0] as String); 276 | } 277 | 278 | /// The optional [atBlock] parameter can be used to view historical data. When 279 | /// set, the function will be evaluated in the specified block. By default, the 280 | /// latest on-chain block will be used. 281 | Future nextMint({_i1.BlockNum? atBlock}) async { 282 | final function = self.abi.functions[23]; 283 | assert(checkSignature(function, 'cf665443')); 284 | final params = []; 285 | final response = await read(function, params, atBlock); 286 | return (response[0] as BigInt); 287 | } 288 | 289 | /// The optional [atBlock] parameter can be used to view historical data. When 290 | /// set, the function will be evaluated in the specified block. By default, the 291 | /// latest on-chain block will be used. 292 | Future nonces(_i1.EthereumAddress owner, 293 | {_i1.BlockNum? atBlock}) async { 294 | final function = self.abi.functions[24]; 295 | assert(checkSignature(function, '7ecebe00')); 296 | final params = [owner]; 297 | final response = await read(function, params, atBlock); 298 | return (response[0] as BigInt); 299 | } 300 | 301 | /// The optional [atBlock] parameter can be used to view historical data. When 302 | /// set, the function will be evaluated in the specified block. By default, the 303 | /// latest on-chain block will be used. 304 | Future numCheckpoints(_i1.EthereumAddress account, 305 | {_i1.BlockNum? atBlock}) async { 306 | final function = self.abi.functions[25]; 307 | assert(checkSignature(function, '6fcfff45')); 308 | final params = [account]; 309 | final response = await read(function, params, atBlock); 310 | return (response[0] as BigInt); 311 | } 312 | 313 | /// The optional [atBlock] parameter can be used to view historical data. When 314 | /// set, the function will be evaluated in the specified block. By default, the 315 | /// latest on-chain block will be used. 316 | Future<_i1.EthereumAddress> owner({_i1.BlockNum? atBlock}) async { 317 | final function = self.abi.functions[26]; 318 | assert(checkSignature(function, '8da5cb5b')); 319 | final params = []; 320 | final response = await read(function, params, atBlock); 321 | return (response[0] as _i1.EthereumAddress); 322 | } 323 | 324 | /// The optional [transaction] parameter can be used to override parameters 325 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 326 | /// set by the contract. 327 | Future permit(_i1.EthereumAddress owner, _i1.EthereumAddress spender, 328 | BigInt value, BigInt deadline, BigInt v, _i2.Uint8List r, _i2.Uint8List s, 329 | {required _i1.Credentials credentials, 330 | _i1.Transaction? transaction}) async { 331 | final function = self.abi.functions[27]; 332 | assert(checkSignature(function, 'd505accf')); 333 | final params = [owner, spender, value, deadline, v, r, s]; 334 | return write(credentials, transaction, function, params); 335 | } 336 | 337 | /// The optional [transaction] parameter can be used to override parameters 338 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 339 | /// set by the contract. 340 | Future renounceOwnership( 341 | {required _i1.Credentials credentials, 342 | _i1.Transaction? transaction}) async { 343 | final function = self.abi.functions[28]; 344 | assert(checkSignature(function, '715018a6')); 345 | final params = []; 346 | return write(credentials, transaction, function, params); 347 | } 348 | 349 | /// The optional [transaction] parameter can be used to override parameters 350 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 351 | /// set by the contract. 352 | Future setMerkleRoot(_i2.Uint8List _merkleRoot, 353 | {required _i1.Credentials credentials, 354 | _i1.Transaction? transaction}) async { 355 | final function = self.abi.functions[29]; 356 | assert(checkSignature(function, '7cb64759')); 357 | final params = [_merkleRoot]; 358 | return write(credentials, transaction, function, params); 359 | } 360 | 361 | /// The optional [transaction] parameter can be used to override parameters 362 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 363 | /// set by the contract. 364 | Future sweep(_i1.EthereumAddress dest, 365 | {required _i1.Credentials credentials, 366 | _i1.Transaction? transaction}) async { 367 | final function = self.abi.functions[30]; 368 | assert(checkSignature(function, '01681a62')); 369 | final params = [dest]; 370 | return write(credentials, transaction, function, params); 371 | } 372 | 373 | /// The optional [atBlock] parameter can be used to view historical data. When 374 | /// set, the function will be evaluated in the specified block. By default, the 375 | /// latest on-chain block will be used. 376 | Future symbol({_i1.BlockNum? atBlock}) async { 377 | final function = self.abi.functions[31]; 378 | assert(checkSignature(function, '95d89b41')); 379 | final params = []; 380 | final response = await read(function, params, atBlock); 381 | return (response[0] as String); 382 | } 383 | 384 | /// The optional [atBlock] parameter can be used to view historical data. When 385 | /// set, the function will be evaluated in the specified block. By default, the 386 | /// latest on-chain block will be used. 387 | Future totalSupply({_i1.BlockNum? atBlock}) async { 388 | final function = self.abi.functions[32]; 389 | assert(checkSignature(function, '18160ddd')); 390 | final params = []; 391 | final response = await read(function, params, atBlock); 392 | return (response[0] as BigInt); 393 | } 394 | 395 | /// The optional [transaction] parameter can be used to override parameters 396 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 397 | /// set by the contract. 398 | Future transfer(_i1.EthereumAddress recipient, BigInt amount, 399 | {required _i1.Credentials credentials, 400 | _i1.Transaction? transaction}) async { 401 | final function = self.abi.functions[33]; 402 | assert(checkSignature(function, 'a9059cbb')); 403 | final params = [recipient, amount]; 404 | return write(credentials, transaction, function, params); 405 | } 406 | 407 | /// The optional [transaction] parameter can be used to override parameters 408 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 409 | /// set by the contract. 410 | Future transferFrom( 411 | _i1.EthereumAddress sender, _i1.EthereumAddress recipient, BigInt amount, 412 | {required _i1.Credentials credentials, 413 | _i1.Transaction? transaction}) async { 414 | final function = self.abi.functions[34]; 415 | assert(checkSignature(function, '23b872dd')); 416 | final params = [sender, recipient, amount]; 417 | return write(credentials, transaction, function, params); 418 | } 419 | 420 | /// The optional [transaction] parameter can be used to override parameters 421 | /// like the gas price, nonce and max gas. The `data` and `to` fields will be 422 | /// set by the contract. 423 | Future transferOwnership(_i1.EthereumAddress newOwner, 424 | {required _i1.Credentials credentials, 425 | _i1.Transaction? transaction}) async { 426 | final function = self.abi.functions[35]; 427 | assert(checkSignature(function, 'f2fde38b')); 428 | final params = [newOwner]; 429 | return write(credentials, transaction, function, params); 430 | } 431 | 432 | /// Returns a live stream of all Approval events emitted by this contract. 433 | Stream approvalEvents( 434 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 435 | final event = self.event('Approval'); 436 | final filter = _i1.FilterOptions.events( 437 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 438 | return client.events(filter).map((_i1.FilterEvent result) { 439 | final decoded = event.decodeResults(result.topics!, result.data!); 440 | return Approval(decoded); 441 | }); 442 | } 443 | 444 | /// Returns a live stream of all Claim events emitted by this contract. 445 | Stream claimEvents({_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 446 | final event = self.event('Claim'); 447 | final filter = _i1.FilterOptions.events( 448 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 449 | return client.events(filter).map((_i1.FilterEvent result) { 450 | final decoded = event.decodeResults(result.topics!, result.data!); 451 | return Claim(decoded); 452 | }); 453 | } 454 | 455 | /// Returns a live stream of all DelegateChanged events emitted by this contract. 456 | Stream delegateChangedEvents( 457 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 458 | final event = self.event('DelegateChanged'); 459 | final filter = _i1.FilterOptions.events( 460 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 461 | return client.events(filter).map((_i1.FilterEvent result) { 462 | final decoded = event.decodeResults(result.topics!, result.data!); 463 | return DelegateChanged(decoded); 464 | }); 465 | } 466 | 467 | /// Returns a live stream of all DelegateVotesChanged events emitted by this contract. 468 | Stream delegateVotesChangedEvents( 469 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 470 | final event = self.event('DelegateVotesChanged'); 471 | final filter = _i1.FilterOptions.events( 472 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 473 | return client.events(filter).map((_i1.FilterEvent result) { 474 | final decoded = event.decodeResults(result.topics!, result.data!); 475 | return DelegateVotesChanged(decoded); 476 | }); 477 | } 478 | 479 | /// Returns a live stream of all MerkleRootChanged events emitted by this contract. 480 | Stream merkleRootChangedEvents( 481 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 482 | final event = self.event('MerkleRootChanged'); 483 | final filter = _i1.FilterOptions.events( 484 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 485 | return client.events(filter).map((_i1.FilterEvent result) { 486 | final decoded = event.decodeResults(result.topics!, result.data!); 487 | return MerkleRootChanged(decoded); 488 | }); 489 | } 490 | 491 | /// Returns a live stream of all OwnershipTransferred events emitted by this contract. 492 | Stream ownershipTransferredEvents( 493 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 494 | final event = self.event('OwnershipTransferred'); 495 | final filter = _i1.FilterOptions.events( 496 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 497 | return client.events(filter).map((_i1.FilterEvent result) { 498 | final decoded = event.decodeResults(result.topics!, result.data!); 499 | return OwnershipTransferred(decoded); 500 | }); 501 | } 502 | 503 | /// Returns a live stream of all Transfer events emitted by this contract. 504 | Stream transferEvents( 505 | {_i1.BlockNum? fromBlock, _i1.BlockNum? toBlock}) { 506 | final event = self.event('Transfer'); 507 | final filter = _i1.FilterOptions.events( 508 | contract: self, event: event, fromBlock: fromBlock, toBlock: toBlock); 509 | return client.events(filter).map((_i1.FilterEvent result) { 510 | final decoded = event.decodeResults(result.topics!, result.data!); 511 | return Transfer(decoded); 512 | }); 513 | } 514 | } 515 | 516 | class Approval { 517 | Approval(List response) 518 | : owner = (response[0] as _i1.EthereumAddress), 519 | spender = (response[1] as _i1.EthereumAddress), 520 | value = (response[2] as BigInt); 521 | 522 | final _i1.EthereumAddress owner; 523 | 524 | final _i1.EthereumAddress spender; 525 | 526 | final BigInt value; 527 | } 528 | 529 | class Claim { 530 | Claim(List response) 531 | : claimant = (response[0] as _i1.EthereumAddress), 532 | amount = (response[1] as BigInt); 533 | 534 | final _i1.EthereumAddress claimant; 535 | 536 | final BigInt amount; 537 | } 538 | 539 | class DelegateChanged { 540 | DelegateChanged(List response) 541 | : delegator = (response[0] as _i1.EthereumAddress), 542 | fromDelegate = (response[1] as _i1.EthereumAddress), 543 | toDelegate = (response[2] as _i1.EthereumAddress); 544 | 545 | final _i1.EthereumAddress delegator; 546 | 547 | final _i1.EthereumAddress fromDelegate; 548 | 549 | final _i1.EthereumAddress toDelegate; 550 | } 551 | 552 | class DelegateVotesChanged { 553 | DelegateVotesChanged(List response) 554 | : delegate = (response[0] as _i1.EthereumAddress), 555 | previousBalance = (response[1] as BigInt), 556 | newBalance = (response[2] as BigInt); 557 | 558 | final _i1.EthereumAddress delegate; 559 | 560 | final BigInt previousBalance; 561 | 562 | final BigInt newBalance; 563 | } 564 | 565 | class MerkleRootChanged { 566 | MerkleRootChanged(List response) 567 | : merkleRoot = (response[0] as _i2.Uint8List); 568 | 569 | final _i2.Uint8List merkleRoot; 570 | } 571 | 572 | class OwnershipTransferred { 573 | OwnershipTransferred(List response) 574 | : previousOwner = (response[0] as _i1.EthereumAddress), 575 | newOwner = (response[1] as _i1.EthereumAddress); 576 | 577 | final _i1.EthereumAddress previousOwner; 578 | 579 | final _i1.EthereumAddress newOwner; 580 | } 581 | 582 | class Transfer { 583 | Transfer(List response) 584 | : from = (response[0] as _i1.EthereumAddress), 585 | to = (response[1] as _i1.EthereumAddress), 586 | value = (response[2] as BigInt); 587 | 588 | final _i1.EthereumAddress from; 589 | 590 | final _i1.EthereumAddress to; 591 | 592 | final BigInt value; 593 | } 594 | -------------------------------------------------------------------------------- /lib/src/ens_dart.dart: -------------------------------------------------------------------------------- 1 | export 'contracts/contracts.dart'; 2 | export 'utils.dart'; 3 | export 'ens_resolver.dart'; 4 | export 'models/models.dart'; 5 | export 'const/const.dart'; 6 | -------------------------------------------------------------------------------- /lib/src/ens_resolver.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: constant_identifier_names 2 | 3 | import 'dart:typed_data'; 4 | import 'package:convert/convert.dart'; 5 | 6 | import 'package:web3dart/crypto.dart'; 7 | import 'package:web3dart/web3dart.dart'; 8 | 9 | import 'ens_dart.dart'; 10 | 11 | enum EnsTextKey { 12 | email, 13 | url, 14 | avatar, 15 | description, 16 | notice, 17 | keywords, 18 | com_discord, 19 | com_github, 20 | com_reddit, 21 | com_twitter, 22 | org_telegram, 23 | eth_ens_delegate 24 | } 25 | 26 | extension EnsResolve on Ens { 27 | /// Name hash for ENS name 28 | Uint8List get nodeHash => hexToBytes(ENSUtils.nameHash(ensName ?? '')); 29 | 30 | /// Reverse node hash for ENS name 31 | Uint8List get reverseNodeHash => hexToBytes( 32 | ENSUtils.reverseNameHash('${ensAddress!.hexNo0x}.addr.reverse')); 33 | 34 | /// Returns the owner/controller for the current ENS name. 35 | Future getAddress() async { 36 | if (ensName == null) { 37 | throw 'ensName needs to be set first with .withName()'; 38 | } 39 | 40 | final _resolvedAddress = await addr(nodeHash); 41 | withAddress(_resolvedAddress); 42 | return _resolvedAddress; 43 | } 44 | 45 | /// Returns the owner/controller for the current ENS name. 46 | Future getCoinAddress(CoinType coinType) async { 47 | if (ensName == null) { 48 | throw 'ensName needs to be set first with .withName()'; 49 | } 50 | 51 | final _resolvedAddress = await addr$2(nodeHash, coinType.coinTypeInt); 52 | return hex.encode(_resolvedAddress); 53 | } 54 | 55 | /// Returns the address for the current ENS name for the coinId provided. 56 | Future setAddress( 57 | EthereumAddress address, 58 | BigInt coinType, { 59 | required Credentials credentials, 60 | Transaction? transaction, 61 | }) async { 62 | if (ensName == null) { 63 | throw 'ensName needs to be set first with .withName()'; 64 | } 65 | 66 | final _resolvedAddress = await setAddr( 67 | nodeHash, 68 | coinType, 69 | address.addressBytes, 70 | credentials: credentials, 71 | transaction: transaction, 72 | ); 73 | return _resolvedAddress; 74 | } 75 | 76 | /// Sets the address for the current ENS name for the coinId provided. 77 | Future getContentHash() async { 78 | return hex.encode(await contenthash(nodeHash)); 79 | } 80 | 81 | /// Returns the text record for a given key for the current ENS name. 82 | Future getTextRecord() async { 83 | var map = {}; 84 | 85 | for (var item in EnsTextKey.values) { 86 | var _name = ENSUtils.describeEnum(item); 87 | final _raw = await text( 88 | nodeHash, 89 | _name.replaceAll('_', '.'), 90 | ); 91 | 92 | map.putIfAbsent(_name, () => _raw); 93 | } 94 | 95 | final _record = EnsTextRecord.fromMap(map); 96 | setEnsTextRecord(_record); 97 | 98 | return _record; 99 | } 100 | 101 | /// Returns a Resolver Object, allowing you to query names from this specific resolver. 102 | /// Most useful when querying a different resolver that is different than is currently recorded on the registry. 103 | /// E.g. migrating to a new resolver 104 | Future getResolverAddress(Uint8List hash) async { 105 | final ensReg = EnsRegistryFallback( 106 | address: ENS_FALLBACK_REGISTRY, 107 | client: client, 108 | ); 109 | return ensReg.resolver(hash); 110 | } 111 | 112 | ///Returns a name, that allows you to make record queries. 113 | Future getName() async { 114 | if (ensAddress == null) { 115 | throw 'ensAddress needs to be set first with .withAddress()'; 116 | } 117 | final resolver = await getResolverAddress(reverseNodeHash); 118 | final name = await reverseEns(resolver).name(reverseNodeHash); 119 | withName(name); 120 | return name; 121 | } 122 | 123 | /// Sets the name for the current Ethereum address 124 | Future setEnsName( 125 | String name, { 126 | required Credentials credentials, 127 | Transaction? transaction, 128 | }) async { 129 | if (ensAddress == null) { 130 | throw 'ensAddress needs to be set first with .withAddress()'; 131 | } 132 | final _resolvedAddress = await setName( 133 | reverseNodeHash, 134 | name, 135 | credentials: credentials, 136 | transaction: transaction, 137 | ); 138 | return _resolvedAddress; 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /lib/src/models/coin_types.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: constant_identifier_names 2 | 3 | import 'package:ens_dart/src/ens_dart.dart'; 4 | 5 | enum CoinType { 6 | BTC, 7 | LTC, 8 | DOGE, 9 | RDD, 10 | DASH, 11 | PPC, 12 | NMC, 13 | VIA, 14 | GRS, 15 | DGB, 16 | MONA, 17 | DCR, 18 | XEM, 19 | AIB, 20 | SYS, 21 | ETH, 22 | ETC, 23 | ICX, 24 | XVG, 25 | STRAT, 26 | ARK, 27 | ATOM, 28 | ZIL, 29 | EGLD, 30 | ZEN, 31 | XMR, 32 | ZEC, 33 | LSK, 34 | STEEM, 35 | FIRO, 36 | RSK, 37 | KMD, 38 | XRP, 39 | BCH, 40 | XLM, 41 | BTM, 42 | OPT, 43 | XDAI, 44 | VET, 45 | BNB, 46 | CLO, 47 | HIVE, 48 | TOMO, 49 | HNT, 50 | RUNE, 51 | BCD, 52 | TT, 53 | FTM, 54 | ONE, 55 | ONT, 56 | XTZ, 57 | ADA, 58 | SC, 59 | QTUM, 60 | GXC, 61 | ELA, 62 | NAS, 63 | HBAR, 64 | IOTA, 65 | HNS, 66 | STX, 67 | GO, 68 | XCH, 69 | NULS, 70 | AVAX, 71 | NRG, 72 | ARDR, 73 | ZEL, 74 | CELO, 75 | WICC, 76 | WAN, 77 | WAVES, 78 | BSC, 79 | MATIC, 80 | ARB1, 81 | BTG, 82 | NANO, 83 | RVN, 84 | POA, 85 | LCC, 86 | EOS, 87 | TRX, 88 | BCN, 89 | FIO, 90 | BSV, 91 | NEO, 92 | NIM, 93 | EWT, 94 | ALGO, 95 | IOST, 96 | DIVI, 97 | IOTX, 98 | BTS, 99 | CKB, 100 | LUNA, 101 | DOT, 102 | VSYS, 103 | ABBC, 104 | NEAR, 105 | ETN, 106 | AION, 107 | KSM, 108 | AE, 109 | KAVA, 110 | FIL, 111 | AR, 112 | CCA, 113 | THETA, 114 | SOL, 115 | XHV, 116 | FLOW, 117 | IRIS, 118 | LRG, 119 | SERO, 120 | BDX, 121 | CCXX, 122 | SRM, 123 | VLX, 124 | BPS, 125 | TFUEL, 126 | GRIN 127 | } 128 | 129 | const _coinMaps = { 130 | "BTC": 0, 131 | "LTC": 2, 132 | "DOGE": 3, 133 | "RDD": 4, 134 | "DASH": 5, 135 | "PPC": 6, 136 | "NMC": 7, 137 | "VIA": 14, 138 | "GRS": 17, 139 | "DGB": 20, 140 | "MONA": 22, 141 | "DCR": 42, 142 | "XEM": 43, 143 | "AIB": 55, 144 | "SYS": 57, 145 | "ETH": 60, 146 | "ETC": 61, 147 | "ICX": 74, 148 | "XVG": 77, 149 | "STRAT": 105, 150 | "ARK": 111, 151 | "ATOM": 118, 152 | "ZIL": 119, 153 | "EGLD": 120, 154 | "ZEN": 121, 155 | "XMR": 128, 156 | "ZEC": 133, 157 | "LSK": 134, 158 | "STEEM": 135, 159 | "FIRO": 136, 160 | "RSK": 137, 161 | "KMD": 141, 162 | "XRP": 144, 163 | "BCH": 145, 164 | "XLM": 148, 165 | "BTM": 153, 166 | "OPT": 614, 167 | "XDAI": 700, 168 | "VET": 703, 169 | "BNB": 714, 170 | "CLO": 820, 171 | "HIVE": 825, 172 | "TOMO": 889, 173 | "HNT": 904, 174 | "RUNE": 931, 175 | "BCD": 999, 176 | "TT": 1001, 177 | "FTM": 1007, 178 | "ONE": 1023, 179 | "ONT": 1024, 180 | "XTZ": 1729, 181 | "ADA": 1815, 182 | "SC": 1991, 183 | "QTUM": 2301, 184 | "GXC": 2303, 185 | "ELA": 2305, 186 | "NAS": 2718, 187 | "HBAR": 3030, 188 | "IOTA": 4218, 189 | "HNS": 5353, 190 | "STX": 5757, 191 | "GO": 6060, 192 | "XCH": 8444, 193 | "NULS": 8964, 194 | "AVAX": 9000, 195 | "NRG": 9797, 196 | "ARDR": 16754, 197 | "ZEL": 19167, 198 | "CELO": 52752, 199 | "WICC": 99999, 200 | "WAN": 5718350, 201 | "WAVES": 5741564, 202 | "BSC": 2147483704, 203 | "MATIC": 2147483785, 204 | "ARB1": 2147525809, 205 | "BTG": 156, 206 | "NANO": 165, 207 | "RVN": 175, 208 | "POA": 178, 209 | "LCC": 192, 210 | "EOS": 194, 211 | "TRX": 195, 212 | "BCN": 204, 213 | "FIO": 235, 214 | "BSV": 236, 215 | "NEO": 239, 216 | "NIM": 242, 217 | "EWT": 246, 218 | "ALGO": 283, 219 | "IOST": 291, 220 | "DIVI": 301, 221 | "IOTX": 304, 222 | "BTS": 308, 223 | "CKB": 309, 224 | "LUNA": 330, 225 | "DOT": 354, 226 | "VSYS": 360, 227 | "ABBC": 367, 228 | "NEAR": 397, 229 | "ETN": 415, 230 | "AION": 425, 231 | "KSM": 434, 232 | "AE": 457, 233 | "KAVA": 459, 234 | "FIL": 461, 235 | "AR": 472, 236 | "CCA": 489, 237 | "THETA": 500, 238 | "SOL": 501, 239 | "XHV": 535, 240 | "FLOW": 539, 241 | "IRIS": 566, 242 | "LRG": 568, 243 | "SERO": 569, 244 | "BDX": 570, 245 | "CCXX": 571, 246 | "SRM": 573, 247 | "VLX": 574, 248 | "BPS": 576, 249 | "TFUEL": 589, 250 | "GRIN": 592 251 | }; 252 | 253 | extension CoinTypeVal on CoinType { 254 | BigInt get coinTypeInt => 255 | BigInt.from(_coinMaps[ENSUtils.describeEnum(this)] as int); 256 | } 257 | -------------------------------------------------------------------------------- /lib/src/models/ens_text_record.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | class EnsTextRecord { 4 | final String email; 5 | final String url; 6 | final String avatar; 7 | final String description; 8 | final String notice; 9 | final String keywords; 10 | final String discord; 11 | final String github; 12 | final String reddit; 13 | final String twitter; 14 | final String telegram; 15 | final String ensDelegate; 16 | EnsTextRecord({ 17 | required this.email, 18 | required this.url, 19 | required this.avatar, 20 | required this.description, 21 | required this.notice, 22 | required this.keywords, 23 | required this.discord, 24 | required this.github, 25 | required this.reddit, 26 | required this.twitter, 27 | required this.telegram, 28 | required this.ensDelegate, 29 | }); 30 | 31 | EnsTextRecord copyWith({ 32 | String? email, 33 | String? url, 34 | String? avatar, 35 | String? description, 36 | String? notice, 37 | String? keywords, 38 | String? discord, 39 | String? github, 40 | String? reddit, 41 | String? twitter, 42 | String? telegram, 43 | String? ensDelegate, 44 | }) { 45 | return EnsTextRecord( 46 | email: email ?? this.email, 47 | url: url ?? this.url, 48 | avatar: avatar ?? this.avatar, 49 | description: description ?? this.description, 50 | notice: notice ?? this.notice, 51 | keywords: keywords ?? this.keywords, 52 | discord: discord ?? this.discord, 53 | github: github ?? this.github, 54 | reddit: reddit ?? this.reddit, 55 | twitter: twitter ?? this.twitter, 56 | telegram: telegram ?? this.telegram, 57 | ensDelegate: ensDelegate ?? this.ensDelegate, 58 | ); 59 | } 60 | 61 | Map toMap() { 62 | return { 63 | 'email': email, 64 | 'url': url, 65 | 'avatar': avatar, 66 | 'description': description, 67 | 'notice': notice, 68 | 'keywords': keywords, 69 | 'com_discord': discord, 70 | 'com_github': github, 71 | 'com_reddit': reddit, 72 | 'com_twitter': twitter, 73 | 'org_telegram': telegram, 74 | 'eth_ens_delegate': ensDelegate, 75 | }; 76 | } 77 | 78 | factory EnsTextRecord.fromMap(Map map) { 79 | return EnsTextRecord( 80 | email: map['email'] ?? '', 81 | url: map['url'] ?? '', 82 | avatar: map['avatar'] ?? '', 83 | description: map['description'] ?? '', 84 | notice: map['notice'] ?? '', 85 | keywords: map['keywords'] ?? '', 86 | discord: map['com_discord'] ?? '', 87 | github: map['com_github'] ?? '', 88 | reddit: map['com_reddit'] ?? '', 89 | twitter: map['com_twitter'] ?? '', 90 | telegram: map['org_telegram'] ?? '', 91 | ensDelegate: map['eth_ens_delegate'] ?? '', 92 | ); 93 | } 94 | 95 | String toJson() => json.encode(toMap()); 96 | 97 | factory EnsTextRecord.fromJson(String source) => 98 | EnsTextRecord.fromMap(json.decode(source)); 99 | 100 | @override 101 | String toString() { 102 | return ''' 103 | EnsTextRecord { 104 | email: $email, 105 | url: $url, 106 | avatar: $avatar, 107 | description: $description, 108 | notice: $notice, 109 | keywords: $keywords, 110 | com.discord: $discord, 111 | com.github: $github, 112 | com.reddit: $reddit, 113 | com.twitter: $twitter, 114 | org.telegram: $telegram, 115 | eth.ens.delegate: $ensDelegate 116 | }'''; 117 | } 118 | 119 | @override 120 | bool operator ==(Object other) { 121 | if (identical(this, other)) return true; 122 | 123 | return other is EnsTextRecord && 124 | other.email == email && 125 | other.url == url && 126 | other.avatar == avatar && 127 | other.description == description && 128 | other.notice == notice && 129 | other.keywords == keywords && 130 | other.discord == discord && 131 | other.github == github && 132 | other.reddit == reddit && 133 | other.twitter == twitter && 134 | other.telegram == telegram && 135 | other.ensDelegate == ensDelegate; 136 | } 137 | 138 | @override 139 | int get hashCode { 140 | return email.hashCode ^ 141 | url.hashCode ^ 142 | avatar.hashCode ^ 143 | description.hashCode ^ 144 | notice.hashCode ^ 145 | keywords.hashCode ^ 146 | discord.hashCode ^ 147 | github.hashCode ^ 148 | reddit.hashCode ^ 149 | twitter.hashCode ^ 150 | telegram.hashCode ^ 151 | ensDelegate.hashCode; 152 | } 153 | } 154 | -------------------------------------------------------------------------------- /lib/src/models/models.dart: -------------------------------------------------------------------------------- 1 | export 'coin_types.dart'; 2 | export 'ens_text_record.dart'; 3 | -------------------------------------------------------------------------------- /lib/src/utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:convert/convert.dart'; 2 | import 'package:sha3/sha3.dart'; 3 | 4 | class ENSUtils { 5 | static String nameHash(String? inputName) { 6 | var node = ''; 7 | for (var i = 0; i < 32; i++) { 8 | node += '00'; 9 | } 10 | if (inputName != null) { 11 | if (!inputName.contains('.eth')) { 12 | inputName = '$inputName.eth'; 13 | } 14 | 15 | var labels = inputName.split('.'); 16 | 17 | for (var i = labels.length - 1; i >= 0; i--) { 18 | String labelSha; 19 | if (isEncodedLabelhash(labels[i])) { 20 | labelSha = decodeLabelhash(labels[i]); 21 | } else { 22 | var normalisedLabel = labels[i]; 23 | labelSha = sha3(normalisedLabel); 24 | } 25 | 26 | node = sha3(String.fromCharCodes(hex.decode('$node$labelSha'))); 27 | } 28 | } 29 | 30 | return '0x' + node; 31 | } 32 | 33 | static String reverseNameHash(inputName) { 34 | // Reject empty names: 35 | var node = ''; 36 | for (var i = 0; i < 32; i++) { 37 | node += '00'; 38 | } 39 | 40 | var name = normalize(inputName); 41 | 42 | var labels = name.split('.'); 43 | 44 | for (var i = labels.length - 1; i >= 0; i--) { 45 | var labelSha = sha3(labels[i]); 46 | node = sha3(String.fromCharCodes(hex.decode('$node$labelSha'))); 47 | } 48 | 49 | return '0x' + node; 50 | } 51 | 52 | String encodeLabelhash(hash) { 53 | if (!hash.startsWith('0x')) { 54 | throw 'Expected label hash to start with 0x'; 55 | } 56 | 57 | if (hash.length != 66) { 58 | throw 'Expected label hash to have a length of 66'; 59 | } 60 | 61 | return '[${hash.slice(2)}]'; 62 | } 63 | 64 | static String decodeLabelhash(String hash) { 65 | if (!(hash.startsWith('[') && hash.endsWith(']'))) { 66 | throw 'Expected encoded labelhash to start and end with square brackets'; 67 | } 68 | 69 | if (hash.length != 66) { 70 | throw 'Expected encoded labelhash to have a length of 66'; 71 | } 72 | 73 | return hash.slice(1, -1); 74 | } 75 | 76 | static bool isEncodedLabelhash(hash) { 77 | return hash.startsWith('[') && hash.endsWith(']') && hash.length == 66; 78 | } 79 | 80 | static bool isDecrypted(String name) { 81 | final nameArray = name.split('.'); 82 | final decrypted = nameArray.skip(1).fold(true, ((acc, label) { 83 | if (acc == false) return false; 84 | return isEncodedLabelhash(label) ? false : true; 85 | })); 86 | return decrypted; 87 | } 88 | 89 | static String labelhash(unnormalisedLabelOrLabelhash) { 90 | return isEncodedLabelhash(unnormalisedLabelOrLabelhash) 91 | ? '0x' + decodeLabelhash(unnormalisedLabelOrLabelhash) 92 | : '0x' + sha3(normalize(unnormalisedLabelOrLabelhash)); 93 | } 94 | 95 | static String sha3(String string) { 96 | var hash = 97 | SHA3(256, KECCAK_PADDING, 256).update(string.runes.toList()).digest(); 98 | 99 | return hex.encode(hash); 100 | } 101 | 102 | static String normalize(String name) { 103 | return (name); 104 | } 105 | 106 | static String describeEnum(Object enumEntry) { 107 | final String description = enumEntry.toString(); 108 | final int indexOfDot = description.indexOf('.'); 109 | assert( 110 | indexOfDot != -1 && indexOfDot < description.length - 1, 111 | 'The provided object "$enumEntry" is not an enum.', 112 | ); 113 | return description.substring(indexOfDot + 1); 114 | } 115 | } 116 | 117 | extension Slice on String { 118 | String slice(int start, [int? end]) { 119 | if (end != null && end.isNegative) { 120 | return substring(start, length - end.abs()); 121 | } 122 | return substring(start, end); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: ens_dart 2 | description: A dart library that wraps the Ethereum Name Service. It enables users and developers to use human-friendly names in place of error-prone hexadecimal addresses, content hashes, and more. 3 | version: 1.0.0 4 | homepage: https://github.com/Zfinix/ens_dart 5 | 6 | environment: 7 | sdk: ">=2.12.0 <3.0.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | dotenv: ^3.0.0 13 | sha3: ^0.2.0 14 | web3dart: ^2.3.3 15 | #path: ../web3dart 16 | web_socket_channel: ^2.1.0 17 | fast_base58: ^0.2.1 18 | http: ^0.13.4 19 | convert: ^3.0.1 20 | 21 | dev_dependencies: 22 | flutter_test: 23 | sdk: flutter 24 | flutter_lints: ^1.0.0 25 | 26 | # For information on the generic Dart part of this file, see the 27 | # following page: https://dart.dev/tools/pub/pubspec 28 | 29 | # The following section is specific to Flutter. 30 | flutter: 31 | -------------------------------------------------------------------------------- /test/ens_dart_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:dotenv/dotenv.dart' as env; 2 | import 'package:flutter_test/flutter_test.dart'; 3 | 4 | import 'package:ens_dart/ens_dart.dart'; 5 | import 'package:http/http.dart'; 6 | import 'package:web3dart/web3dart.dart'; 7 | import 'package:web_socket_channel/io.dart'; 8 | 9 | void main() { 10 | final names = [ 11 | 'chizi', 12 | 'mike', 13 | 'coinbase', 14 | 'sea', 15 | 'law', 16 | ]; 17 | 18 | final addresses = [ 19 | '0x324f9307b6d26881822c7c8692eeac39791a9756', 20 | '0x1a5cdcfba600e0c669795e0b65c344d5a37a4d5a', 21 | '0x81b287c0992b110adeb5903bf7e2d9350c80581a', 22 | '0x2cb86d919332d0369c66a2d5982419266f5e490f', 23 | '0x9c308bd202dddfca28f6cdce8e96b1e209833473', 24 | ]; 25 | group('ENS Tests', () { 26 | env.load(); 27 | 28 | final infuraKey = env.env['INFURA_KEY']; 29 | 30 | final rpcUrl = 'https://mainnet.infura.io/v3/$infuraKey'; 31 | final wsUrl = 'wss://mainnet.infura.io/ws/v3/$infuraKey'; 32 | 33 | final client = Web3Client(rpcUrl, Client(), socketConnector: () { 34 | return IOWebSocketChannel.connect(wsUrl).cast(); 35 | }); 36 | 37 | final ens = Ens(client: client); 38 | 39 | test('.getName() fetches correct name', () async { 40 | for (var i = 0; i < addresses.length; i++) { 41 | final name = await ens 42 | .withAddress(EthereumAddress.fromHex(addresses[i])) 43 | .getName(); 44 | expect(name, '${names[i]}.eth'); 45 | } 46 | }); 47 | test('.getAddress() fetches correct address', () async { 48 | for (var i = 0; i < names.length; i++) { 49 | final addr = await ens.withName('${names[i]}.eth').getAddress(); 50 | expect(addr.hex, addresses[i]); 51 | } 52 | }); 53 | test('.getTextRecord() fetches TextRecord', () async { 54 | for (var i = 0; i < names.length; i++) { 55 | final record = await ens.withName('brantly').getTextRecord(); 56 | expect(record.runtimeType, EnsTextRecord); 57 | } 58 | }); 59 | }); 60 | } 61 | --------------------------------------------------------------------------------