@@ -25,6 +25,49 @@ function isWebSocketLike(value: any): value is WebSocketLike {
25
25
26
26
const Testnets = "goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt" . split ( " " ) ;
27
27
28
+ /**
29
+ * Returns a default provider for %%network%%.
30
+ *
31
+ * If %%network%% is a [[WebSocketLike]] or string that begins with
32
+ * ``"ws:"`` or ``"wss:"``, a [[WebSocketProvider]] is returned backed
33
+ * by that WebSocket or URL.
34
+ *
35
+ * If %%network%% is a string that begins with ``"HTTP:"`` or ``"HTTPS:"``,
36
+ * a [[JsonRpcProvider]] is returned connected to that URL.
37
+ *
38
+ * Otherwise, a default provider is created backed by well-known public
39
+ * Web3 backends (such as [[link-infura]]) using community-provided API
40
+ * keys.
41
+ *
42
+ * The %%options%% allows specifying custom API keys per backend (setting
43
+ * an API key to ``"-"`` will omit that provider) and ``options.exclusive``
44
+ * can be set to either a backend name or and array of backend names, which
45
+ * will whitelist **only** those backends.
46
+ *
47
+ * Current backend strings supported are:
48
+ * - ``"alchemy"``
49
+ * - ``"ankr"``
50
+ * - ``"cloudflare"``
51
+ * - ``"etherscan"``
52
+ * - ``"infura"``
53
+ * - ``"publicPolygon"``
54
+ * - ``"quicknode"``
55
+ *
56
+ * @example :
57
+ * // Connect to a local Geth node
58
+ * provider = getDefaultProvider("http://localhost:8545/");
59
+ *
60
+ * // Connect to Ethereum mainnet with any current and future
61
+ * // third-party services available
62
+ * provider = getDefaultProvider("mainnet");
63
+ *
64
+ * // Connect to Polygoin, but only allow Etherscan and
65
+ * // INFURA and use "MY_API_KEY" in calls to Etherscan.
66
+ * provider = getDefaultProvider("matic", {
67
+ * etherscan: "MY_API_KEY",
68
+ * exclusive: [ "etherscan", "infura" ]
69
+ * });
70
+ */
28
71
export function getDefaultProvider ( network : string | Networkish | WebSocketLike , options ?: any ) : AbstractProvider {
29
72
if ( options == null ) { options = { } ; }
30
73
0 commit comments