The ethers library offers default API keys for each service, so that each Provider works out-of-the-box.
-These API keys are a provided as a community resource by the backend services for low-traffic projects and for early prototyping.
+These API keys are provided as a community resource by the backend services for low-traffic projects and for early prototyping.
-Since these API keys are shared by all users (that have not acquired their own API key), they are aggressively throttled which means reties occur more frequently and the responses are slower.
+Since these API keys are shared by all users (that have not acquired their own API key), they are aggressively throttled which means retries occur more frequently and the responses are slower.
It is highly recommended that you sign up for a free API key from each service for their free tier, which (depending on the service) includes many advantages:
@@ -40,7 +44,7 @@- higher rate limit (since you are not using the shared rate limit)
- customer usage metrics
The INFURA service has been around for quite some time and is very robust and reliable and highly recommend.
+The INFURA service has been around for quite some time and is very robust and reliable and highly recommended.
They offer a standard JSON-RPC interface and a WebSocket interface, which makes interaction with standard tools versatile, simple and straight forward.
@@ -54,12 +58,18 @@They offer a standard JSON-RPC interface and a WebSocket interface, as well as a collection of advanced APIs for interacting with tokens and to assist with debugging.
-Sign up for a free API key on Alchemy
+Sign up for a free API key on Alchemy
Benefits:
- higher rate limit
- customer usage metrics
- access to advanced token balance and metadata APIs
- access to advanced debugging trace and revert reason APIs
Sign up for a free API key on Pocket
+ +Benefits:
+ +- customer usage metrics
- decentralized Access to Blockchain Infrastructure
- Stake as opposed to paying a monthly fee
- Highly redundant global set of nodes incentivized by cryptoeconomic incentives
The default provider connects to multiple backends and verifies their results internally, making it simple to have a high level of trust in third-party services.
A second optional parameter allows API keys to be specified to each Provider created internally and any API key omitted will fallback onto using the default API key for that service.
@@ -75,16 +85,28 @@ const provider = ethers.getDefaultProvider(network, { etherscan: YOUR_ETHERSCAN_API_KEY, infura: YOUR_INFURA_PROJECT_ID, - alchemy: YOUR_ALCHEMY_API_KEY -}); + // Or if using a project secret: + // infura: { + // projectId: YOUR_INFURA_PROJECT_ID, + // projectSecret: YOUR_INFURA_PROJECT_SECRET, + // }, + alchemy: YOUR_ALCHEMY_API_KEY, + pocket: YOUR_POCKET_APPLICATION_KEY + // Or if using an application secret key: + // pocket: { + // applicationId: , + // applicationSecretKey: + // } +});