Solana API Quickstart | Alchemy Docs

Solana API Quickstart

How to get started building on Solana using Alchemy

Send your first request on Alchemy

Let's use @solana/web3.js package to set up a Connection with Alchemy and get the latest slot on Solana!

npm install --save @solana/web3.js
yarn add @solana/web3.js

Create a connection to Alchemy

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

const connection = new Connection(
  "https://solana-devnet.g.alchemy.com/v2/YOUR_ALCHEMY_API_KEY",
  "confirmed"
);

const slot = await connection.getSlot();
console.log("Current slot:", slot);

Now that you've set up a connection to Alchemy, you can continue with some basics:

Create a wallet

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

const wallet = Keypair.generate();
console.log("Public Key:", wallet.publicKey.toBase58());

Check wallet balance

const balance = await connection.getBalance(wallet.publicKey);
console.log("Balance:", balance / 1e9, "SOL");

Fetch account info

const info = await connection.getAccountInfo(wallet.publicKey);
console.log(info);

Find Solana methods by category

Current State Methods
Historical Data (Archival)
Transaction Submission
Network & Cluster Info

CU Calculator

Want to estimate your Solana Compute Units (CUs) before running transactions?

Try the CU Calculator now: Open CU Calculator →

Solana Tutorials

Check out the following tutorials to learn how to build with Solana: