Solana Kit

Getting Started

Getting Started with the Solana Kit SDK for Shelby Protocol

Solana Kit SDK

The Solana Kit SDK enables Solana developers to easily integrate with the Shelby Protocol and leverage decentralized blob storage in their applications.

Installation

npm install @shelby-protocol/solana-kit

Entry Points

The SDK provides two entry points optimized for different environments:

Entry PointEnvironmentUse Case
@shelby-protocol/solana-kit/nodeNode.jsBackend services, scripts, CLIs
@shelby-protocol/solana-kit/reactBrowserReact dApps with wallet adapters

Acquire a Shelby API Key

API keys authenticate your app and manage rate limits when using Shelby services. Without one, your client runs in "anonymous" mode with much lower limits, which can affect performance.

Quick Start

Node.js (Server-Side)

For backend services with direct keypair access:

import { Shelby, Network } from "@shelby-protocol/solana-kit/node";
import { Connection, Keypair } from "@solana/web3.js";

// Create a Solana network connection
const connection = new Connection("https://api.devnet.solana.com");

// Create a Shelby client
const shelbyClient = new Shelby({
  network: Network.SHELBYNET,
  connection,
  apiKey: "AG-***",
});

// Create a storage account from a Solana keypair
const solanaKeypair = Keypair.generate();
const storageAccount = shelbyClient.createStorageAccount(
  solanaKeypair,
  "my-app.com"
);

// Upload data
await shelbyClient.upload({
  blobData: new Uint8Array([1, 2, 3]),
  signer: storageAccount,
  blobName: "example.txt",
  expirationMicros: Date.now() * 1000 + 86400000000,
});

React (Browser)

For browser dApps with wallet connections:

"use client";

import { useStorageAccount, Network } from "@shelby-protocol/solana-kit/react";
import { ShelbyClient } from "@shelby-protocol/sdk/browser";
import { useWallet } from "@solana/wallet-adapter-react";

function MyComponent() {
  const { publicKey, signMessage } = useWallet();
  const shelbyClient = new ShelbyClient({
    network: Network.SHELBYNET,
    apiKey: "AG-***",
  });

  const { storageAccountAddress, signAndSubmitTransaction } = useStorageAccount(
    {
      client: shelbyClient,
      solanaAddress: publicKey?.toBase58(),
      signMessageFn: signMessage,
    }
  );

  return (
    <div>
      <p>Storage Account: {storageAccountAddress?.toString()}</p>
    </div>
  );
}

Key Concepts

Cross-Chain Identity

Shelby uses the Aptos blockchain as a coordination and settlement layer. The Solana Kit leverages Aptos Derivable Account Abstraction to create a Shelby Storage Account from a Solana identity. This enables:

  • Solana keypairs to control data on Shelby
  • Cross-chain signatures managed securely on the Aptos network
  • Application-level isolation through domain scoping

Ownership Hierarchy

The ownership structure is:

  1. Solana Keypair/Wallet → Controls the Storage Account
  2. Storage Account → Owns blobs on Shelby

Each storage account has a different address on different dApps due to domain scoping. This maintains isolation at the application level.

Next Steps