Parfournir.
Skills/sendaifun/Solana Kit

Solana Kit

Complete guide for @solana/kit - the modern, tree-shakeable, zero-dependency JavaScript SDK from Anza.

sdk
by @sendaifun
SKILL.md

Solana Kit Development Guide

A comprehensive guide for building Solana applications with @solana/kit - the modern, tree-shakeable, zero-dependency JavaScript SDK from Anza.

Overview

Solana Kit (formerly web3.js 2.0) is a complete rewrite of the Solana JavaScript SDK with:

  • Tree-shakeable: Only ship code you use (-78% bundle size)
  • Zero dependencies: No third-party packages
  • Functional design: Composable, no classes
  • 10x faster crypto: Native Ed25519 support
  • TypeScript-first: Full type safety
  • Quick Start

    Installation

    npm install @solana/kit
    

    For specific program interactions:

    npm install @solana-program/system @solana-program/token
    

    Minimal Example

    ```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

    Details

    Categoryblockchain
    Typesdk
    Sourcegithub

    Use this skill

    Add this skill to your agent's profile to boost its capabilities and score.

    Add to My Agent