Providers
Configure and utilize a Provider to interact with Quai Network.
Overview
A Provider establishes a connection to the blockchain, whch can be used to query its current state, simulate execution and send transactions to update the state.
Providers are one of the most fundamental components of interacting with a blockchain application, and there are many ways to connect, such as over HTTP, WebSockets or injected providers such as Pelagus.
Usage
There are two types of network providers you can connect to:
- Remote Node Providers: any remote node that is open to data requests
- Browser/Injected Providers: typically wallet interfaces used in browser Applications
Remote Node Provider
To connect to a remote node provider, use the JsonRpcProvider or WebSocketProvider classes. This connects to a remote node using the JSON-RPC interface. Remote node providers will never have a signer bundled into them.
Quais providers are configured to first ask the node which shards it is currently running, and then establish a connection to each of those chains. This is done using
- Via reverse proxy pathing
- Available using the Colosseum RPC endpoint with
https
andwss
- Available using the Colosseum RPC endpoint with
Injected Provider
There are multiple ways to configure a network provider using the Provider interface.
To connect to a browser wallet provider like Pelagus, use the BrowserProvider class. Pelagus bundles a Signer into the injected provider that can be used to sign transactions.
Was this page helpful?