diff --git a/cw_ethereum/lib/ethereum_client.dart b/cw_ethereum/lib/ethereum_client.dart index 9d50fdd5b..1298d54f5 100644 --- a/cw_ethereum/lib/ethereum_client.dart +++ b/cw_ethereum/lib/ethereum_client.dart @@ -19,7 +19,8 @@ class EthereumClient extends EVMChainClient { Future> fetchTransactions(String address, {String? contractAddress}) async { try { - final response = await httpClient.get(Uri.https("api.etherscan.io", "/api", { + final response = await httpClient.get(Uri.https("api.etherscan.io", "/v2/api", { + "chainid": "$chainId", "module": "account", "action": contractAddress != null ? "tokentx" : "txlist", if (contractAddress != null) "contractaddress": contractAddress, @@ -50,7 +51,8 @@ class EthereumClient extends EVMChainClient { @override Future> fetchInternalTransactions(String address) async { try { - final response = await httpClient.get(Uri.https("api.etherscan.io", "/api", { + final response = await httpClient.get(Uri.https("api.etherscan.io", "/v2/api", { + "chainid": "$chainId", "module": "account", "action": "txlistinternal", "address": address, diff --git a/cw_polygon/lib/polygon_client.dart b/cw_polygon/lib/polygon_client.dart index cb8331977..7e9e882fa 100644 --- a/cw_polygon/lib/polygon_client.dart +++ b/cw_polygon/lib/polygon_client.dart @@ -40,12 +40,13 @@ class PolygonClient extends EVMChainClient { Future> fetchTransactions(String address, {String? contractAddress}) async { try { - final response = await httpClient.get(Uri.https("api.polygonscan.com", "/api", { + final response = await httpClient.get(Uri.https("api.etherscan.io", "/v2/api", { + "chainid": "$chainId", "module": "account", "action": contractAddress != null ? "tokentx" : "txlist", if (contractAddress != null) "contractaddress": contractAddress, "address": address, - "apikey": secrets.polygonScanApiKey, + "apikey": secrets.etherScanApiKey, })); final jsonResponse = json.decode(response.body) as Map; @@ -67,11 +68,12 @@ class PolygonClient extends EVMChainClient { @override Future> fetchInternalTransactions(String address) async { try { - final response = await httpClient.get(Uri.https("api.polygonscan.io", "/api", { + final response = await httpClient.get(Uri.https("api.etherscan.io", "/v2/api", { + "chainid": "$chainId", "module": "account", "action": "txlistinternal", "address": address, - "apikey": secrets.polygonScanApiKey, + "apikey": secrets.etherScanApiKey, })); final jsonResponse = json.decode(response.body) as Map; diff --git a/lib/view_model/dashboard/home_settings_view_model.dart b/lib/view_model/dashboard/home_settings_view_model.dart index 7bba04b21..4794746c4 100644 --- a/lib/view_model/dashboard/home_settings_view_model.dart +++ b/lib/view_model/dashboard/home_settings_view_model.dart @@ -297,13 +297,14 @@ abstract class HomeSettingsViewModelBase with Store { required bool isEthereum, }) async { final uri = Uri.https( - isEthereum ? "api.etherscan.io" : "api.polygonscan.com", - "/api", + "api.etherscan.io", + "/v2/api", { + "chainid": isEthereum ? "1" : "137", "module": "token", "action": "tokeninfo", "contractaddress": contractAddress, - "apikey": isEthereum ? secrets.etherScanApiKey : secrets.polygonScanApiKey, + "apikey": secrets.etherScanApiKey, }, ); @@ -338,13 +339,14 @@ abstract class HomeSettingsViewModelBase with Store { required bool isEthereum, }) async { final uri = Uri.https( - isEthereum ? "api.etherscan.io" : "api.polygonscan.com", - "/api", + "api.etherscan.io", + "/v2/api", { + "chainid": isEthereum ? "1" : "137", "module": "contract", "action": "getsourcecode", "address": contractAddress, - "apikey": isEthereum ? secrets.etherScanApiKey : secrets.polygonScanApiKey, + "apikey": secrets.etherScanApiKey, }, );