2023-03-03 18:25:07 -07:00
|
|
|
import type { AbstractProvider } from "./abstract-provider.js";
|
|
|
|
import type { Networkish } from "./network.js";
|
|
|
|
import { WebSocketLike } from "./provider-websocket.js";
|
2023-10-09 20:27:56 -04:00
|
|
|
/**
|
|
|
|
* Returns a default provider for %%network%%.
|
|
|
|
*
|
|
|
|
* If %%network%% is a [[WebSocketLike]] or string that begins with
|
|
|
|
* ``"ws:"`` or ``"wss:"``, a [[WebSocketProvider]] is returned backed
|
|
|
|
* by that WebSocket or URL.
|
|
|
|
*
|
|
|
|
* If %%network%% is a string that begins with ``"HTTP:"`` or ``"HTTPS:"``,
|
|
|
|
* a [[JsonRpcProvider]] is returned connected to that URL.
|
|
|
|
*
|
|
|
|
* Otherwise, a default provider is created backed by well-known public
|
|
|
|
* Web3 backends (such as [[link-infura]]) using community-provided API
|
|
|
|
* keys.
|
|
|
|
*
|
|
|
|
* The %%options%% allows specifying custom API keys per backend (setting
|
|
|
|
* an API key to ``"-"`` will omit that provider) and ``options.exclusive``
|
|
|
|
* can be set to either a backend name or and array of backend names, which
|
|
|
|
* will whitelist **only** those backends.
|
|
|
|
*
|
|
|
|
* Current backend strings supported are:
|
|
|
|
* - ``"alchemy"``
|
|
|
|
* - ``"ankr"``
|
|
|
|
* - ``"cloudflare"``
|
|
|
|
* - ``"etherscan"``
|
|
|
|
* - ``"infura"``
|
|
|
|
* - ``"publicPolygon"``
|
|
|
|
* - ``"quicknode"``
|
|
|
|
*
|
|
|
|
* @example:
|
|
|
|
* // Connect to a local Geth node
|
|
|
|
* provider = getDefaultProvider("http://localhost:8545/");
|
|
|
|
*
|
|
|
|
* // Connect to Ethereum mainnet with any current and future
|
|
|
|
* // third-party services available
|
|
|
|
* provider = getDefaultProvider("mainnet");
|
|
|
|
*
|
2023-11-11 18:00:39 -05:00
|
|
|
* // Connect to Polygon, but only allow Etherscan and
|
2023-10-09 20:27:56 -04:00
|
|
|
* // INFURA and use "MY_API_KEY" in calls to Etherscan.
|
|
|
|
* provider = getDefaultProvider("matic", {
|
|
|
|
* etherscan: "MY_API_KEY",
|
|
|
|
* exclusive: [ "etherscan", "infura" ]
|
|
|
|
* });
|
|
|
|
*/
|
2024-02-02 03:25:03 -05:00
|
|
|
export declare function getDefaultProvider(network?: string | Networkish | WebSocketLike, options?: any): AbstractProvider;
|
2023-04-27 21:19:55 +09:00
|
|
|
//# sourceMappingURL=default-provider.d.ts.map
|