UNPKG

4.69 kBTypeScriptView Raw
1/**
2 * [[link-etherscan]] provides a third-party service for connecting to
3 * various blockchains over a combination of JSON-RPC and custom API
4 * endpoints.
5 *
6 * **Supported Networks**
7 *
8 * - Ethereum Mainnet (``mainnet``)
9 * - Goerli Testnet (``goerli``)
10 * - Sepolia Testnet (``sepolia``)
11 * - Holesky Testnet (``holesky``)
12 * - Arbitrum (``arbitrum``)
13 * - Arbitrum Goerli Testnet (``arbitrum-goerli``)
14 * - Base (``base``)
15 * - Base Sepolia Testnet (``base-sepolia``)
16 * - BNB Smart Chain Mainnet (``bnb``)
17 * - BNB Smart Chain Testnet (``bnbt``)
18 * - Optimism (``optimism``)
19 * - Optimism Goerli Testnet (``optimism-goerli``)
20 * - Polygon (``matic``)
21 * - Polygon Mumbai Testnet (``matic-mumbai``)
22 * - Polygon Amoy Testnet (``matic-amoy``)
23 *
24 * @_subsection api/providers/thirdparty:Etherscan [providers-etherscan]
25 */
26import { Contract } from "../contract/index.js";
27import { AbstractProvider } from "./abstract-provider.js";
28import { Network } from "./network.js";
29import { NetworkPlugin } from "./plugins-network.js";
30import { PerformActionRequest } from "./abstract-provider.js";
31import type { Networkish } from "./network.js";
32import type { TransactionRequest } from "./provider.js";
33/**
34 * When subscribing to the ``"debug"`` event on an Etherscan-based
35 * provider, the events receive a **DebugEventEtherscanProvider**
36 * payload.
37 *
38 * @_docloc: api/providers/thirdparty:Etherscan
39 */
40export type DebugEventEtherscanProvider = {
41 action: "sendRequest";
42 id: number;
43 url: string;
44 payload: Record<string, any>;
45} | {
46 action: "receiveRequest";
47 id: number;
48 result: any;
49} | {
50 action: "receiveError";
51 id: number;
52 error: any;
53};
54/**
55 * A Network can include an **EtherscanPlugin** to provide
56 * a custom base URL.
57 *
58 * @_docloc: api/providers/thirdparty:Etherscan
59 */
60export declare class EtherscanPlugin extends NetworkPlugin {
61 /**
62 * The Etherscan API base URL.
63 */
64 readonly baseUrl: string;
65 /**
66 * Creates a new **EtherscanProvider** which will use
67 * %%baseUrl%%.
68 */
69 constructor(baseUrl: string);
70 clone(): EtherscanPlugin;
71}
72/**
73 * The **EtherscanBaseProvider** is the super-class of
74 * [[EtherscanProvider]], which should generally be used instead.
75 *
76 * Since the **EtherscanProvider** includes additional code for
77 * [[Contract]] access, in //rare cases// that contracts are not
78 * used, this class can reduce code size.
79 *
80 * @_docloc: api/providers/thirdparty:Etherscan
81 */
82export declare class EtherscanProvider extends AbstractProvider {
83 #private;
84 /**
85 * The connected network.
86 */
87 readonly network: Network;
88 /**
89 * The API key or null if using the community provided bandwidth.
90 */
91 readonly apiKey: null | string;
92 /**
93 * Creates a new **EtherscanBaseProvider**.
94 */
95 constructor(_network?: Networkish, _apiKey?: string);
96 /**
97 * Returns the base URL.
98 *
99 * If an [[EtherscanPlugin]] is configured on the
100 * [[EtherscanBaseProvider_network]], returns the plugin's
101 * baseUrl.
102 */
103 getBaseUrl(): string;
104 /**
105 * Returns the URL for the %%module%% and %%params%%.
106 */
107 getUrl(module: string, params: Record<string, string>): string;
108 /**
109 * Returns the URL for using POST requests.
110 */
111 getPostUrl(): string;
112 /**
113 * Returns the parameters for using POST requests.
114 */
115 getPostData(module: string, params: Record<string, any>): Record<string, any>;
116 detectNetwork(): Promise<Network>;
117 /**
118 * Resolves to the result of calling %%module%% with %%params%%.
119 *
120 * If %%post%%, the request is made as a POST request.
121 */
122 fetch(module: string, params: Record<string, any>, post?: boolean): Promise<any>;
123 /**
124 * Returns %%transaction%% normalized for the Etherscan API.
125 */
126 _getTransactionPostData(transaction: TransactionRequest): Record<string, string>;
127 /**
128 * Throws the normalized Etherscan error.
129 */
130 _checkError(req: PerformActionRequest, error: Error, transaction: any): never;
131 _detectNetwork(): Promise<Network>;
132 _perform(req: PerformActionRequest): Promise<any>;
133 getNetwork(): Promise<Network>;
134 /**
135 * Resolves to the current price of ether.
136 *
137 * This returns ``0`` on any network other than ``mainnet``.
138 */
139 getEtherPrice(): Promise<number>;
140 /**
141 * Resolves to a [Contract]] for %%address%%, using the
142 * Etherscan API to retreive the Contract ABI.
143 */
144 getContract(_address: string): Promise<null | Contract>;
145 isCommunityResource(): boolean;
146}
147//# sourceMappingURL=provider-etherscan.d.ts.map
\No newline at end of file