MCPcopy
hub / github.com/subquery/subql / tryFetchAbiFromExplorer

Function tryFetchAbiFromExplorer

packages/cli/src/utils/etherscan.ts:38–57  ·  view source on GitHub ↗
(address: string, chainId: number | string)

Source from the content-addressed store, hash-verified

36 * @returns The ABI as a JSON object or undefined if the fetch fails.
37 */
38export async function tryFetchAbiFromExplorer(address: string, chainId: number | string): Promise<unknown> {
39 try {
40 const result = await runRequest<string>(chainId, {
41 module: 'contract',
42 action: 'getabi',
43 address,
44 });
45
46 if (!result) {
47 return undefined;
48 }
49
50 return JSON.parse(result);
51 } catch (e) {
52 if (e instanceof Error && e.message.includes('Contract source code not verified')) {
53 return undefined;
54 }
55 throw e;
56 }
57}
58
59/**
60 * Fetches the deployment height of a contract from Etherscan.

Callers 2

etherscan.spec.tsFile · 0.90
generateAdapterFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected