Complete guide for @solana/kit - the modern, tree-shakeable, zero-dependency JavaScript SDK from Anza.
A comprehensive guide for building Solana applications with @solana/kit - the modern, tree-shakeable, zero-dependency JavaScript SDK from Anza.
Solana Kit (formerly web3.js 2.0) is a complete rewrite of the Solana JavaScript SDK with:
npm install @solana/kit
For specific program interactions:
npm install @solana-program/system @solana-program/token
```typescript
import {
createSolanaRpc,
createSolanaRpcSubscriptions,
generateKeyPairSigner,
lamports,
pipe,
createTransactionMessage,
setTransactionMessageFeePayer,
setTransactionMessageLifetimeUsingBlockhash,
appendTransactionMessageInstruction,
signTransactionMessageWithSigners,
sendAndConfirmTransactionFactory,
getSignatureFromTransaction,
} from "@solana/kit";
import { getTransferSolInstruction } from "@solana-program/system";
const LAMPORTS_PER_SOL = BigInt(1_000_000_000);
async function transferSol() {
// 1. Connect to RPC
const rpc = createSolanaRpc("https://api.devnet.solana.com");
const rpcSubscriptions = createSolanaRpcSubscriptions("wss://api.devnet.solana.com");
// 2. Create signers
const sender = await generateKeyPairSigner();
const recipient = await generateKeyPairSigner();
// 3. Get blockhash
const { value: latestBlockhash } = await rpc.getLatestBlockhash().send();
// 4. Build transaction with pipe
const transactionMessage = pipe(
createTransactionMessage({ version: 0 }),
(tx) => setTransactionMessageFeePayer(sender.address, tx),
(tx) => setTransactionMessageLifetimeUsingBlockhash(latestBlockhash, tx),
(tx) => appendTransactionMessageInstruction(
getTransferSolIns
Use this skill
Add this skill to your agent's profile to boost its capabilities and score.
Add to My Agent