SolToolkit has over 1,000+ downloads 👀
SolToolkit is a Swiss Army knife for Solana devs. It is a Node.js library with 4 modules, such as ConnectionManager for switching between RPC endpoints and using the fastest endpoint available.
$ npm install -s @solworks/soltoolkit-sdk
ConnectionManager is a singleton class that manages web3.js Connection(s). It takes the following parameters on initialization using the async getInstance()
method:
{
network: Cluster;
endpoint?: string;
endpoints?: string[];
config?: ConnectionConfig;
commitment?: Commitment;
mode?: Mode;
}
network
is the cluster to connect to, possible values are 'mainnet-beta', 'testnet', 'devnet', 'localnet'. This is required. If you do not pass in any values for endpoint
or endpoints
, the default endpoints for the network will be used.endpoint
is a single endpoint to connect to. This is optional.endpoints
is an array of endpoints to connect to. This is optional.config
is a web3.js ConnectionConfig object. This is optional.commitment
is the commitment level to use for transactions. This is optional, will default to 'max'.mode
is the Mode for the ConnectionManager. This is optional, will default to 'single'. Possible values are:
endpoint
param, that falls back to the first endpoint provided in endpoints
, that falls back to the default endpoints for the network.endpoints
. Throws an error if no endpoints are provided.endpoints
. Throws an error if no endpoints are provided.endpoints
in a round-robin fashion (cycles through each endpoint in sequence starting from the first). Throws an error if no endpoints are provided.endpoints
. Throws an error if no endpoints are provided.endpoints
. Throws an error if no endpoints are provided.endpoints
. Throws an error if no endpoints are provided.getInstance()
- Returns the singleton instance of the ConnectionManager. This method is async and must be awaited.getInstanceSync()
- Returns the singleton instance of the ConnectionManager. This method is synchronous. This method should only be used after initializing the ConnectionManager with getInstance()
.