Typescript components for Shadow Drive.
Install these dependencies:
yarn add @shadow-drive/sdkimport React, { useEffect } from "react";
import * as anchor from "@coral-xyz/anchor";
import { ShdwDrive } from "@shadow-drive/sdk";
import {
AnchorWallet,
useAnchorWallet,
useConnection,
} from "@solana/wallet-adapter-react";
export default function Drive() {
const { connection } = useConnection();
const wallet = useAnchorWallet();
useEffect(() => {
(async () => {
if (wallet?.publicKey) {
const drive = await new ShdwDrive(connection, wallet).init();
}
})();
}, [wallet?.publicKey]);
return <div></div>;
}import { ShdwDrive } from "@shadow-drive/sdk";
import * as web3 from "@solana/web3.js";
const connection = new web3.Connection("{rpc-url}", "confirmed");
const drive = await new ShdwDrive(connection, wallet).init();Shadow Drive uses Solana wallet signatures for authentication. You only need a Solana wallet - no additional API keys or Shadow Drive accounts required.
You can use any Solana RPC endpoint. The example code shows GenesysGo's RPC service, but this is optional:
Option 1: Public Solana RPC (No additional credentials needed)
const connection = new web3.Connection("https://api.mainnet-beta.solana.com");Option 2: GenesysGo RPC (Requires their RPC credentials)
const connection = new web3.Connection(
"https://us-west-1.genesysgo.net/{YOUR_RPC_ACCOUNT_ID}",
{
commitment: "confirmed",
httpHeaders: {
Authorization: "Bearer {YOUR_RPC_ACCESS_TOKEN}",
},
}
);Option 3: Other RPC providers
// Helius, QuickNode, Alchemy, etc.
const connection = new web3.Connection("{YOUR_PREFERRED_RPC_URL}");Regardless of your RPC choice, Shadow Drive setup is the same:
// Your Solana wallet (browser wallet, keypair, etc.)
const wallet = /* your wallet instance */;
// Initialize Shadow Drive
const drive = await new ShdwDrive(connection, wallet).init();In examples/web/src/App.tsx, the placeholders refer to GenesysGo's RPC service credentials:
{YOUR_ACCOUNT_UUID_HERE}= Your GenesysGo RPC account identifier{GENESYSGO AUTHENTICATION TOKEN HERE}= Your GenesysGo RPC access token
To use the example:
- Option A: Replace with your GenesysGo RPC credentials
- Option B: Change to a public RPC endpoint and remove the Authorization header
- RPC Authentication: Handled by your connection configuration (varies by provider)
- Shadow Drive Authentication: Automatic via wallet signatures
- No API keys needed
- Uses cryptographic message signing
- Wallet signs authentication messages for each operation
Note: GenesysGo RPC credentials are for blockchain access only, not Shadow Drive storage. Shadow Drive authenticates through your Solana wallet automatically.
| package | description |
|---|---|
| react | Using shadow-drive in a react/browser environment |
- Clone the project:
git clone https://github.com/genesysgo/shadow-drive.git- Install dependencies:
cd shadow-drive
yarn install