Solana Kit
Storage Account
Cross-chain storage account for Solana identities
The ShelbyStorageAccount class represents a cross-chain storage account that allows Solana keypairs to own and manage data on the Shelby Protocol.
Overview
A Shelby Storage Account is derived from:
- Solana Keypair - Links the original keypair with the storage account
- Domain - Provides application-level isolation
This derivation uses Aptos Derivable Account Abstraction to create a unique Aptos address controlled by the Solana keypair.
Creating a Storage Account
import { Shelby, Network } from "@shelby-protocol/solana-kit/node";
import { Connection, Keypair } from "@solana/web3.js";
const connection = new Connection("https://api.devnet.solana.com");
const shelbyClient = new Shelby({
network: Network.SHELBYNET,
connection,
apiKey: "AG-***",
});
const solanaKeypair = Keypair.generate();
const domain = "my-awesome-dapp.com";
const storageAccount = shelbyClient.createStorageAccount(solanaKeypair, domain);Parameters
| Parameter | Type | Description |
|---|---|---|
solanaKeypair | Keypair | The Solana keypair that controls the storage account |
domain | string | The dApp domain for account isolation |
Properties
accountAddress
The address of the storage account.
console.log(storageAccount.accountAddress.toString());
// Output: "0x1234...abcd"solanaKeypair
The underlying Solana keypair.
console.log(storageAccount.solanaKeypair.publicKey.toBase58());
// Output: "7xKX...9abc"domain
The domain used for account derivation.
console.log(storageAccount.domain);
// Output: "my-awesome-dapp.com"Usage as a Signer
The storage account can be used as a signer for Shelby operations:
// Upload a blob
await shelbyClient.upload({
blobData: new Uint8Array([1, 2, 3]),
signer: storageAccount, // Use as signer
blobName: "example.txt",
expirationMicros: Date.now() * 1000 + 86400000000,
});Domain Isolation
Storage accounts are scoped to the dApp domain. The same Solana keypair will have different storage account addresses on different domains.
const keypair = Keypair.generate();
const account1 = shelbyClient.createStorageAccount(keypair, "app1.com");
const account2 = shelbyClient.createStorageAccount(keypair, "app2.com");
// Different addresses!
console.log(account1.accountAddress.toString()); // "0x1111..."
console.log(account2.accountAddress.toString()); // "0x2222..."This isolation ensures that:
- Users have separate storage spaces per application
- Applications cannot access each other's data
- Domain-specific permissions are enforced