Connecting to a Solana RPC
To start Kite, you need to connect to a Solana RPC - RPCs are how your code communicates with the Solana blockchain.
To use the local cluster (ie, solana-test-validator
running on your machine):
import { connect } from "solana-kite";
const connection = connect();
You can also specify a cluster name. The connection object defaults to localnet
but any of the following cluster names are supported:
devnet
- Development network for testing with fake SOL. This is where Solana apps developers typically deploy first.mainnet-beta
(ormainnet
) - Main Solana network where transactions involving real value occur.testnet
- Used to test future versions of the Solana blockchain.helius-mainnet
,helius-testnet
, orhelius-devnet
- the Helius names require the environment variableHELIUS_API_KEY
to be set in your environment. You can get an API key from Helius .
const connection = connect("helius-devnet");
You can also specify an arbitrary RPC URL and RPC subscription URL:
const connection = connect("https://mainnet.example.com/", "wss://mainnet.example.com/");
After you’ve made a connection Kite is ready to use.
If you’re used to raw @solana/kit
you don’t need to set up any factories, they’re already configured.
Last updated on