├── docs └── api │ ├── categories.json │ ├── static-assets │ ├── favicon.png │ ├── readme.md │ ├── play_button.svg │ └── github.css │ ├── __404error.html │ ├── etherscan_api │ ├── DescribeEnum │ │ └── str.html │ ├── EthChainString │ │ ├── chainName.html │ │ └── chainApiUrl.html │ ├── EthStats │ │ ├── ethPrice.html │ │ ├── ethSupply.html │ │ └── tokenSupply.html │ ├── EthTransaction │ │ └── getStatus.html │ ├── EthContract │ │ ├── getAbi.html │ │ └── getSourceCode.html │ ├── EtherscanAPI │ │ ├── chain.html │ │ ├── apiKey.html │ │ ├── timeout.html │ │ └── enableLogs.html │ ├── EtherSort │ │ └── toString.html │ ├── EtherScanFailure │ │ ├── code.html │ │ ├── message.html │ │ ├── props.html │ │ └── EtherScanFailure.html │ ├── EthChain │ │ └── toString.html │ ├── EthBlock │ │ └── getBlockReward.html │ ├── EthAccount │ │ ├── getMinedBlocks.html │ │ └── balance.html │ └── EthProxy │ │ ├── gasPrice.html │ │ └── blockNumber.html │ └── index.html ├── CHANGELOG.md ├── .DS_Store ├── lib ├── .DS_Store ├── src │ ├── .DS_Store │ ├── core │ │ ├── commons │ │ │ └── failure.dart │ │ ├── utils │ │ │ └── logger.dart │ │ ├── apis │ │ │ ├── transaction.dart │ │ │ ├── block.dart │ │ │ ├── contract.dart │ │ │ ├── stats.dart │ │ │ └── log.dart │ │ └── helper │ │ │ └── get_request.dart │ ├── models │ │ ├── models.dart │ │ ├── contract │ │ │ ├── abi_model.dart │ │ │ └── source_code_model.dart │ │ ├── proxy │ │ │ ├── rpc_response_model.dart │ │ │ └── tx_by_hash_model.dart │ │ ├── stats │ │ │ ├── supply_model.dart │ │ │ ├── eth_price_model.dart │ │ │ └── block_reward_model.dart │ │ ├── account │ │ │ ├── token_balance_model.dart │ │ │ ├── balance_model.dart │ │ │ ├── minted_blocks_model.dart │ │ │ └── tx_list_internal_model.dart │ │ ├── transaction │ │ │ └── tx_status.dart │ │ └── log │ │ │ └── log_model.dart │ └── etherscan_api.dart └── etherscan_api.dart ├── .gitignore ├── pubspec.yaml ├── analysis_options.yaml ├── .vscode └── launch.json ├── example └── main.dart ├── test ├── eth_test.dart ├── testnet_balance_test.dart └── balance_test.dart ├── LICENSE.md └── README.md /docs/api/categories.json: -------------------------------------------------------------------------------- 1 | [] 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.0-beta 2 | 3 | - Initial version 4 | -------------------------------------------------------------------------------- /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zfinix/etherscan_api/HEAD/.DS_Store -------------------------------------------------------------------------------- /lib/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zfinix/etherscan_api/HEAD/lib/.DS_Store -------------------------------------------------------------------------------- /lib/src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zfinix/etherscan_api/HEAD/lib/src/.DS_Store -------------------------------------------------------------------------------- /docs/api/static-assets/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Zfinix/etherscan_api/HEAD/docs/api/static-assets/favicon.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .dart_tool/ 3 | .packages 4 | 5 | # Conventional directory for build outputs 6 | build/ 7 | 8 | -------------------------------------------------------------------------------- /docs/api/static-assets/readme.md: -------------------------------------------------------------------------------- 1 | # highlight.js 2 | 3 | Generated from https://highlightjs.org/download/ on 2020-12-30 4 | 5 | Included languages: 6 | 7 | * bash 8 | * css 9 | * dart 10 | * html, xml 11 | * java 12 | * javascript 13 | * json 14 | * kotlin 15 | * markdown 16 | * objective-c 17 | * shell 18 | * swift 19 | * yaml 20 | -------------------------------------------------------------------------------- /docs/api/static-assets/play_button.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/src/core/commons/failure.dart: -------------------------------------------------------------------------------- 1 | import 'package:equatable/equatable.dart'; 2 | 3 | class EtherScanFailure extends Equatable { 4 | final String message; 5 | final int code; 6 | 7 | EtherScanFailure({this.message = '', this.code = -1}); 8 | 9 | @override 10 | bool? get stringify => true; 11 | 12 | @override 13 | List get props => [message, code]; 14 | } 15 | -------------------------------------------------------------------------------- /lib/etherscan_api.dart: -------------------------------------------------------------------------------- 1 | library etherscan_api; 2 | 3 | export 'src/etherscan_api.dart'; 4 | export 'src/core/apis/log.dart'; 5 | export 'src/core/apis/proxy.dart'; 6 | export 'src/core/apis/block.dart'; 7 | export 'src/core/apis/stats.dart'; 8 | export 'src/core/apis/account.dart'; 9 | export 'src/core/apis/contract.dart'; 10 | export 'src/core/apis/transaction.dart'; 11 | export 'src/core/commons/failure.dart'; 12 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: etherscan_api 2 | description: A dart library to access the etherscan.io apis. 3 | version: 1.0.0-beta 4 | homepage: https://www.example.com 5 | 6 | environment: 7 | sdk: '>=2.12.0 <3.0.0' 8 | 9 | dependencies: 10 | dio: ^4.0.0-prev3 11 | dartz: ^0.10.0-nullsafety.1 12 | equatable: ^2.0.0 13 | logger: ^1.0.0 14 | 15 | dev_dependencies: 16 | pedantic: ^1.9.0 17 | test: ^1.14.4 18 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:pedantic/analysis_options.yaml 2 | 3 | analyzer: 4 | 5 | linter: 6 | rules: 7 | - prefer_single_quotes 8 | - avoid_returning_null_for_future 9 | - prefer_void_to_null 10 | - always_require_non_null_named_parameters 11 | - avoid_returning_null 12 | - avoid_returning_null_for_void 13 | - prefer_initializing_formals 14 | - prefer_typing_uninitialized_variables 15 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "etherscan_api", 9 | "request": "launch", 10 | "type": "dart" 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /example/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/etherscan_api.dart'; 2 | 3 | void main() async { 4 | final eth = EtherscanAPI( 5 | apiKey: 'YourApiKey', chain: EthChain.ropsten, enableLogs: false); 6 | 7 | final bal = await eth.txListInternal( 8 | txhash: 9 | '0x40eb908387324f2b575b4879cd9d7188f69c8fc9d87c901b9e2daaea4b442170'); 10 | 11 | print(bal); 12 | 13 | /// EtherScanBalanceModel(1, OK, [EtherScanBalanceResult(0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae, 430141119464489895480972)]) 14 | } 15 | -------------------------------------------------------------------------------- /test/eth_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/models/models.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | group('proxy', () { 7 | final eth = EtherscanAPI( 8 | apiKey: 'YourApiKey', 9 | ); 10 | test('.getMinedBlocks() returns data', () async { 11 | final bal = await eth.getMinedBlocks( 12 | address: '0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b', 13 | ); 14 | expect(bal, isNot(EtherScanMintedBlocksModel.empty())); 15 | }); 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /test/testnet_balance_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/models/models.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | group('testnet balance', () { 7 | final eth = EtherscanAPI( 8 | apiKey: 'YourApiKey', 9 | chain: EthChain.ropsten, 10 | ); 11 | test('.balance() returns testnet balance data', () async { 12 | final bal = await eth.balance( 13 | addresses: [ 14 | '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', 15 | ], 16 | ); 17 | expect(bal, isNot(EtherScanBalanceModel.empty())); 18 | }); 19 | }); 20 | } 21 | -------------------------------------------------------------------------------- /lib/src/core/utils/logger.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:logger/logger.dart'; 5 | 6 | String? stringifyMessage(dynamic message) { 7 | final decoder = JsonDecoder(); 8 | final encoder = JsonEncoder.withIndent(' '); 9 | final color = AnsiColor.fg(15); 10 | 11 | if (message is String) { 12 | try { 13 | final raw = decoder.convert(message); 14 | return Platform.isAndroid 15 | ? color(encoder.convert(raw)) 16 | : encoder.convert(raw); 17 | } catch (e) { 18 | return message.toString(); 19 | } 20 | } else if (message is Map || message is Iterable) { 21 | return Platform.isAndroid 22 | ? color(encoder.convert(message)) 23 | : encoder.convert(message); 24 | } else { 25 | return message.toString(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/models/models.dart: -------------------------------------------------------------------------------- 1 | /// Account Models 2 | export 'account/balance_model.dart'; 3 | export 'account/token_balance_model.dart'; 4 | export 'account/tx_list_internal_model.dart'; 5 | export 'account/tx_list_model.dart'; 6 | export 'account/minted_blocks_model.dart'; 7 | export 'account/token_tx_model.dart'; 8 | export 'account/token_fftx_model.dart'; 9 | 10 | /// Transaction Models 11 | export 'transaction/tx_status.dart'; 12 | 13 | /// Stats Models 14 | export 'stats/block_reward_model.dart'; 15 | export 'stats/eth_price_model.dart'; 16 | export 'stats/supply_model.dart'; 17 | 18 | /// Proxy Models 19 | export 'proxy/block_by_number_model.dart'; 20 | export 'proxy/rpc_response_model.dart'; 21 | export 'proxy/tx_by_hash_model.dart'; 22 | export 'proxy/tx_receipt_model.dart'; 23 | 24 | /// Log Models 25 | export 'log/log_model.dart'; 26 | -------------------------------------------------------------------------------- /lib/src/core/apis/transaction.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/src/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/core/helper/get_request.dart'; 3 | import 'package:etherscan_api/src/models/models.dart'; 4 | 5 | extension EthTransaction on EtherscanAPI { 6 | /// Returns the status of a specific transaction hash 7 | /// 8 | /// `txhash` - Transaction hash 9 | /// 10 | 11 | Future getStatus({ 12 | required String? txhash, 13 | }) async { 14 | const module = 'transaction'; 15 | const action = 'getstatus'; 16 | 17 | Map? query = { 18 | 'txhash': txhash, 19 | 'module': module, 20 | 'action': action, 21 | 'apiKey': apiKey, 22 | }; 23 | 24 | return (await get(query)).fold( 25 | (l) => EtherScanTxStatusModel.empty(), 26 | (r) => EtherScanTxStatusModel.fromJson(r), 27 | ); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /test/balance_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/models/models.dart'; 3 | import 'package:test/test.dart'; 4 | 5 | void main() { 6 | group('balance', () { 7 | final eth = EtherscanAPI( 8 | apiKey: 'YourApiKey', 9 | ); 10 | test('.balance() returns data', () async { 11 | final bal = await eth.balance( 12 | addresses: [ 13 | '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', 14 | ], 15 | ); 16 | expect(bal, isNot(EtherScanBalanceModel.empty())); 17 | }); 18 | }); 19 | 20 | test('.balance() throws Error', () async { 21 | final eth = EtherscanAPI( 22 | apiKey: '', 23 | enableLogs: true, 24 | ); 25 | 26 | final bal = await eth.balance( 27 | addresses: [ 28 | '', 29 | ], 30 | ); 31 | expect(bal, equals(EtherScanBalanceModel.empty())); 32 | }); 33 | } 34 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Chiziaruhoma Ogbonda 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /lib/src/core/apis/block.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/src/models/models.dart'; 2 | 3 | import 'package:etherscan_api/src/core/helper/get_request.dart'; 4 | import 'package:etherscan_api/src/etherscan_api.dart'; 5 | 6 | extension EthBlock on EtherscanAPI { 7 | /// 8 | /// Find the block reward for a given address and block 9 | /// 10 | /// `address` - Address of the block 11 | /// 12 | /// `blockno` - Block number 13 | /// 14 | 15 | Future getBlockReward({ 16 | String? address, 17 | Object? blockno = 0, 18 | }) async { 19 | const module = 'block'; 20 | const action = 'getblockreward'; 21 | 22 | final query = { 23 | 'module': module, 24 | 'action': action, 25 | 'apiKey': apiKey, 26 | }; 27 | 28 | if (address != null) { 29 | query.putIfAbsent('address', () => address); 30 | } 31 | 32 | if (blockno != null) { 33 | query.putIfAbsent('blockno', () => '$blockno'); 34 | } 35 | 36 | return (await get(query)).fold( 37 | (l) => EtherScanBlockRewardModel.empty(), 38 | (r) => EtherScanBlockRewardModel.fromJson(r), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Etherscan Dart API 2 | 3 | [![license](https://img.shields.io/github/license/Zfinix/etherscan_api.svg)](https://github.com/Zfinix/etherscan_api/blob/main/LICENSE.md) 4 | [![GitHub tag](https://img.shields.io/github/tag/Zfinix/etherscan_api.svg)](https://github.com/Zfinix/etherscan_api) 5 | 6 | [![GitHub issues](https://img.shields.io/github/issues/Zfinix/etherscan_api.svg)](https://github.com/Zfinix/etherscan_api/issues) 7 | 8 | A dart library to access the [etherscan.io](https://etherscan.io/apis) apis. 9 | 10 | ```dart 11 | 12 | import 'package:etherscan_api/etherscan_api.dart'; 13 | 14 | final eth = EtherscanAPI(apiKey: 'YourApiKey'); 15 | 16 | final bal = await eth.balance( 17 | addresses: [ 18 | '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae', 19 | ], 20 | ); 21 | 22 | print(val); 23 | 24 | ``` 25 | ## For testnet usage 26 | 27 | Supported TestNets: 28 | 29 | * morden 30 | * ropsten 31 | * rinkeby 32 | 33 | Latest 34 | 35 | ```dart 36 | 37 | final eth = EtherscanAPI( 38 | apiKey: 'YourApiKey', // Api key 39 | chain: EthChain.ropsten, // Network/chain 40 | enableLogs: true // Enable Logging 41 | ); 42 | ``` 43 | 44 | 45 | -------------------------------------------------------------------------------- /lib/src/models/contract/abi_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanAbiModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final String result; 9 | 10 | EtherScanAbiModel({ 11 | required this.status, 12 | required this.message, 13 | required this.result, 14 | }); 15 | 16 | EtherScanAbiModel copyWith({ 17 | String? status, 18 | String? message, 19 | String? result, 20 | }) { 21 | return EtherScanAbiModel( 22 | status: status ?? this.status, 23 | message: message ?? this.message, 24 | result: result ?? this.result, 25 | ); 26 | } 27 | 28 | Map toMap() { 29 | return { 30 | 'status': status, 31 | 'message': message, 32 | 'result': result, 33 | }; 34 | } 35 | 36 | factory EtherScanAbiModel.empty() { 37 | return EtherScanAbiModel( 38 | status: 'empty', 39 | message: '', 40 | result: '', 41 | ); 42 | } 43 | 44 | factory EtherScanAbiModel.fromMap(Map map) { 45 | return EtherScanAbiModel( 46 | status: map['status'], 47 | message: map['message'], 48 | result: map['result'], 49 | ); 50 | } 51 | 52 | String toJson() => json.encode(toMap()); 53 | 54 | factory EtherScanAbiModel.fromJson(String source) => 55 | EtherScanAbiModel.fromMap(json.decode(source)); 56 | 57 | @override 58 | bool get stringify => true; 59 | 60 | @override 61 | List get props => [status, message, result]; 62 | } 63 | -------------------------------------------------------------------------------- /lib/src/models/proxy/rpc_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanRpcResponseModel with EquatableMixin { 6 | final String jsonrpc; 7 | final int id; 8 | final String result; 9 | EtherScanRpcResponseModel({ 10 | required this.jsonrpc, 11 | required this.id, 12 | required this.result, 13 | }); 14 | 15 | EtherScanRpcResponseModel copyWith({ 16 | String? jsonrpc, 17 | int? id, 18 | String? result, 19 | }) { 20 | return EtherScanRpcResponseModel( 21 | jsonrpc: jsonrpc ?? this.jsonrpc, 22 | id: id ?? this.id, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'jsonrpc': jsonrpc, 30 | 'id': id, 31 | 'result': result, 32 | }; 33 | } 34 | 35 | factory EtherScanRpcResponseModel.empty() { 36 | return EtherScanRpcResponseModel( 37 | jsonrpc: '', 38 | id: 0, 39 | result: '', 40 | ); 41 | } 42 | 43 | factory EtherScanRpcResponseModel.fromMap(Map map) { 44 | return EtherScanRpcResponseModel( 45 | jsonrpc: map['jsonrpc'], 46 | id: map['id'], 47 | result: map['result'], 48 | ); 49 | } 50 | 51 | String toJson() => json.encode(toMap()); 52 | 53 | factory EtherScanRpcResponseModel.fromJson(String source) => 54 | EtherScanRpcResponseModel.fromMap(json.decode(source)); 55 | 56 | @override 57 | bool get stringify => true; 58 | 59 | @override 60 | List get props => [jsonrpc, id, result]; 61 | } 62 | -------------------------------------------------------------------------------- /lib/src/models/stats/supply_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanSupplyModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final String result; 9 | 10 | EtherScanSupplyModel({ 11 | required this.status, 12 | required this.message, 13 | required this.result, 14 | }); 15 | 16 | EtherScanSupplyModel copyWith({ 17 | String? status, 18 | String? message, 19 | String? result, 20 | }) { 21 | return EtherScanSupplyModel( 22 | status: status ?? this.status, 23 | message: message ?? this.message, 24 | result: result ?? this.result, 25 | ); 26 | } 27 | 28 | Map toMap() { 29 | return { 30 | 'status': status, 31 | 'message': message, 32 | 'result': result, 33 | }; 34 | } 35 | 36 | factory EtherScanSupplyModel.empty() { 37 | return EtherScanSupplyModel( 38 | status: 'empty', 39 | message: '', 40 | result: '', 41 | ); 42 | } 43 | 44 | factory EtherScanSupplyModel.fromMap(Map map) { 45 | return EtherScanSupplyModel( 46 | status: map['status'], 47 | message: map['message'], 48 | result: map['result'], 49 | ); 50 | } 51 | 52 | String toJson() => json.encode(toMap()); 53 | 54 | factory EtherScanSupplyModel.fromJson(String source) => 55 | EtherScanSupplyModel.fromMap(json.decode(source)); 56 | 57 | @override 58 | bool? get stringify => true; 59 | 60 | @override 61 | List get props => [status, message, result]; 62 | } 63 | -------------------------------------------------------------------------------- /lib/src/models/account/token_balance_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanTokenBalanceModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final String result; 9 | EtherScanTokenBalanceModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanTokenBalanceModel copyWith({ 16 | String? status, 17 | String? message, 18 | String? result, 19 | }) { 20 | return EtherScanTokenBalanceModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result, 32 | }; 33 | } 34 | 35 | factory EtherScanTokenBalanceModel.fromMap(Map map) { 36 | return EtherScanTokenBalanceModel( 37 | status: map['status'], 38 | message: map['message'], 39 | result: map['result'], 40 | ); 41 | } 42 | 43 | factory EtherScanTokenBalanceModel.empty() { 44 | return EtherScanTokenBalanceModel( 45 | status: 'empty', 46 | message: '', 47 | result: '', 48 | ); 49 | } 50 | 51 | String toJson() => json.encode(toMap()); 52 | 53 | factory EtherScanTokenBalanceModel.fromJson(String source) => 54 | EtherScanTokenBalanceModel.fromMap(json.decode(source)); 55 | 56 | @override 57 | bool? get stringify => true; 58 | 59 | @override 60 | List get props => [status, message, result]; 61 | } 62 | -------------------------------------------------------------------------------- /docs/api/static-assets/github.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | github.com style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | .hljs { 8 | display: block; 9 | overflow-x: auto; 10 | padding: 0.5em; 11 | color: #333; 12 | background: #f8f8f8; 13 | } 14 | 15 | .hljs-comment, 16 | .hljs-quote { 17 | color: #998; 18 | font-style: italic; 19 | } 20 | 21 | .hljs-keyword, 22 | .hljs-selector-tag, 23 | .hljs-subst { 24 | color: #333; 25 | font-weight: bold; 26 | } 27 | 28 | .hljs-number, 29 | .hljs-literal, 30 | .hljs-variable, 31 | .hljs-template-variable, 32 | .hljs-tag .hljs-attr { 33 | color: #008080; 34 | } 35 | 36 | .hljs-string, 37 | .hljs-doctag { 38 | color: #d14; 39 | } 40 | 41 | .hljs-title, 42 | .hljs-section, 43 | .hljs-selector-id { 44 | color: #900; 45 | font-weight: bold; 46 | } 47 | 48 | .hljs-subst { 49 | font-weight: normal; 50 | } 51 | 52 | .hljs-type, 53 | .hljs-class .hljs-title { 54 | color: #458; 55 | font-weight: bold; 56 | } 57 | 58 | .hljs-tag, 59 | .hljs-name, 60 | .hljs-attribute { 61 | color: #000080; 62 | font-weight: normal; 63 | } 64 | 65 | .hljs-regexp, 66 | .hljs-link { 67 | color: #009926; 68 | } 69 | 70 | .hljs-symbol, 71 | .hljs-bullet { 72 | color: #990073; 73 | } 74 | 75 | .hljs-built_in, 76 | .hljs-builtin-name { 77 | color: #0086b3; 78 | } 79 | 80 | .hljs-meta { 81 | color: #999; 82 | font-weight: bold; 83 | } 84 | 85 | .hljs-deletion { 86 | background: #fdd; 87 | } 88 | 89 | .hljs-addition { 90 | background: #dfd; 91 | } 92 | 93 | .hljs-emphasis { 94 | font-style: italic; 95 | } 96 | 97 | .hljs-strong { 98 | font-weight: bold; 99 | } 100 | -------------------------------------------------------------------------------- /lib/src/etherscan_api.dart: -------------------------------------------------------------------------------- 1 | import 'core/helper/get_request.dart'; 2 | 3 | class EtherscanAPI { 4 | final String apiKey; 5 | final EthChain chain; 6 | final bool enableLogs; 7 | final Duration? timeout; 8 | 9 | EtherscanAPI({ 10 | required this.apiKey, 11 | this.chain = EthChain.mainnet, 12 | this.enableLogs = true, 13 | this.timeout, 14 | }); 15 | } 16 | 17 | /// EtherScan sort order 18 | enum EtherSort { asc, desc } 19 | 20 | /// Describe num extension 21 | extension DescribeEnum on Object { 22 | String get str => describeEnum(this); 23 | } 24 | 25 | /// Ethereum chain type 26 | enum EthChain { mainnet, ropsten, kovan, rinkeby, homestead } 27 | 28 | extension EthChainString on EthChain { 29 | String get chainName => str; 30 | String get chainApiUrl => ETH_API_URLS[chainName]!; 31 | } 32 | 33 | // This method exists as a workaround for https://github.com/dart-lang/sdk/issues/30021 34 | /// Returns a short description of an enum value. 35 | /// 36 | /// Strips off the enum class name from the `enumEntry.toString()`. 37 | /// 38 | /// {@tool snippet} 39 | /// 40 | /// ```dart 41 | /// enum EthChain { 42 | /// mainnet, ropsten, kovan, rinkeby, homestead 43 | /// } 44 | /// 45 | /// void validateDescribeEnum() { 46 | /// assert(EthChain.ropsten.toString() == 'EthChain.ropsten'); 47 | /// assert(describeEnum(EthChain.ropsten) == 'ropsten'); 48 | /// } 49 | /// ``` 50 | /// {@end-tool} 51 | String describeEnum(Object enumEntry) { 52 | final description = enumEntry.toString(); 53 | final indexOfDot = description.indexOf('.'); 54 | 55 | assert( 56 | indexOfDot != -1 && indexOfDot < description.length - 1, 57 | 'The provided object "$enumEntry" is not an enum.', 58 | ); 59 | 60 | return description.substring(indexOfDot + 1); 61 | } 62 | -------------------------------------------------------------------------------- /lib/src/core/apis/contract.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/src/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/models/contract/abi_model.dart'; 3 | import 'package:etherscan_api/src/core/helper/get_request.dart'; 4 | import 'package:etherscan_api/src/models/contract/source_code_model.dart'; 5 | 6 | extension EthContract on EtherscanAPI { 7 | /// Returns the ABI/Interface of a given contract 8 | /// 9 | /// `address` - Contract address 10 | /// 11 | /// Example 12 | /// 13 | /// ``` 14 | /// api.contract 15 | /// ..getAbi('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359') 16 | /// ..at('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359') 17 | /// ..memberId('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359') 18 | /// ``` 19 | /// 20 | Future getAbi({ 21 | required String? address, 22 | }) async { 23 | const module = 'contract'; 24 | const action = 'getabi'; 25 | 26 | var query = { 27 | 'module': module, 28 | 'action': action, 29 | 'address': address, 30 | 'apiKey': apiKey 31 | }; 32 | 33 | return (await get(query)).fold( 34 | (l) => EtherScanAbiModel.empty(), 35 | (r) => EtherScanAbiModel.fromJson(r), 36 | ); 37 | } 38 | 39 | /// Get Contract Source Code for Verified Contract Source Codes 40 | /// 41 | /// `address` - Contract address 42 | /// 43 | /// Example 44 | /// 45 | /// ``` 46 | /// api.contract.getSourceCode( 47 | /// address: '0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359' 48 | /// ) 49 | /// ``` 50 | /// 51 | Future getSourceCode({ 52 | required String? address, 53 | }) async { 54 | const module = 'contract'; 55 | const action = 'getsourcecode'; 56 | 57 | var query = { 58 | 'module': module, 59 | 'action': action, 60 | 'address': address, 61 | 'apiKey': apiKey 62 | }; 63 | 64 | return (await get(query)).fold( 65 | (l) => EtherscanSourceCodeModel.empty(), 66 | (r) => EtherscanSourceCodeModel.fromJson(r), 67 | ); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/src/core/helper/get_request.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:dartz/dartz.dart'; 4 | import 'package:dio/dio.dart'; 5 | import 'package:etherscan_api/etherscan_api.dart'; 6 | import 'package:etherscan_api/src/core/utils/logger.dart'; 7 | 8 | import '../commons/failure.dart'; 9 | 10 | const ETH_API_URLS = { 11 | 'mainnet': 'https://api.etherscan.io', 12 | 'ropsten': 'https://api-ropsten.etherscan.io', 13 | 'kovan': 'https://api-kovan.etherscan.io', 14 | 'rinkeby': 'https://api-rinkeby.etherscan.io', 15 | 'homestead': 'https://api.etherscan.io' 16 | }; 17 | 18 | extension GetRequest on EtherscanAPI { 19 | /// Runs query 20 | /// returns [Future>] 21 | Future> get( 22 | Map? query, 23 | ) async { 24 | try { 25 | if (enableLogs == true) { 26 | // Log data response 27 | print('api_url: ${chain.chainApiUrl}\n'); 28 | print('query: ${stringifyMessage(query)}\n'); 29 | } 30 | 31 | /// Dio client 32 | final client = Dio( 33 | BaseOptions( 34 | baseUrl: chain.chainApiUrl, 35 | connectTimeout: timeout?.inMilliseconds, 36 | responseType: ResponseType.json, 37 | ), 38 | ); 39 | 40 | /// Make Request 41 | final res = await client.get('/api', queryParameters: query); 42 | 43 | /// Return Error if data is null 44 | if (res.data == null) { 45 | if (enableLogs == true) { 46 | // Log error response 47 | print('Error: Null Response\n'); 48 | } 49 | return Left(EtherScanFailure(message: 'Null Response')); 50 | } 51 | 52 | var status = res.data['status']; 53 | if (status != null && status != '1' || '${res.data}'.contains('error')) { 54 | if (enableLogs == true) { 55 | // Log error response 56 | print('Error: ${res.data}'); 57 | } 58 | 59 | return Left(EtherScanFailure(message: '${res.data}')); 60 | } 61 | 62 | if (enableLogs == true) { 63 | // Log success response 64 | print('response: ${stringifyMessage(res.data)}\n'); 65 | } 66 | return Right(json.encode(res.data)); 67 | } catch (e) { 68 | var msg = e.toString(); 69 | 70 | if (enableLogs == true) { 71 | /// Log error response 72 | print('Error: $msg'); 73 | } 74 | return Left(EtherScanFailure(message: msg)); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /lib/src/core/apis/stats.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/src/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/core/helper/get_request.dart'; 3 | import 'package:etherscan_api/src/models/models.dart'; 4 | import 'package:etherscan_api/src/models/stats/eth_price_model.dart'; 5 | 6 | extension EthStats on EtherscanAPI { 7 | /// Returns the supply of Tokens 8 | /// 9 | /// `tokenname` - Name of the Token 10 | /// 11 | /// `contractaddress` - Address from token contract 12 | /// 13 | /// Example 14 | /// 15 | /// ```dart 16 | /// var supply = eth.tokenSupply( 17 | /// tokenname: null, 18 | /// contractAddress: '0x57d90b64a1a57749b0f932f1a3395792e12e7055' 19 | /// ); 20 | /// ``` 21 | /// Result returned in Wei, to get value in Ether divide resultAbove/1000000000000000000) 22 | /// 23 | 24 | Future tokenSupply({ 25 | String? tokenName, 26 | String? contractAddress, 27 | }) async { 28 | const module = 'stats'; 29 | const action = 'tokensupply'; 30 | 31 | Map? query = { 32 | 'module': module, 33 | 'action': action, 34 | 'apiKey': apiKey, 35 | }; 36 | 37 | if (tokenName != null) { 38 | query.putIfAbsent('tokenname', () => tokenName); 39 | } 40 | 41 | if (contractAddress != null) { 42 | query.putIfAbsent('contractaddress', () => contractAddress); 43 | } 44 | 45 | return (await get(query)).fold( 46 | (l) => EtherScanSupplyModel.empty(), 47 | (r) => EtherScanSupplyModel.fromJson(r), 48 | ); 49 | } 50 | 51 | /// Returns total supply of ether 52 | /// 53 | /// Example 54 | /// 55 | ///``` dart 56 | /// var supply = eth.ethSupply(); 57 | ///``` 58 | /// 59 | 60 | Future ethSupply() async { 61 | const module = 'stats'; 62 | const action = 'ethsupply'; 63 | 64 | Map? query = { 65 | 'module': module, 66 | 'action': action, 67 | 'apiKey': apiKey, 68 | }; 69 | 70 | return (await get(query)).fold( 71 | (l) => EtherScanSupplyModel.empty(), 72 | (r) => EtherScanSupplyModel.fromJson(r), 73 | ); 74 | } 75 | 76 | /// Returns the price of ether now 77 | /// 78 | /// Example 79 | /// 80 | /// ```dart 81 | /// var price = eth.ethprice(); 82 | /// ``` 83 | /// 84 | 85 | Future ethPrice() async { 86 | const module = 'stats'; 87 | const action = 'ethprice'; 88 | 89 | Map? query = { 90 | 'module': module, 91 | 'action': action, 92 | 'apiKey': apiKey, 93 | }; 94 | 95 | return (await get(query)).fold( 96 | (l) => EtherScanPriceModel.empty(), 97 | (r) => EtherScanPriceModel.fromJson(r), 98 | ); 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /lib/src/core/apis/log.dart: -------------------------------------------------------------------------------- 1 | import 'package:etherscan_api/src/etherscan_api.dart'; 2 | import 'package:etherscan_api/src/core/helper/get_request.dart'; 3 | import 'package:etherscan_api/src/models/models.dart'; 4 | 5 | extension EthLog on EtherscanAPI { 6 | /// The Event Log API was designed to provide an alternative to the native eth_getLogs. 7 | /// returns the status of a specific transaction hash 8 | /// 9 | /// `fromBlock` - fromBlock 10 | /// 11 | /// `toBlock` - toBlock 12 | /// 13 | /// `topic0` - topic (32 Bytes per topic) 14 | /// 15 | /// `topic0_1_opr` - and | or between topic0 & topic1 16 | /// 17 | /// `topic1` - topic (32 Bytes per topic) 18 | /// 19 | /// `topic1_2_opr` - and | or between topic1 & topic2 20 | /// 21 | /// `topic2` - topic (32 Bytes per topic) 22 | /// 23 | /// `topic2_3_opr` - and | or between topic2 & topic3 24 | /// 25 | /// `topic3` - topic (32 Bytes per topic) 26 | /// 27 | /// `topic0_2_opr` - and | or between topic0 & topic2 28 | /// 29 | 30 | Future getLogs({ 31 | required String? address, 32 | String? fromBlock, 33 | String? toBlock, 34 | String? topic0, 35 | String? topic0_1_opr, 36 | String? topic1, 37 | String? topic1_2_opr, 38 | String? topic2, 39 | String? topic2_3_opr, 40 | String? topic3, 41 | String? topic0_2_opr, 42 | }) async { 43 | const module = 'logs'; 44 | const action = 'getLogs'; 45 | 46 | Map? query = { 47 | 'apiKey': apiKey, 48 | 'module': module, 49 | 'action': action, 50 | }; 51 | 52 | if (address != null) { 53 | query.putIfAbsent('address', () => address); 54 | } 55 | 56 | if (fromBlock != null) { 57 | query.putIfAbsent('fromBlock', () => fromBlock); 58 | } 59 | 60 | if (toBlock != null) { 61 | query.putIfAbsent('toBlock', () => toBlock); 62 | } 63 | 64 | if (topic0 != null) { 65 | query.putIfAbsent('topic0', () => topic0); 66 | } 67 | if (topic0_1_opr != null) { 68 | query.putIfAbsent('topic0_1_opr', () => topic0_1_opr); 69 | } 70 | 71 | if (topic1 != null) { 72 | query.putIfAbsent('topic1', () => topic1); 73 | } 74 | 75 | if (topic1_2_opr != null) { 76 | query.putIfAbsent('topic1_2_opr', () => topic1_2_opr); 77 | } 78 | if (topic2 != null) { 79 | query.putIfAbsent('topic2', () => topic2); 80 | } 81 | 82 | if (topic2_3_opr != null) { 83 | query.putIfAbsent('topic2_3_opr', () => topic2_3_opr); 84 | } 85 | 86 | if (topic0_2_opr != null) { 87 | query.putIfAbsent('topic0_2_opr', () => topic0_2_opr); 88 | } 89 | 90 | if (topic3 != null) { 91 | query.putIfAbsent('topic3', () => topic3); 92 | } 93 | return (await get(query)).fold( 94 | (l) => EtherScanLogModel.empty(), 95 | (r) => EtherScanLogModel.fromJson(r), 96 | ); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /lib/src/models/account/balance_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanBalanceModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final List? result; 9 | EtherScanBalanceModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanBalanceModel copyWith({ 16 | String? status, 17 | String? message, 18 | List? result, 19 | }) { 20 | return EtherScanBalanceModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result?.map((x) => x.toMap()).toList(), 32 | }; 33 | } 34 | 35 | factory EtherScanBalanceModel.empty() { 36 | return EtherScanBalanceModel( 37 | status: 'empty', 38 | message: '', 39 | result: [], 40 | ); 41 | } 42 | 43 | factory EtherScanBalanceModel.fromMap(Map map) { 44 | return EtherScanBalanceModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: List.from( 48 | map['result']?.map((x) => EtherScanBalanceResult.fromMap(x))), 49 | ); 50 | } 51 | 52 | String toJson() => json.encode(toMap()); 53 | 54 | factory EtherScanBalanceModel.fromJson(String source) => 55 | EtherScanBalanceModel.fromMap(json.decode(source)); 56 | @override 57 | bool? get stringify => true; 58 | 59 | @override 60 | List get props => [status, message, result ?? []]; 61 | } 62 | 63 | class EtherScanBalanceResult with EquatableMixin { 64 | final String account; 65 | final String balance; 66 | EtherScanBalanceResult({ 67 | required this.account, 68 | required this.balance, 69 | }); 70 | 71 | EtherScanBalanceResult copyWith({ 72 | String? account, 73 | String? balance, 74 | }) { 75 | return EtherScanBalanceResult( 76 | account: account ?? this.account, 77 | balance: balance ?? this.balance, 78 | ); 79 | } 80 | 81 | Map toMap() { 82 | return { 83 | 'account': account, 84 | 'balance': balance, 85 | }; 86 | } 87 | 88 | factory EtherScanBalanceResult.fromMap(Map map) { 89 | return EtherScanBalanceResult( 90 | account: map['account'], 91 | balance: map['balance'], 92 | ); 93 | } 94 | 95 | String toJson() => json.encode(toMap()); 96 | 97 | factory EtherScanBalanceResult.fromJson(String source) => 98 | EtherScanBalanceResult.fromMap(json.decode(source)); 99 | 100 | @override 101 | bool? get stringify => true; 102 | 103 | @override 104 | List get props => [account, balance]; 105 | } 106 | -------------------------------------------------------------------------------- /lib/src/models/transaction/tx_status.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanTxStatusModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final EtherScanTxStatusResult result; 9 | EtherScanTxStatusModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanTxStatusModel copyWith({ 16 | String? status, 17 | String? message, 18 | EtherScanTxStatusResult? result, 19 | }) { 20 | return EtherScanTxStatusModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result.toMap(), 32 | }; 33 | } 34 | 35 | factory EtherScanTxStatusModel.empty() { 36 | return EtherScanTxStatusModel( 37 | status: 'empty', 38 | message: '', 39 | result: EtherScanTxStatusResult.empty(), 40 | ); 41 | } 42 | 43 | factory EtherScanTxStatusModel.fromMap(Map map) { 44 | return EtherScanTxStatusModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: EtherScanTxStatusResult.fromMap(map['result']), 48 | ); 49 | } 50 | 51 | String toJson() => json.encode(toMap()); 52 | 53 | factory EtherScanTxStatusModel.fromJson(String source) => 54 | EtherScanTxStatusModel.fromMap(json.decode(source)); 55 | 56 | @override 57 | bool? get stringify => true; 58 | 59 | @override 60 | List get props => [status, message, result]; 61 | } 62 | 63 | class EtherScanTxStatusResult with EquatableMixin { 64 | final String isError; 65 | final String errDescription; 66 | EtherScanTxStatusResult({ 67 | required this.isError, 68 | required this.errDescription, 69 | }); 70 | 71 | EtherScanTxStatusResult copyWith({ 72 | String? isError, 73 | String? errDescription, 74 | }) { 75 | return EtherScanTxStatusResult( 76 | isError: isError ?? this.isError, 77 | errDescription: errDescription ?? this.errDescription, 78 | ); 79 | } 80 | 81 | Map toMap() { 82 | return { 83 | 'isError': isError, 84 | 'errDescription': errDescription, 85 | }; 86 | } 87 | 88 | factory EtherScanTxStatusResult.empty() { 89 | return EtherScanTxStatusResult( 90 | isError: '', 91 | errDescription: '', 92 | ); 93 | } 94 | 95 | factory EtherScanTxStatusResult.fromMap(Map map) { 96 | return EtherScanTxStatusResult( 97 | isError: map['isError'], 98 | errDescription: map['errDescription'], 99 | ); 100 | } 101 | 102 | String toJson() => json.encode(toMap()); 103 | 104 | factory EtherScanTxStatusResult.fromJson(String source) => 105 | EtherScanTxStatusResult.fromMap(json.decode(source)); 106 | 107 | @override 108 | bool? get stringify => true; 109 | 110 | @override 111 | List get props => [isError, errDescription]; 112 | } 113 | -------------------------------------------------------------------------------- /lib/src/models/account/minted_blocks_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanMintedBlocksModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final List? result; 9 | EtherScanMintedBlocksModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanMintedBlocksModel copyWith({ 16 | String? status, 17 | String? message, 18 | List? result, 19 | }) { 20 | return EtherScanMintedBlocksModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result?.map((x) => x.toMap()).toList(), 32 | }; 33 | } 34 | 35 | factory EtherScanMintedBlocksModel.empty() { 36 | return EtherScanMintedBlocksModel( 37 | status: 'empty', 38 | message: '', 39 | result: [], 40 | ); 41 | } 42 | 43 | factory EtherScanMintedBlocksModel.fromMap(Map map) { 44 | return EtherScanMintedBlocksModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: List.from( 48 | map['result']?.map((x) => EtherScanMintedBlocksResult.fromMap(x))), 49 | ); 50 | } 51 | 52 | String toJson() => json.encode(toMap()); 53 | 54 | factory EtherScanMintedBlocksModel.fromJson(String source) => 55 | EtherScanMintedBlocksModel.fromMap(json.decode(source)); 56 | 57 | @override 58 | bool? get stringify => true; 59 | 60 | @override 61 | List get props => [status, message, result ?? []]; 62 | } 63 | 64 | class EtherScanMintedBlocksResult with EquatableMixin { 65 | final String blockNumber; 66 | final String timeStamp; 67 | final String blockReward; 68 | EtherScanMintedBlocksResult({ 69 | required this.blockNumber, 70 | required this.timeStamp, 71 | required this.blockReward, 72 | }); 73 | 74 | EtherScanMintedBlocksResult copyWith({ 75 | String? blockNumber, 76 | String? timeStamp, 77 | String? blockReward, 78 | }) { 79 | return EtherScanMintedBlocksResult( 80 | blockNumber: blockNumber ?? this.blockNumber, 81 | timeStamp: timeStamp ?? this.timeStamp, 82 | blockReward: blockReward ?? this.blockReward, 83 | ); 84 | } 85 | 86 | Map toMap() { 87 | return { 88 | 'blockNumber': blockNumber, 89 | 'timeStamp': timeStamp, 90 | 'blockReward': blockReward, 91 | }; 92 | } 93 | 94 | factory EtherScanMintedBlocksResult.fromMap(Map map) { 95 | return EtherScanMintedBlocksResult( 96 | blockNumber: map['blockNumber'], 97 | timeStamp: map['timeStamp'], 98 | blockReward: map['blockReward'], 99 | ); 100 | } 101 | 102 | String toJson() => json.encode(toMap()); 103 | 104 | factory EtherScanMintedBlocksResult.fromJson(String source) => 105 | EtherScanMintedBlocksResult.fromMap(json.decode(source)); 106 | 107 | @override 108 | bool? get stringify => true; 109 | 110 | @override 111 | List get props => [blockNumber, timeStamp, blockReward]; 112 | } 113 | -------------------------------------------------------------------------------- /docs/api/__404error.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | etherscan_api - Dart API docs 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
25 | 26 |
27 | 28 | 31 |
etherscan_api
32 | 35 |
36 | 37 |
38 | 39 | 56 | 57 |
58 |

