Skip to main content
Version: Canary 🚧

Connecting to a Solana Environment

When you are working on Solana development, you will need to connect to a specific RPC API endpoint. Solana has 3 public development environments:

import { clusterApiUrl, Connection } from "@solana/web3.js";

(async () => {
const connection = new Connection(clusterApiUrl("mainnet-beta"), "confirmed");
})();

Finally, you can also connect to a private cluster, either one local or running remotely with the following:

import { Connection } from "@solana/web3.js";

(async () => {
// This will connect you to your local validator
const connection = new Connection("http://127.0.0.1:8899", "confirmed");
})();