diff --git a/packages/ethereum-viewer/src/explorer/fetchFiles.ts b/packages/ethereum-viewer/src/explorer/fetchFiles.ts index cc27921..ed12e82 100644 --- a/packages/ethereum-viewer/src/explorer/fetchFiles.ts +++ b/packages/ethereum-viewer/src/explorer/fetchFiles.ts @@ -42,12 +42,22 @@ export async function fetchFiles( }: FetchFilesOptions = {} ): Promise { const apiUrl = explorerApiUrls[apiName]; - const url = - apiUrl + - "?module=contract" + - "&action=getsourcecode" + - `&address=${contractAddress}` + - `&apikey=${explorerApiKeys[apiName]}`; + let url; + if (apiUrl.includes("chainid=")) { + url = + apiUrl + + "&module=contract" + + "&action=getsourcecode" + + `&address=${contractAddress}` + + `&apikey=${explorerApiKeys[apiName]}`; + } else { + url = + apiUrl + + "?module=contract" + + "&action=getsourcecode" + + `&address=${contractAddress}` + + `&apikey=${explorerApiKeys[apiName]}`; + } const response = (await fetch(url)) as types.ContractSourceResponse;