404: Something's gone wrong :-(

59 | 60 |
61 |

You've tried to visit a page that doesn't exist. Luckily this site 62 | has other pages.

63 |

If you were looking for something specific, try searching: 64 |

67 |

68 | 69 |
70 |
71 | 72 | 74 | 75 |
76 | 77 |
78 | 79 | etherscan_api 80 | 1.0.0-beta 81 | 82 | 83 |
84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /lib/src/models/stats/eth_price_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanPriceModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final EtherScanPriceResult result; 9 | 10 | EtherScanPriceModel({ 11 | required this.status, 12 | required this.message, 13 | required this.result, 14 | }); 15 | 16 | EtherScanPriceModel copyWith({ 17 | String? status, 18 | String? message, 19 | EtherScanPriceResult? result, 20 | }) { 21 | return EtherScanPriceModel( 22 | status: status ?? this.status, 23 | message: message ?? this.message, 24 | result: result ?? this.result, 25 | ); 26 | } 27 | 28 | Map toMap() { 29 | return { 30 | 'status': status, 31 | 'message': message, 32 | 'result': result.toMap(), 33 | }; 34 | } 35 | 36 | factory EtherScanPriceModel.empty() { 37 | return EtherScanPriceModel( 38 | status: 'empty', 39 | message: '', 40 | result: EtherScanPriceResult.empty(), 41 | ); 42 | } 43 | 44 | factory EtherScanPriceModel.fromMap(Map map) { 45 | return EtherScanPriceModel( 46 | status: map['status'], 47 | message: map['message'], 48 | result: EtherScanPriceResult.fromMap(map['result']), 49 | ); 50 | } 51 | 52 | String toJson() => json.encode(toMap()); 53 | 54 | factory EtherScanPriceModel.fromJson(String source) => 55 | EtherScanPriceModel.fromMap(json.decode(source)); 56 | 57 | @override 58 | bool get stringify => true; 59 | 60 | @override 61 | List get props => [status, message, result]; 62 | } 63 | 64 | class EtherScanPriceResult with EquatableMixin { 65 | final String ethbtc; 66 | final String ethbtc_timestamp; 67 | final String ethusd; 68 | final String ethusd_timestamp; 69 | 70 | EtherScanPriceResult({ 71 | required this.ethbtc, 72 | required this.ethbtc_timestamp, 73 | required this.ethusd, 74 | required this.ethusd_timestamp, 75 | }); 76 | 77 | EtherScanPriceResult copyWith({ 78 | String? ethbtc, 79 | String? ethbtc_timestamp, 80 | String? ethusd, 81 | String? ethusd_timestamp, 82 | }) { 83 | return EtherScanPriceResult( 84 | ethbtc: ethbtc ?? this.ethbtc, 85 | ethbtc_timestamp: ethbtc_timestamp ?? this.ethbtc_timestamp, 86 | ethusd: ethusd ?? this.ethusd, 87 | ethusd_timestamp: ethusd_timestamp ?? this.ethusd_timestamp, 88 | ); 89 | } 90 | 91 | Map toMap() { 92 | return { 93 | 'ethbtc': ethbtc, 94 | 'ethbtc_timestamp': ethbtc_timestamp, 95 | 'ethusd': ethusd, 96 | 'ethusd_timestamp': ethusd_timestamp, 97 | }; 98 | } 99 | 100 | factory EtherScanPriceResult.empty() { 101 | return EtherScanPriceResult( 102 | ethbtc: '', 103 | ethbtc_timestamp: '', 104 | ethusd: '', 105 | ethusd_timestamp: '', 106 | ); 107 | } 108 | 109 | factory EtherScanPriceResult.fromMap(Map map) { 110 | return EtherScanPriceResult( 111 | ethbtc: map['ethbtc'], 112 | ethbtc_timestamp: map['ethbtc_timestamp'], 113 | ethusd: map['ethusd'], 114 | ethusd_timestamp: map['ethusd_timestamp'], 115 | ); 116 | } 117 | 118 | String toJson() => json.encode(toMap()); 119 | 120 | factory EtherScanPriceResult.fromJson(String source) => 121 | EtherScanPriceResult.fromMap(json.decode(source)); 122 | 123 | @override 124 | bool get stringify => true; 125 | 126 | @override 127 | List get props => [ 128 | ethbtc, 129 | ethbtc_timestamp, 130 | ethusd, 131 | ethusd_timestamp, 132 | ]; 133 | } 134 | -------------------------------------------------------------------------------- /lib/src/models/stats/block_reward_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanBlockRewardModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final EtherScanBlockRewardResult result; 9 | EtherScanBlockRewardModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanBlockRewardModel copyWith({ 16 | String? status, 17 | String? message, 18 | EtherScanBlockRewardResult? result, 19 | }) { 20 | return EtherScanBlockRewardModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result.toMap(), 32 | }; 33 | } 34 | 35 | factory EtherScanBlockRewardModel.empty() { 36 | return EtherScanBlockRewardModel( 37 | status: 'empty', 38 | message: '', 39 | result: EtherScanBlockRewardResult.empty(), 40 | ); 41 | } 42 | 43 | factory EtherScanBlockRewardModel.fromMap(Map map) { 44 | return EtherScanBlockRewardModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: EtherScanBlockRewardResult.fromMap(map['result']), 48 | ); 49 | } 50 | 51 | String toJson() => json.encode(toMap()); 52 | 53 | factory EtherScanBlockRewardModel.fromJson(String source) => 54 | EtherScanBlockRewardModel.fromMap(json.decode(source)); 55 | 56 | @override 57 | bool? get stringify => true; 58 | 59 | @override 60 | List get props => [status, message, result]; 61 | } 62 | 63 | class EtherScanBlockRewardResult with EquatableMixin { 64 | final String blockNumber; 65 | final String timeStamp; 66 | final String blockMiner; 67 | final String blockReward; 68 | final List uncles; 69 | final String uncleInclusionReward; 70 | EtherScanBlockRewardResult({ 71 | required this.blockNumber, 72 | required this.timeStamp, 73 | required this.blockMiner, 74 | required this.blockReward, 75 | required this.uncles, 76 | required this.uncleInclusionReward, 77 | }); 78 | 79 | EtherScanBlockRewardResult copyWith({ 80 | String? blockNumber, 81 | String? timeStamp, 82 | String? blockMiner, 83 | String? blockReward, 84 | List? uncles, 85 | String? uncleInclusionReward, 86 | }) { 87 | return EtherScanBlockRewardResult( 88 | blockNumber: blockNumber ?? this.blockNumber, 89 | timeStamp: timeStamp ?? this.timeStamp, 90 | blockMiner: blockMiner ?? this.blockMiner, 91 | blockReward: blockReward ?? this.blockReward, 92 | uncles: uncles ?? this.uncles, 93 | uncleInclusionReward: uncleInclusionReward ?? this.uncleInclusionReward, 94 | ); 95 | } 96 | 97 | Map toMap() { 98 | return { 99 | 'blockNumber': blockNumber, 100 | 'timeStamp': timeStamp, 101 | 'blockMiner': blockMiner, 102 | 'blockReward': blockReward, 103 | 'uncles': uncles, 104 | 'uncleInclusionReward': uncleInclusionReward, 105 | }; 106 | } 107 | 108 | factory EtherScanBlockRewardResult.empty() { 109 | return EtherScanBlockRewardResult( 110 | blockNumber: '', 111 | timeStamp: '', 112 | blockMiner: '', 113 | blockReward: '', 114 | uncles: [], 115 | uncleInclusionReward: '', 116 | ); 117 | } 118 | 119 | factory EtherScanBlockRewardResult.fromMap(Map map) { 120 | return EtherScanBlockRewardResult( 121 | blockNumber: map['blockNumber'], 122 | timeStamp: map['timeStamp'], 123 | blockMiner: map['blockMiner'], 124 | blockReward: map['blockReward'], 125 | uncles: List.from(map['uncles']), 126 | uncleInclusionReward: map['uncleInclusionReward'], 127 | ); 128 | } 129 | 130 | String toJson() => json.encode(toMap()); 131 | 132 | factory EtherScanBlockRewardResult.fromJson(String source) => 133 | EtherScanBlockRewardResult.fromMap(json.decode(source)); 134 | 135 | @override 136 | bool? get stringify => true; 137 | 138 | @override 139 | List get props { 140 | return [ 141 | blockNumber, 142 | timeStamp, 143 | blockMiner, 144 | blockReward, 145 | uncles, 146 | uncleInclusionReward, 147 | ]; 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/DescribeEnum/str.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | str property - DescribeEnum extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
str
34 | 37 |
38 | 39 |
40 | 41 | 72 | 73 |
74 |

str property Null safety 75 |

76 | 77 | 78 |
79 | 80 |
81 | String 82 | str 83 | 84 |
85 | 86 |
87 |

Implementation

88 |
String get str => describeEnum(this);
89 |
90 |
91 | 92 |
93 | 94 | 96 | 97 |
98 | 99 |
100 | 101 | etherscan_api 102 | 1.0.0-beta 103 | 104 | 105 |
106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthChainString/chainName.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | chainName property - EthChainString extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
chainName
34 | 37 |
38 | 39 |
40 | 41 | 73 | 74 |
75 |

chainName property Null safety 76 |

77 | 78 | 79 |
80 | 81 |
82 | String 83 | chainName 84 | 85 |
86 | 87 |
88 |

Implementation

89 |
String get chainName => str;
90 |
91 |
92 | 93 |
94 | 95 | 97 | 98 |
99 | 100 |
101 | 102 | etherscan_api 103 | 1.0.0-beta 104 | 105 | 106 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthChainString/chainApiUrl.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | chainApiUrl property - EthChainString extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
chainApiUrl
34 | 37 |
38 | 39 |
40 | 41 | 73 | 74 |
75 |

chainApiUrl property Null safety 76 |

77 | 78 | 79 |
80 | 81 |
82 | String 83 | chainApiUrl 84 | 85 |
86 | 87 |
88 |

Implementation

89 |
String get chainApiUrl => ETH_API_URLS[chainName]!;
90 |
91 |
92 | 93 |
94 | 95 | 97 | 98 |
99 | 100 |
101 | 102 | etherscan_api 103 | 1.0.0-beta 104 | 105 | 106 |
107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /lib/src/models/log/log_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanLogModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final List? result; 9 | EtherScanLogModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanLogModel copyWith({ 16 | String? status, 17 | String? message, 18 | List? result, 19 | }) { 20 | return EtherScanLogModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result?.map((x) => x.toMap()).toList(), 32 | }; 33 | } 34 | 35 | factory EtherScanLogModel.empty() { 36 | return EtherScanLogModel( 37 | status: 'empty', 38 | message: '', 39 | result: [], 40 | ); 41 | } 42 | 43 | factory EtherScanLogModel.fromMap(Map map) { 44 | return EtherScanLogModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: List.from( 48 | map['result']?.map( 49 | (x) => EtherScanLogResult.fromMap(x), 50 | ), 51 | ), 52 | ); 53 | } 54 | 55 | String toJson() => json.encode(toMap()); 56 | 57 | factory EtherScanLogModel.fromJson(String source) => 58 | EtherScanLogModel.fromMap(json.decode(source)); 59 | 60 | @override 61 | int get hashCode => status.hashCode ^ message.hashCode ^ result.hashCode; 62 | 63 | @override 64 | bool get stringify => true; 65 | 66 | @override 67 | List get props => [status, message, result ?? []]; 68 | } 69 | 70 | class EtherScanLogResult with EquatableMixin { 71 | final String address; 72 | final List? topics; 73 | final String data; 74 | final String blockNumber; 75 | final String timeStamp; 76 | final String gasPrice; 77 | final String gasUsed; 78 | final String logIndex; 79 | final String transactionHash; 80 | final String transactionIndex; 81 | EtherScanLogResult({ 82 | required this.address, 83 | required this.topics, 84 | required this.data, 85 | required this.blockNumber, 86 | required this.timeStamp, 87 | required this.gasPrice, 88 | required this.gasUsed, 89 | required this.logIndex, 90 | required this.transactionHash, 91 | required this.transactionIndex, 92 | }); 93 | 94 | EtherScanLogResult copyWith({ 95 | String? address, 96 | List? topics, 97 | String? data, 98 | String? blockNumber, 99 | String? timeStamp, 100 | String? gasPrice, 101 | String? gasUsed, 102 | String? logIndex, 103 | String? transactionHash, 104 | String? transactionIndex, 105 | }) { 106 | return EtherScanLogResult( 107 | address: address ?? this.address, 108 | topics: topics ?? this.topics, 109 | data: data ?? this.data, 110 | blockNumber: blockNumber ?? this.blockNumber, 111 | timeStamp: timeStamp ?? this.timeStamp, 112 | gasPrice: gasPrice ?? this.gasPrice, 113 | gasUsed: gasUsed ?? this.gasUsed, 114 | logIndex: logIndex ?? this.logIndex, 115 | transactionHash: transactionHash ?? this.transactionHash, 116 | transactionIndex: transactionIndex ?? this.transactionIndex, 117 | ); 118 | } 119 | 120 | Map toMap() { 121 | return { 122 | 'address': address, 123 | 'topics': topics, 124 | 'data': data, 125 | 'blockNumber': blockNumber, 126 | 'timeStamp': timeStamp, 127 | 'gasPrice': gasPrice, 128 | 'gasUsed': gasUsed, 129 | 'logIndex': logIndex, 130 | 'transactionHash': transactionHash, 131 | 'transactionIndex': transactionIndex, 132 | }; 133 | } 134 | 135 | factory EtherScanLogResult.fromMap(Map map) { 136 | return EtherScanLogResult( 137 | address: map['address'], 138 | topics: List.from(map['topics']), 139 | data: map['data'], 140 | blockNumber: map['blockNumber'], 141 | timeStamp: map['timeStamp'], 142 | gasPrice: map['gasPrice'], 143 | gasUsed: map['gasUsed'], 144 | logIndex: map['logIndex'], 145 | transactionHash: map['transactionHash'], 146 | transactionIndex: map['transactionIndex'], 147 | ); 148 | } 149 | 150 | String toJson() => json.encode(toMap()); 151 | 152 | factory EtherScanLogResult.fromJson(String source) => 153 | EtherScanLogResult.fromMap(json.decode(source)); 154 | 155 | @override 156 | bool get stringify => true; 157 | 158 | @override 159 | List get props { 160 | return [ 161 | address, 162 | topics ?? [], 163 | data, 164 | blockNumber, 165 | timeStamp, 166 | gasPrice, 167 | gasUsed, 168 | logIndex, 169 | transactionHash, 170 | transactionIndex, 171 | ]; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /docs/api/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | etherscan_api - Dart API docs 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 23 | 24 |
25 | 26 |
27 | 28 | 31 |
etherscan_api
32 | 35 |
36 | 37 |
38 | 39 | 56 | 57 |
58 |
59 |

Etherscan Dart API

60 |

license 61 | GitHub tag

62 |

GitHub issues

63 |

A dart library to access the etherscan.io apis.

64 |

 65 | import 'package:etherscan_api/etherscan_api.dart';
 66 | 
 67 | final eth = EtherscanAPI(apiKey: 'YourApiKey');
 68 | 
 69 |  final bal = await eth.balance(
 70 |     addresses: [
 71 |       '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae',
 72 |     ],
 73 |   );
 74 |  
 75 |  print(val);
 76 | 
 77 | 
78 |

For testnet usage

79 |

Supported TestNets:

80 |
    81 |
  • morden
  • 82 |
  • ropsten
  • 83 |
  • rinkeby
  • 84 |
85 |

Latest

86 |

 87 | final eth = EtherscanAPI(
 88 |     apiKey: 'YourApiKey', // Api key
 89 |     chain: EthChain.ropsten, // Network/chain
 90 |     enableLogs: true // Enable Logging
 91 |   );
 92 | 
93 |
94 | 95 |
96 |

Libraries

97 |
98 |
99 | etherscan_api 100 |
101 |
102 | 103 |
104 |
105 |
106 | 107 |
108 | 109 | 111 | 112 |
113 | 114 |
115 | 116 | etherscan_api 117 | 1.0.0-beta 118 | 119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthStats/ethPrice.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ethPrice method - EthStats extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
ethPrice
34 | 37 |
38 | 39 |
40 | 41 | 73 | 74 |
75 |

ethPrice method Null safety 76 |

77 | 78 |
79 | Future<EtherScanPriceModel> 80 | ethPrice 81 | () 82 | 83 |
84 |
85 |

Returns the price of ether now

86 |

Example

87 |
var price = eth.ethprice();
 88 | 
89 |
90 | 91 |
92 |

Implementation

93 |
Future<EtherScanPriceModel> ethPrice() async {
 94 |   const module = 'stats';
 95 |   const action = 'ethprice';
 96 | 
 97 |   Map<String, dynamic>? query = {
 98 |     'module': module,
 99 |     'action': action,
100 |     'apiKey': apiKey,
101 |   };
102 | 
103 |   return (await get(query)).fold(
104 |     (l) => EtherScanPriceModel.empty(),
105 |     (r) => EtherScanPriceModel.fromJson(r),
106 |   );
107 | }
108 |
109 | 110 |
111 | 112 | 114 | 115 |
116 | 117 |
118 | 119 | etherscan_api 120 | 1.0.0-beta 121 | 122 | 123 |
124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthStats/ethSupply.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | ethSupply method - EthStats extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
ethSupply
34 | 37 |
38 | 39 |
40 | 41 | 73 | 74 |
75 |

ethSupply method Null safety 76 |

77 | 78 |
79 | Future<EtherScanSupplyModel> 80 | ethSupply 81 | () 82 | 83 |
84 |
85 |

Returns total supply of ether

86 |

Example

87 |
var supply = eth.ethSupply();
 88 | 
89 |
90 | 91 |
92 |

Implementation

93 |
Future<EtherScanSupplyModel> ethSupply() async {
 94 |   const module = 'stats';
 95 |   const action = 'ethsupply';
 96 | 
 97 |   Map<String, dynamic>? query = {
 98 |     'module': module,
 99 |     'action': action,
100 |     'apiKey': apiKey,
101 |   };
102 | 
103 |   return (await get(query)).fold(
104 |     (l) => EtherScanSupplyModel.empty(),
105 |     (r) => EtherScanSupplyModel.fromJson(r),
106 |   );
107 | }
108 |
109 | 110 |
111 | 112 | 114 | 115 |
116 | 117 |
118 | 119 | etherscan_api 120 | 1.0.0-beta 121 | 122 | 123 |
124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthTransaction/getStatus.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | getStatus method - EthTransaction extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
getStatus
34 | 37 |
38 | 39 |
40 | 41 | 71 | 72 |
73 |

getStatus method Null safety 74 |

75 | 76 |
77 | Future<EtherScanTxStatusModel> 78 | getStatus 79 | (
  1. {required String? txhash}
  2. 80 |
) 81 | 82 |
83 |
84 |

Returns the status of a specific transaction hash

85 |

txhash - Transaction hash

86 |
87 | 88 |
89 |

Implementation

90 |
Future<EtherScanTxStatusModel> getStatus({
 91 |   required String? txhash,
 92 | }) async {
 93 |   const module = 'transaction';
 94 |   const action = 'getstatus';
 95 | 
 96 |   Map<String, dynamic>? query = {
 97 |     'txhash': txhash,
 98 |     'module': module,
 99 |     'action': action,
100 |     'apiKey': apiKey,
101 |   };
102 | 
103 |   return (await get(query)).fold(
104 |     (l) => EtherScanTxStatusModel.empty(),
105 |     (r) => EtherScanTxStatusModel.fromJson(r),
106 |   );
107 | }
108 |
109 | 110 |
111 | 112 | 114 | 115 |
116 | 117 |
118 | 119 | etherscan_api 120 | 1.0.0-beta 121 | 122 | 123 |
124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /lib/src/models/account/tx_list_internal_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanTxInternalModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final List? result; 9 | EtherScanTxInternalModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherScanTxInternalModel copyWith({ 16 | String? status, 17 | String? message, 18 | List? result, 19 | }) { 20 | return EtherScanTxInternalModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result?.map((x) => x.toMap()).toList(), 32 | }; 33 | } 34 | 35 | factory EtherScanTxInternalModel.empty() { 36 | return EtherScanTxInternalModel( 37 | status: 'empty', 38 | message: '', 39 | result: [], 40 | ); 41 | } 42 | 43 | factory EtherScanTxInternalModel.fromMap(Map map) { 44 | return EtherScanTxInternalModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: List.from( 48 | map['result']?.map( 49 | (x) => EtherScanTxInternalResult.fromMap(x), 50 | ), 51 | ), 52 | ); 53 | } 54 | 55 | String toJson() => json.encode(toMap()); 56 | 57 | factory EtherScanTxInternalModel.fromJson(String source) => 58 | EtherScanTxInternalModel.fromMap(json.decode(source)); 59 | 60 | @override 61 | bool? get stringify => true; 62 | 63 | @override 64 | List get props => [status, message, result ?? []]; 65 | } 66 | 67 | class EtherScanTxInternalResult with EquatableMixin { 68 | final String blockNumber; 69 | final String timeStamp; 70 | final String hash; 71 | final String from; 72 | final String to; 73 | final String value; 74 | final String contractAddress; 75 | final String input; 76 | final String type; 77 | final String gas; 78 | final String gasUsed; 79 | final String traceId; 80 | final String isError; 81 | final String errCode; 82 | EtherScanTxInternalResult({ 83 | required this.blockNumber, 84 | required this.timeStamp, 85 | required this.hash, 86 | required this.from, 87 | required this.to, 88 | required this.value, 89 | required this.contractAddress, 90 | required this.input, 91 | required this.type, 92 | required this.gas, 93 | required this.gasUsed, 94 | required this.traceId, 95 | required this.isError, 96 | required this.errCode, 97 | }); 98 | 99 | EtherScanTxInternalResult copyWith({ 100 | String? blockNumber, 101 | String? timeStamp, 102 | String? hash, 103 | String? from, 104 | String? to, 105 | String? value, 106 | String? contractAddress, 107 | String? input, 108 | String? type, 109 | String? gas, 110 | String? gasUsed, 111 | String? traceId, 112 | String? isError, 113 | String? errCode, 114 | }) { 115 | return EtherScanTxInternalResult( 116 | blockNumber: blockNumber ?? this.blockNumber, 117 | timeStamp: timeStamp ?? this.timeStamp, 118 | hash: hash ?? this.hash, 119 | from: from ?? this.from, 120 | to: to ?? this.to, 121 | value: value ?? this.value, 122 | contractAddress: contractAddress ?? this.contractAddress, 123 | input: input ?? this.input, 124 | type: type ?? this.type, 125 | gas: gas ?? this.gas, 126 | gasUsed: gasUsed ?? this.gasUsed, 127 | traceId: traceId ?? this.traceId, 128 | isError: isError ?? this.isError, 129 | errCode: errCode ?? this.errCode, 130 | ); 131 | } 132 | 133 | Map toMap() { 134 | return { 135 | 'blockNumber': blockNumber, 136 | 'timeStamp': timeStamp, 137 | 'hash': hash, 138 | 'from': from, 139 | 'to': to, 140 | 'value': value, 141 | 'contractAddress': contractAddress, 142 | 'input': input, 143 | 'type': type, 144 | 'gas': gas, 145 | 'gasUsed': gasUsed, 146 | 'traceId': traceId, 147 | 'isError': isError, 148 | 'errCode': errCode, 149 | }; 150 | } 151 | 152 | factory EtherScanTxInternalResult.fromMap(Map map) { 153 | return EtherScanTxInternalResult( 154 | blockNumber: map['blockNumber'], 155 | timeStamp: map['timeStamp'], 156 | hash: map['hash'], 157 | from: map['from'], 158 | to: map['to'], 159 | value: map['value'], 160 | contractAddress: map['contractAddress'], 161 | input: map['input'], 162 | type: map['type'], 163 | gas: map['gas'], 164 | gasUsed: map['gasUsed'], 165 | traceId: map['traceId'], 166 | isError: map['isError'], 167 | errCode: map['errCode'], 168 | ); 169 | } 170 | 171 | String toJson() => json.encode(toMap()); 172 | 173 | factory EtherScanTxInternalResult.fromJson(String source) => 174 | EtherScanTxInternalResult.fromMap(json.decode(source)); 175 | 176 | @override 177 | bool? get stringify => true; 178 | 179 | @override 180 | List get props { 181 | return [ 182 | blockNumber, 183 | timeStamp, 184 | hash, 185 | from, 186 | to, 187 | value, 188 | contractAddress, 189 | input, 190 | type, 191 | gas, 192 | gasUsed, 193 | traceId, 194 | isError, 195 | errCode, 196 | ]; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthContract/getAbi.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | getAbi method - EthContract extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
getAbi
34 | 37 |
38 | 39 |
40 | 41 | 72 | 73 |
74 |

getAbi method Null safety 75 |

76 | 77 |
78 | Future<EtherScanAbiModel> 79 | getAbi 80 | (
  1. {required String? address}
  2. 81 |
) 82 | 83 |
84 |
85 |

Returns the ABI/Interface of a given contract

86 |

address - Contract address

87 |

Example

88 |
api.contract
 89 |  ..getAbi('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
 90 |  ..at('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
 91 |  ..memberId('0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359')
 92 | 
93 |
94 | 95 |
96 |

Implementation

97 |
Future<EtherScanAbiModel> getAbi({
 98 |   required String? address,
 99 | }) async {
100 |   const module = 'contract';
101 |   const action = 'getabi';
102 | 
103 |   var query = {
104 |     'module': module,
105 |     'action': action,
106 |     'address': address,
107 |     'apiKey': apiKey
108 |   };
109 | 
110 |   return (await get(query)).fold(
111 |     (l) => EtherScanAbiModel.empty(),
112 |     (r) => EtherScanAbiModel.fromJson(r),
113 |   );
114 | }
115 |
116 | 117 |
118 | 119 | 121 | 122 |
123 | 124 |
125 | 126 | etherscan_api 127 | 1.0.0-beta 128 | 129 | 130 |
131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthContract/getSourceCode.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | getSourceCode method - EthContract extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
getSourceCode
34 | 37 |
38 | 39 |
40 | 41 | 72 | 73 |
74 |

getSourceCode method Null safety 75 |

76 | 77 |
78 | Future<EtherscanSourceCodeModel> 79 | getSourceCode 80 | (
  1. {required String? address}
  2. 81 |
) 82 | 83 |
84 |
85 |

Get Contract Source Code for Verified Contract Source Codes

86 |

address - Contract address

87 |

Example

88 |
api.contract.getSourceCode(
 89 |     address: '0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359'
 90 | )
 91 | 
92 |
93 | 94 |
95 |

Implementation

96 |
Future<EtherscanSourceCodeModel> getSourceCode({
 97 |   required String? address,
 98 | }) async {
 99 |   const module = 'contract';
100 |   const action = 'getsourcecode';
101 | 
102 |   var query = {
103 |     'module': module,
104 |     'action': action,
105 |     'address': address,
106 |     'apiKey': apiKey
107 |   };
108 | 
109 |   return (await get(query)).fold(
110 |     (l) => EtherscanSourceCodeModel.empty(),
111 |     (r) => EtherscanSourceCodeModel.fromJson(r),
112 |   );
113 | }
114 |
115 | 116 |
117 | 118 | 120 | 121 |
122 | 123 |
124 | 125 | etherscan_api 126 | 1.0.0-beta 127 | 128 | 129 |
130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherscanAPI/chain.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | chain property - EtherscanAPI class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
chain
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

chain property Null safety 88 |

89 | 90 |
91 | EthChain 92 | chain 93 |
final
94 |
95 |
96 |

Implementation

97 |
final EthChain chain;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherscanAPI/apiKey.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | apiKey property - EtherscanAPI class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
apiKey
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

apiKey property Null safety 88 |

89 | 90 |
91 | String 92 | apiKey 93 |
final
94 |
95 |
96 |

Implementation

97 |
final String apiKey;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherscanAPI/timeout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | timeout property - EtherscanAPI class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
timeout
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

timeout property Null safety 88 |

89 | 90 |
91 | Duration? 92 | timeout 93 |
final
94 |
95 |
96 |

Implementation

97 |
final Duration? timeout;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherSort/toString.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | toString method - EtherSort extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
toString
34 | 37 |
38 | 39 |
40 | 41 | 82 | 83 |
84 |

toString method Null safety 85 |

86 | 87 |
88 | String 89 | toString 90 | () 91 |
override
92 |
93 |
94 |

A string representation of this object.

95 |

Some classes have a default textual representation, 96 | often paired with a static parse function (like int.parse). 97 | These classes will provide the textual representation as 98 | their string represetion.

99 |

Other classes have no meaningful textual representation 100 | that a program will care about. 101 | Such classes will typically override toString to provide 102 | useful information when inspecting the object, 103 | mainly for debugging or logging.

104 |
105 | 106 | 107 | 108 |
109 | 110 | 112 | 113 |
114 | 115 |
116 | 117 | etherscan_api 118 | 1.0.0-beta 119 | 120 | 121 |
122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherscanAPI/enableLogs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | enableLogs property - EtherscanAPI class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
enableLogs
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

enableLogs property Null safety 88 |

89 | 90 |
91 | bool 92 | enableLogs 93 |
final
94 |
95 |
96 |

Implementation

97 |
final bool enableLogs;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /lib/src/models/proxy/tx_by_hash_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherScanTxByHashModel with EquatableMixin { 6 | final String jsonrpc; 7 | final int id; 8 | final EtherScanTxByHashModelResult result; 9 | EtherScanTxByHashModel({ 10 | required this.jsonrpc, 11 | required this.id, 12 | required this.result, 13 | }); 14 | 15 | EtherScanTxByHashModel copyWith({ 16 | String? jsonrpc, 17 | int? id, 18 | EtherScanTxByHashModelResult? result, 19 | }) { 20 | return EtherScanTxByHashModel( 21 | jsonrpc: jsonrpc ?? this.jsonrpc, 22 | id: id ?? this.id, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'jsonrpc': jsonrpc, 30 | 'id': id, 31 | 'result': result.toMap(), 32 | }; 33 | } 34 | 35 | factory EtherScanTxByHashModel.empty() { 36 | return EtherScanTxByHashModel( 37 | jsonrpc: '', 38 | id: 0, 39 | result: EtherScanTxByHashModelResult.empty(), 40 | ); 41 | } 42 | 43 | factory EtherScanTxByHashModel.fromMap(Map map) { 44 | return EtherScanTxByHashModel( 45 | jsonrpc: map['jsonrpc'], 46 | id: map['id'], 47 | result: EtherScanTxByHashModelResult.fromMap(map['result']), 48 | ); 49 | } 50 | 51 | String toJson() => json.encode(toMap()); 52 | 53 | factory EtherScanTxByHashModel.fromJson(String source) => 54 | EtherScanTxByHashModel.fromMap(json.decode(source)); 55 | 56 | @override 57 | bool get stringify => true; 58 | 59 | @override 60 | List get props => [jsonrpc, id, result]; 61 | } 62 | 63 | class EtherScanTxByHashModelResult with EquatableMixin { 64 | final String blockHash; 65 | final String blockNumber; 66 | final String from; 67 | final String gas; 68 | final String gasPrice; 69 | final String hash; 70 | final String input; 71 | final String nonce; 72 | final String to; 73 | final String transactionIndex; 74 | final String value; 75 | final String type; 76 | final String v; 77 | final String r; 78 | final String s; 79 | 80 | EtherScanTxByHashModelResult({ 81 | required this.blockHash, 82 | required this.blockNumber, 83 | required this.from, 84 | required this.gas, 85 | required this.gasPrice, 86 | required this.hash, 87 | required this.input, 88 | required this.nonce, 89 | required this.to, 90 | required this.transactionIndex, 91 | required this.value, 92 | required this.type, 93 | required this.v, 94 | required this.r, 95 | required this.s, 96 | }); 97 | 98 | EtherScanTxByHashModelResult copyWith({ 99 | String? blockHash, 100 | String? blockNumber, 101 | String? from, 102 | String? gas, 103 | String? gasPrice, 104 | String? hash, 105 | String? input, 106 | String? nonce, 107 | String? to, 108 | String? transactionIndex, 109 | String? value, 110 | String? type, 111 | String? v, 112 | String? r, 113 | String? s, 114 | }) { 115 | return EtherScanTxByHashModelResult( 116 | blockHash: blockHash ?? this.blockHash, 117 | blockNumber: blockNumber ?? this.blockNumber, 118 | from: from ?? this.from, 119 | gas: gas ?? this.gas, 120 | gasPrice: gasPrice ?? this.gasPrice, 121 | hash: hash ?? this.hash, 122 | input: input ?? this.input, 123 | nonce: nonce ?? this.nonce, 124 | to: to ?? this.to, 125 | transactionIndex: transactionIndex ?? this.transactionIndex, 126 | value: value ?? this.value, 127 | type: type ?? this.type, 128 | v: v ?? this.v, 129 | r: r ?? this.r, 130 | s: s ?? this.s, 131 | ); 132 | } 133 | 134 | Map toMap() { 135 | return { 136 | 'blockHash': blockHash, 137 | 'blockNumber': blockNumber, 138 | 'from': from, 139 | 'gas': gas, 140 | 'gasPrice': gasPrice, 141 | 'hash': hash, 142 | 'input': input, 143 | 'nonce': nonce, 144 | 'to': to, 145 | 'transactionIndex': transactionIndex, 146 | 'value': value, 147 | 'type': type, 148 | 'v': v, 149 | 'r': r, 150 | 's': s, 151 | }; 152 | } 153 | 154 | factory EtherScanTxByHashModelResult.empty() { 155 | return EtherScanTxByHashModelResult( 156 | blockHash: '', 157 | blockNumber: '', 158 | from: '', 159 | gas: '', 160 | gasPrice: '', 161 | hash: '', 162 | input: '', 163 | nonce: '', 164 | to: '', 165 | transactionIndex: '', 166 | value: '', 167 | type: '', 168 | v: '', 169 | r: '', 170 | s: '', 171 | ); 172 | } 173 | 174 | factory EtherScanTxByHashModelResult.fromMap(Map map) { 175 | return EtherScanTxByHashModelResult( 176 | blockHash: map['blockHash'], 177 | blockNumber: map['blockNumber'], 178 | from: map['from'], 179 | gas: map['gas'], 180 | gasPrice: map['gasPrice'], 181 | hash: map['hash'], 182 | input: map['input'], 183 | nonce: map['nonce'], 184 | to: map['to'], 185 | transactionIndex: map['transactionIndex'], 186 | value: map['value'], 187 | type: map['type'], 188 | v: map['v'], 189 | r: map['r'], 190 | s: map['s'], 191 | ); 192 | } 193 | 194 | String toJson() => json.encode(toMap()); 195 | 196 | factory EtherScanTxByHashModelResult.fromJson(String source) => 197 | EtherScanTxByHashModelResult.fromMap(json.decode(source)); 198 | 199 | @override 200 | bool get stringify => true; 201 | 202 | @override 203 | List get props { 204 | return [ 205 | blockHash, 206 | blockNumber, 207 | from, 208 | gas, 209 | gasPrice, 210 | hash, 211 | input, 212 | nonce, 213 | to, 214 | transactionIndex, 215 | value, 216 | type, 217 | v, 218 | r, 219 | s, 220 | ]; 221 | } 222 | } 223 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherScanFailure/code.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | code property - EtherScanFailure class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
code
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

code property Null safety 88 |

89 | 90 |
91 | int 92 | code 93 |
final
94 |
95 |
96 |

Implementation

97 |
final int code;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthChain/toString.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | toString method - EthChain extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
toString
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

toString method Null safety 88 |

89 | 90 |
91 | String 92 | toString 93 | () 94 |
override
95 |
96 |
97 |

A string representation of this object.

98 |

Some classes have a default textual representation, 99 | often paired with a static parse function (like int.parse). 100 | These classes will provide the textual representation as 101 | their string represetion.

102 |

Other classes have no meaningful textual representation 103 | that a program will care about. 104 | Such classes will typically override toString to provide 105 | useful information when inspecting the object, 106 | mainly for debugging or logging.

107 |
108 | 109 | 110 | 111 |
112 | 113 | 115 | 116 |
117 | 118 |
119 | 120 | etherscan_api 121 | 1.0.0-beta 122 | 123 | 124 |
125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /lib/src/models/contract/source_code_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:equatable/equatable.dart'; 4 | 5 | class EtherscanSourceCodeModel with EquatableMixin { 6 | final String status; 7 | final String message; 8 | final List? result; 9 | EtherscanSourceCodeModel({ 10 | required this.status, 11 | required this.message, 12 | required this.result, 13 | }); 14 | 15 | EtherscanSourceCodeModel copyWith({ 16 | String? status, 17 | String? message, 18 | List? result, 19 | }) { 20 | return EtherscanSourceCodeModel( 21 | status: status ?? this.status, 22 | message: message ?? this.message, 23 | result: result ?? this.result, 24 | ); 25 | } 26 | 27 | Map toMap() { 28 | return { 29 | 'status': status, 30 | 'message': message, 31 | 'result': result?.map((x) => x?.toMap()).toList(), 32 | }; 33 | } 34 | 35 | factory EtherscanSourceCodeModel.empty() { 36 | return EtherscanSourceCodeModel( 37 | status: 'empty', 38 | message: '', 39 | result: [], 40 | ); 41 | } 42 | 43 | factory EtherscanSourceCodeModel.fromMap(Map map) { 44 | return EtherscanSourceCodeModel( 45 | status: map['status'], 46 | message: map['message'], 47 | result: List.from( 48 | map['result']?.map( 49 | (x) => EtherscanSourceCodeResult.fromMap(x), 50 | ), 51 | ), 52 | ); 53 | } 54 | 55 | String toJson() => json.encode(toMap()); 56 | 57 | factory EtherscanSourceCodeModel.fromJson(String source) => 58 | EtherscanSourceCodeModel.fromMap(json.decode(source)); 59 | 60 | @override 61 | List get props => [status, message, result ?? []]; 62 | 63 | @override 64 | bool get stringify => true; 65 | } 66 | 67 | class EtherscanSourceCodeResult with EquatableMixin { 68 | final String sourceCode; 69 | final String abi; 70 | final String contractName; 71 | final String compilerVersion; 72 | final String optimizationUsed; 73 | final String runs; 74 | final String constructorArguments; 75 | final String evmVersion; 76 | final String library; 77 | final String licenseType; 78 | final String proxy; 79 | final String implementation; 80 | final String swarmSource; 81 | 82 | EtherscanSourceCodeResult({ 83 | required this.sourceCode, 84 | required this.abi, 85 | required this.contractName, 86 | required this.compilerVersion, 87 | required this.optimizationUsed, 88 | required this.runs, 89 | required this.constructorArguments, 90 | required this.evmVersion, 91 | required this.library, 92 | required this.licenseType, 93 | required this.proxy, 94 | required this.implementation, 95 | required this.swarmSource, 96 | }); 97 | 98 | EtherscanSourceCodeResult copyWith({ 99 | String? sourceCode, 100 | String? abi, 101 | String? contractName, 102 | String? compilerVersion, 103 | String? optimizationUsed, 104 | String? runs, 105 | String? constructorArguments, 106 | String? evmVersion, 107 | String? library, 108 | String? licenseType, 109 | String? proxy, 110 | String? implementation, 111 | String? swarmSource, 112 | }) { 113 | return EtherscanSourceCodeResult( 114 | sourceCode: sourceCode ?? this.sourceCode, 115 | abi: abi ?? this.abi, 116 | contractName: contractName ?? this.contractName, 117 | compilerVersion: compilerVersion ?? this.compilerVersion, 118 | optimizationUsed: optimizationUsed ?? this.optimizationUsed, 119 | runs: runs ?? this.runs, 120 | constructorArguments: constructorArguments ?? this.constructorArguments, 121 | evmVersion: evmVersion ?? this.evmVersion, 122 | library: library ?? this.library, 123 | licenseType: licenseType ?? this.licenseType, 124 | proxy: proxy ?? this.proxy, 125 | implementation: implementation ?? this.implementation, 126 | swarmSource: swarmSource ?? this.swarmSource, 127 | ); 128 | } 129 | 130 | Map toMap() { 131 | return { 132 | 'SourceCode': sourceCode, 133 | 'ABI': abi, 134 | 'ContractName': contractName, 135 | 'CompilerVersion': compilerVersion, 136 | 'OptimizationUsed': optimizationUsed, 137 | 'Runs': runs, 138 | 'ConstructorArguments': constructorArguments, 139 | 'EVMVersion': evmVersion, 140 | 'Library': library, 141 | 'LicenseType': licenseType, 142 | 'Proxy': proxy, 143 | 'Implementation': implementation, 144 | 'SwarmSource': swarmSource, 145 | }; 146 | } 147 | 148 | factory EtherscanSourceCodeResult.fromMap(Map map) { 149 | return EtherscanSourceCodeResult( 150 | sourceCode: map['SourceCode'], 151 | abi: map['ABI'], 152 | contractName: map['ContractName'], 153 | compilerVersion: map['CompilerVersion'], 154 | optimizationUsed: map['OptimizationUsed'], 155 | runs: map['Runs'], 156 | constructorArguments: map['ConstructorArguments'], 157 | evmVersion: map['EVMVersion'], 158 | library: map['Library'], 159 | licenseType: map['LicenseType'], 160 | proxy: map['Proxy'], 161 | implementation: map['Implementation'], 162 | swarmSource: map['SwarmSource'], 163 | ); 164 | } 165 | 166 | String toJson() => json.encode(toMap()); 167 | 168 | factory EtherscanSourceCodeResult.fromJson(String source) => 169 | EtherscanSourceCodeResult.fromMap(json.decode(source)); 170 | 171 | @override 172 | bool get stringify => true; 173 | 174 | @override 175 | List get props { 176 | return [ 177 | sourceCode, 178 | abi, 179 | contractName, 180 | compilerVersion, 181 | optimizationUsed, 182 | runs, 183 | constructorArguments, 184 | evmVersion, 185 | library, 186 | licenseType, 187 | proxy, 188 | implementation, 189 | swarmSource, 190 | ]; 191 | } 192 | } 193 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherScanFailure/message.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | message property - EtherScanFailure class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
message
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

message property Null safety 88 |

89 | 90 |
91 | String 92 | message 93 |
final
94 |
95 |
96 |

Implementation

97 |
final String message;
 98 | 
 99 | 
100 |
101 | 102 |
103 | 104 | 106 | 107 |
108 | 109 |
110 | 111 | etherscan_api 112 | 1.0.0-beta 113 | 114 | 115 |
116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthBlock/getBlockReward.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | getBlockReward method - EthBlock extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
getBlockReward
34 | 37 |
38 | 39 |
40 | 41 | 71 | 72 |
73 |

getBlockReward method Null safety 74 |

75 | 76 |
77 | Future<EtherScanBlockRewardModel> 78 | getBlockReward 79 | (
  1. {String? address,
  2. 80 |
  3. Object? blockno = 0}
  4. 81 |
) 82 | 83 |
84 |
85 |

Find the block reward for a given address and block

86 |

address - Address of the block

87 |

blockno - Block number

88 |
89 | 90 |
91 |

Implementation

92 |
Future<EtherScanBlockRewardModel> getBlockReward({
 93 |   String? address,
 94 |   Object? blockno = 0,
 95 | }) async {
 96 |   const module = 'block';
 97 |   const action = 'getblockreward';
 98 | 
 99 |   final query = {
100 |     'module': module,
101 |     'action': action,
102 |     'apiKey': apiKey,
103 |   };
104 | 
105 |   if (address != null) {
106 |     query.putIfAbsent('address', () => address);
107 |   }
108 | 
109 |   if (blockno != null) {
110 |     query.putIfAbsent('blockno', () => '$blockno');
111 |   }
112 | 
113 |   return (await get(query)).fold(
114 |     (l) => EtherScanBlockRewardModel.empty(),
115 |     (r) => EtherScanBlockRewardModel.fromJson(r),
116 |   );
117 | }
118 |
119 | 120 |
121 | 122 | 124 | 125 |
126 | 127 |
128 | 129 | etherscan_api 130 | 1.0.0-beta 131 | 132 | 133 |
134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthAccount/getMinedBlocks.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | getMinedBlocks method - EthAccount extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
getMinedBlocks
34 | 37 |
38 | 39 |
40 | 41 | 77 | 78 |
79 |

getMinedBlocks method Null safety 80 |

81 | 82 |
83 | Future<EtherScanMintedBlocksModel> 84 | getMinedBlocks 85 | (
  1. {required String address}
  2. 86 |
) 87 | 88 |
89 |
90 |

Get a list of blocks that a specific account has mineds

91 |

Example

92 |
var txlist = eth.getMinedBlocks(
 93 |   address:'0x9dd134d14d1e65f84b706d6f205cd5b1cd03a46b'
 94 | );
 95 | 
96 |

address - Transaction hash

97 |
98 | 99 |
100 |

Implementation

101 |
Future<EtherScanMintedBlocksModel> getMinedBlocks({
102 |   required String address,
103 | }) async {
104 |   const module = 'account';
105 |   const action = 'getminedblocks';
106 | 
107 |   final query = {
108 |     'module': module,
109 |     'action': action,
110 |     'address': address,
111 |     'apiKey': apiKey,
112 |   };
113 | 
114 |   return (await get(query)).fold(
115 |     (l) => EtherScanMintedBlocksModel.empty(),
116 |     (r) => EtherScanMintedBlocksModel.fromJson(r),
117 |   );
118 | }
119 |
120 | 121 |
122 | 123 | 125 | 126 |
127 | 128 |
129 | 130 | etherscan_api 131 | 1.0.0-beta 132 | 133 | 134 |
135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherScanFailure/props.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | props property - EtherScanFailure class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
props
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

props property Null safety 88 |

89 | 90 | 91 |
92 | 93 |
94 | List<Object> 95 | props 96 |
override
97 |
98 | 99 |
100 |

The list of properties that will be used to determine whether 101 | two instances are equal.

102 |
103 |
104 |

Implementation

105 |
@override
106 | List<Object> get props => [message, code];
107 |
108 |
109 | 110 |
111 | 112 | 114 | 115 |
116 | 117 |
118 | 119 | etherscan_api 120 | 1.0.0-beta 121 | 122 | 123 |
124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthProxy/gasPrice.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | gasPrice method - EthProxy extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
gasPrice
34 | 37 |
38 | 39 |
40 | 41 | 84 | 85 |
86 |

gasPrice method Null safety 87 |

88 | 89 |
90 | Future<EtherScanRpcResponseModel> 91 | gasPrice 92 | () 93 | 94 |
95 |
96 |

Returns the current price per gas in wei.

97 |
var gasprice = eth.gasPrice();
 98 | 
99 |
100 | 101 |
102 |

Implementation

103 |
Future<EtherScanRpcResponseModel> gasPrice() async {
104 |   const module = 'proxy';
105 |   const action = 'eth_gasPrice';
106 |   Map<String, dynamic>? query = {
107 |     'apiKey': apiKey,
108 |     'module': module,
109 |     'action': action,
110 |   };
111 | 
112 |   return (await get(query)).fold(
113 |     (l) => EtherScanRpcResponseModel.empty(),
114 |     (r) => EtherScanRpcResponseModel.fromJson(r),
115 |   );
116 | }
117 |
118 | 119 |
120 | 121 | 123 | 124 |
125 | 126 |
127 | 128 | etherscan_api 129 | 1.0.0-beta 130 | 131 | 132 |
133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EtherScanFailure/EtherScanFailure.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | EtherScanFailure constructor - EtherScanFailure class - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
EtherScanFailure
34 | 37 |
38 | 39 |
40 | 41 | 85 | 86 |
87 |

EtherScanFailure constructor Null safety 88 |

89 | 90 |
91 | 92 | EtherScanFailure(
  1. {String message = '',
  2. 93 |
  3. int code = -1}
  4. 94 |
) 95 |
96 | 97 | 98 |
99 |

Implementation

100 |
EtherScanFailure({this.message = '', this.code = -1});
101 |
102 | 103 |
104 | 105 | 107 | 108 |
109 | 110 |
111 | 112 | etherscan_api 113 | 1.0.0-beta 114 | 115 | 116 |
117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthProxy/blockNumber.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | blockNumber method - EthProxy extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
blockNumber
34 | 37 |
38 | 39 |
40 | 41 | 84 | 85 |
86 |

blockNumber method Null safety 87 |

88 | 89 |
90 | Future<EtherScanRpcResponseModel> 91 | blockNumber 92 | () 93 | 94 |
95 |
96 |

Returns the number of most recent block

97 |

Example

98 |
var block = eth.blockNumber();
 99 | 
100 |
101 | 102 |
103 |

Implementation

104 |
Future<EtherScanRpcResponseModel> blockNumber() async {
105 |   const module = 'proxy';
106 |   const action = 'eth_blockNumber';
107 | 
108 |   Map<String, dynamic>? query = {
109 |     'module': module,
110 |     'action': action,
111 |     'apiKey': apiKey,
112 |   };
113 | 
114 |   return (await get(query)).fold(
115 |     (l) => EtherScanRpcResponseModel.empty(),
116 |     (r) => EtherScanRpcResponseModel.fromJson(r),
117 |   );
118 | }
119 |
120 | 121 |
122 | 123 | 125 | 126 |
127 | 128 |
129 | 130 | etherscan_api 131 | 1.0.0-beta 132 | 133 | 134 |
135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthStats/tokenSupply.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | tokenSupply method - EthStats extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
tokenSupply
34 | 37 |
38 | 39 |
40 | 41 | 73 | 74 |
75 |

tokenSupply method Null safety 76 |

77 | 78 |
79 | Future<EtherScanSupplyModel> 80 | tokenSupply 81 | (
  1. {String? tokenName,
  2. 82 |
  3. String? contractAddress}
  4. 83 |
) 84 | 85 |
86 |
87 |

Returns the supply of Tokens

88 |

tokenname - Name of the Token

89 |

contractaddress - Address from token contract

90 |

Example

91 |
var supply = eth.tokenSupply(
 92 |     tokenname: null,
 93 |     contractAddress: '0x57d90b64a1a57749b0f932f1a3395792e12e7055'
 94 | );
 95 | 
96 |

Result returned in Wei, to get value in Ether divide resultAbove/1000000000000000000)

97 |
98 | 99 |
100 |

Implementation

101 |
Future<EtherScanSupplyModel> tokenSupply({
102 |   String? tokenName,
103 |   String? contractAddress,
104 | }) async {
105 |   const module = 'stats';
106 |   const action = 'tokensupply';
107 | 
108 |   Map<String, dynamic>? query = {
109 |     'module': module,
110 |     'action': action,
111 |     'apiKey': apiKey,
112 |   };
113 | 
114 |   if (tokenName != null) {
115 |     query.putIfAbsent('tokenname', () => tokenName);
116 |   }
117 | 
118 |   if (contractAddress != null) {
119 |     query.putIfAbsent('contractaddress', () => contractAddress);
120 |   }
121 | 
122 |   return (await get(query)).fold(
123 |     (l) => EtherScanSupplyModel.empty(),
124 |     (r) => EtherScanSupplyModel.fromJson(r),
125 |   );
126 | }
127 |
128 | 129 |
130 | 131 | 133 | 134 |
135 | 136 |
137 | 138 | etherscan_api 139 | 1.0.0-beta 140 | 141 | 142 |
143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | -------------------------------------------------------------------------------- /docs/api/etherscan_api/EthAccount/balance.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | balance method - EthAccount extension - etherscan_api library - Dart API 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 22 | 23 |
24 | 25 |
26 | 27 | 33 |
balance
34 | 37 |
38 | 39 |
40 | 41 | 77 | 78 |
79 |

balance method Null safety 80 |

81 | 82 |
83 | Future<EtherScanBalanceModel> 84 | balance 85 | (
  1. {required List<String> addresses}
  2. 86 |
) 87 | 88 |
89 |
90 |

Returns the balance of a sepcific account

91 |

address - Address

92 |

Example

93 |

 94 | final balance = eth.balance(addresses: [
 95 |     '0xde0b295669a9fd93d5f28d9ec85e40f4cb697bae'
 96 | ]);
 97 | 
98 |
99 | 100 |
101 |

Implementation

102 |
Future<EtherScanBalanceModel> balance({
103 |   required List<String> addresses,
104 | }) async {
105 |   const module = 'account';
106 |   var action = 'balance';
107 |   const tag = 'latest';
108 |   var address = '';
109 | 
110 |   if (addresses.isNotEmpty) {
111 |     address = addresses.join(',');
112 |     action = 'balancemulti';
113 |   }
114 | 
115 |   Map<String, dynamic>? query = {
116 |     'module': module,
117 |     'action': action,
118 |     'apiKey': apiKey,
119 |     'tag': tag,
120 |     'address': address,
121 |   };
122 | 
123 |   return (await get(query)).fold(
124 |     (l) => EtherScanBalanceModel.empty(),
125 |     (r) => EtherScanBalanceModel.fromJson(r),
126 |   );
127 | }
128 |
129 | 130 |
131 | 132 | 134 | 135 |
136 | 137 |
138 | 139 | etherscan_api 140 | 1.0.0-beta 141 | 142 | 143 |
144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | --------------------------------------------------------------------------------