provider-etherscan.d.ts 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  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. */
  26. import { Contract } from "../contract/index.js";
  27. import { AbstractProvider } from "./abstract-provider.js";
  28. import { Network } from "./network.js";
  29. import { NetworkPlugin } from "./plugins-network.js";
  30. import { PerformActionRequest } from "./abstract-provider.js";
  31. import type { Networkish } from "./network.js";
  32. import 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. */
  40. export 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. */
  60. export 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. */
  82. export 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