SDK reference

TypeScript SDK for integrating SadClaw into your applications and agents.

Installation

npm install @sadclaw/sdk

Quick Start

import { SadClawClient } from '@sadclaw/sdk';
import { Keypair } from '@solana/web3.js';

// Initialize client
const client = new SadClawClient({
  rpcUrl: 'https://api.mainnet-beta.solana.com',
  keypair: myKeypair,
});

// Purchase a VM
const vm = await client.purchaseVm({
  tier: 'STANDARD',
  durationHours: 24,
});

// Get SSH credentials
const ssh = await client.getSshCredentials(vm.nftMint);
console.log(`ssh ${ssh.username}@${ssh.host}`);

SadClawClient

Constructor

SadClawConfig:

Property
Type
Description
Default

rpcUrl

string

Solana RPC URL

Required

keypair

Keypair

Wallet keypair

Required

programId

string

SadClaw program ID

Default program

apiUrl

string

SadClaw API URL

Production API

Example:

Properties

wallet

Returns the wallet public key.

Methods

getTiers()

Get available VM tiers.

Returns: Array of VmTier

Example:

listVms()

List VMs owned by the wallet.

Returns: Array of VmInstance

Example:

getVm()

Get a specific VM by NFT mint.

Parameters:

Parameter
Type
Description

nftMint

string

NFT mint address

Returns: VmInstance or null if not found

Example:

purchaseVm()

Purchase a new VM.

PurchaseOptions:

Property
Type
Description
Default

tier

'MICRO' | 'SMALL' | 'STANDARD' | 'LARGE' | 'XLARGE'

VM tier

Required

durationHours

number

Duration in hours (1-720)

Required

region

string

Region code

'fsn1'

Returns: VmInstance

Example:

getSshCredentials()

Get SSH credentials for a VM.

Parameters:

Parameter
Type
Description

nftMint

string

NFT mint address

Returns: SshCredentials

Example:

extendVm()

Extend a VM's duration.

Parameters:

Parameter
Type
Description

nftMint

string

NFT mint address

additionalHours

number

Hours to add

Returns: Updated VmInstance

Example:

destroyVm()

Destroy a VM (burns the NFT).

Parameters:

Parameter
Type
Description

nftMint

string

NFT mint address

Example:

triangle-exclamation

Error Handling

The SDK throws typed errors:

TypeScript Support

The SDK is written in TypeScript and includes full type definitions.

Examples

Auto-scaling Agent

SSH Connection Helper

Last updated