@@ -254,27 +254,27 @@ impl Chain {
254254
255255 pub fn get_chain_etherscan_base ( & self ) -> String {
256256 match self {
257- Chain :: ETH => "https://api.etherscan.io/api" ,
257+ Chain :: ETH => "https://api.etherscan.io/v2/ api" ,
258258 Chain :: GOERLI => "https://api-goerli.etherscan.io/api" ,
259- Chain :: SEPOLIA => "https://api-sepolia .etherscan.io/api" ,
260- Chain :: BSC => "https://api.bscscan.com /api" ,
261- Chain :: CHAPEL => "https://api-testnet.bscscan.com /api" ,
262- Chain :: POLYGON => "https://api.polygonscan.com /api" ,
259+ Chain :: SEPOLIA => "https://api.etherscan.io/v2 /api" ,
260+ Chain :: BSC => "https://api.etherscan.io/v2 /api" ,
261+ Chain :: CHAPEL => "https://api.etherscan.io/v2 /api" ,
262+ Chain :: POLYGON => "https://api.etherscan.io/v2 /api" ,
263263 Chain :: MUMBAI => "https://mumbai.polygonscan.com/api" ,
264- Chain :: FANTOM => "https://api.ftmscan.com /api" ,
265- Chain :: AVALANCHE => "https://api.snowtrace .io/api" ,
266- Chain :: OPTIMISM => "https://api-optimistic .etherscan.io/api" ,
267- Chain :: ARBITRUM => "https://api.arbiscan .io/api" ,
268- Chain :: GNOSIS => "https://api.gnosisscan .io/api" ,
269- Chain :: BASE => "https://api.basescan.org /api" ,
270- Chain :: CELO => "https://api.celoscan .io/api" ,
271- Chain :: ZKEVM => "https://api-zkevm.polygonscan.com /api" ,
272- Chain :: ZkevmTestnet => "https://api-testnet-zkevm.polygonscan.com /api" ,
273- Chain :: BLAST => "https://api.routescan .io/v2/network/mainnet/evm/81457/etherscan " ,
274- Chain :: LINEA => "https://api.lineascan.build /api" ,
264+ Chain :: FANTOM => "https://api.etherscan.io/v2 /api" ,
265+ Chain :: AVALANCHE => "https://api.etherscan .io/v2 /api" ,
266+ Chain :: OPTIMISM => "https://api.etherscan.io/v2 /api" ,
267+ Chain :: ARBITRUM => "https://api.etherscan .io/v2 /api" ,
268+ Chain :: GNOSIS => "https://api.etherscan .io/v2 /api" ,
269+ Chain :: BASE => "https://api.etherscan.io/v2 /api" ,
270+ Chain :: CELO => "https://api.etherscan .io/v2 /api" ,
271+ Chain :: ZKEVM => "https://api.etherscan.io/v2 /api" ,
272+ Chain :: ZkevmTestnet => "https://api.etherscan.io/v2 /api" ,
273+ Chain :: BLAST => "https://api.etherscan .io/v2/api " ,
274+ Chain :: LINEA => "https://api.etherscan.io/v2 /api" ,
275275 Chain :: LOCAL => "http://localhost:8080/abi/" ,
276276 Chain :: IOTEX => "https://babel-api.mainnet.IoTeX.io" ,
277- Chain :: SCROLL => "https://api.scrollscan.com /api" ,
277+ Chain :: SCROLL => "https://api.etherscan.io/v2 /api" ,
278278 Chain :: VANA => "https://api.vanascan.io/api/v2" ,
279279 Chain :: STORY => "https://www.storyscan.xyz/api/v2" ,
280280 }
@@ -749,16 +749,32 @@ impl OnChainConfig {
749749 {
750750 return None ;
751751 }
752- let endpoint = format ! (
753- "{}?module=contract&action=getabi&address={:?}&format=json&apikey={}" ,
754- self . etherscan_base,
755- address,
756- if !self . etherscan_api_key. is_empty( ) {
757- self . etherscan_api_key[ rand:: random:: <usize >( ) % self . etherscan_api_key. len( ) ] . clone( )
758- } else {
759- "" . to_string( )
760- }
761- ) ;
752+
753+ let endpoint = if self . etherscan_base . contains ( "/v2/api" ) {
754+ format ! (
755+ "{}?chainid={}&module=contract&action=getabi&address={:?}&format=json&apikey={}" ,
756+ self . etherscan_base,
757+ self . chain_id,
758+ address,
759+ if !self . etherscan_api_key. is_empty( ) {
760+ self . etherscan_api_key[ rand:: random:: <usize >( ) % self . etherscan_api_key. len( ) ] . clone( )
761+ } else {
762+ "" . to_string( )
763+ }
764+ )
765+ } else {
766+ format ! (
767+ "{}?module=contract&action=getabi&address={:?}&format=json&apikey={}" ,
768+ self . etherscan_base,
769+ address,
770+ if !self . etherscan_api_key. is_empty( ) {
771+ self . etherscan_api_key[ rand:: random:: <usize >( ) % self . etherscan_api_key. len( ) ] . clone( )
772+ } else {
773+ "" . to_string( )
774+ }
775+ )
776+ } ;
777+
762778 info ! ( "fetching abi from {}" , endpoint) ;
763779 match self . get ( endpoint. clone ( ) ) {
764780 Some ( resp) => {
0 commit comments