There are many services which offer a web API for accessing the Ethereum Blockchain. These Providers allow connecting to them, which simplifies development, since you do not need to run your own instance or cluster of Ethereum nodes.
However, this reliance on third-party services can reduce resilience, security and increase the amount of required trust. To mitigate these issues, it is recommended you use a Default Provider.
EtherscanProvider inherits BaseProvider
The EtherscanProvider is backed by a combination of the various Etherscan APIs.
Create a new EtherscanProvider connected to network with the optional apiKey.
The network may be specified as a string for a common network name, a number for a common chain ID or a [Network Object]provider-(network).
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests. It is highly recommended for production, you register with Etherscan for your own API key.
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests.
It is highly recommended for production, you register with Etherscan for your own API key.
homestead
- Homestead (Mainnet)goerli
- Görli (clique testnet)sepolia
- Sepolia (proof-of-authority testnet)arbitrum
- Arbitrum Optimistic L2arbitrum-goerli
- Arbitrum Optimistic L2 testnetmatic
- Polgon mainnetmaticmum
- Polgon testnetoptimism
- Optimism Optimistic L2optimism-goerli
- Optimism Optimistic L2 testnet
@TODO... Explain
InfuraProvider inherits UrlJsonRpcProvider
The InfuraProvider is backed by the popular INFURA Ethereum service.
Create a new InfuraProvider connected to network with the optional apiKey.
The network may be specified as a string for a common network name, a number for a common chain ID or a [Network Object]provider-(network).
The apiKey can be a string Project ID or an object with the properties projectId
and projectSecret
to specify a Project Secret which can be used on non-public sources (like on a server) to further secure your API access and quotas.
Create a new WebSocketProvider using the INFURA web-socket endpoint to connect to network with the optional apiKey.
The network and apiKey are specified the same as the constructor.
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests.
It is highly recommended for production, you register with INFURA for your own API key.
homestead
- Homestead (Mainnet)goerli
- Görli (clique testnet)sepolia
- Sepolia (proof-of-authority testnet)arbitrum
- Arbitrum Optimistic L2arbitrum-goerli
- Arbitrum Optimistic L2 testnetmatic
- Polgon mainnetmaticmum
- Polgon testnetoptimism
- Optimism Optimistic L2optimism-goerli
- Optimism Optimistic L2 testnet
AlchemyProvider inherits UrlJsonRpcProvider
The AlchemyProvider is backed by Alchemy.
Create a new AlchemyProvider connected to network with the optional apiKey.
The network may be specified as a string for a common network name, a number for a common chain ID or a Network Object.
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests.
It is highly recommended for production, you register with Alchemy for your own API key.
homestead
- Homestead (Mainnet)goerli
- Görli (clique testnet)arbitrum
- Arbitrum Optimistic L2arbitrum-goerli
- Arbitrum Optimistic L2 testnetmatic
- Polgon mainnetmaticmum
- Polgon testnetoptimism
- Optimism Optimistic L2optimism-goerli
- Optimism Optimistic L2 testnet
CloudflareProvider inherits UrlJsonRpcProvider
The CloudflareProvider is backed by the Cloudflare Ethereum Gateway.
Create a new CloudflareProvider connected to mainnet (i.e. "homestead").
homestead
- Homestead (Mainnet)
PocketProvider inherits UrlJsonRpcProvider
The PocketProvider is backed by Pocket.
Create a new PocketProvider connected to network with the optional apiKey.
The network may be specified as a string for a common network name, a number for a common chain ID or a Network Object.
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests.
It is highly recommended for production, you register with Pocket for your own API key.
homestead
- Homestead (Mainnet)goerli
- Görli (clique testnet)matic
- Polgon mainnetmaticmum
- Polgon testnet
AnkrProvider inherits UrlJsonRpcProvider
The AnkrProvider is backed by Ankr.
Create a new AnkrProvider connected to network with the optional apiKey.
The network may be specified as a string for a common network name, a number for a common chain ID or a Network Object.
If no apiKey is provided, a shared API key will be used, which may result in reduced performance and throttled requests.
It is highly recommended for production, you register with Ankr for your own API key.
homestead
- Homestead (Mainnet)matic
- Polygonarbitrum
- Arbitrum (L2; optimistic roll-up)