> ## Documentation Index
> Fetch the complete documentation index at: https://docs.phantom.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Phantom Server SDK

> Backend wallet infrastructure for programmatic wallet management

<Danger>
  The Server SDK is currently experimental and not ready for production use. Reach out to [partnerships@phantom.com](mailto:partnerships@phantom.com) for access.
</Danger>

## Overview

The Phantom Server SDK enables backend applications to securely create and manage wallets, sign transactions, and interact with multiple blockchains programmatically. This enterprise-grade solution is designed for server-side applications that require secure, scalable wallet infrastructure.

### What is the Phantom Server SDK?

The Server SDK is a Node.js library that provides programmatic access to Phantom's wallet infrastructure from your backend services. Unlike browser-based wallet interactions, the Server SDK allows you to:

* Create and manage wallets on behalf of your users
* Sign transactions without sending, or sign and submit in one step
* Sign messages for authentication and verification
* Submit transactions to multiple blockchains

### Key features

* Works with Solana, Ethereum, Polygon, Sui, Bitcoin, Base, and other major blockchains.
* Enterprise-grade security with cryptographic authentication and secure key management.
* Full API access for wallet creation, transaction signing, and blockchain interactions.
* Built to handle high-volume apps with efficient wallet management and pagination.

### Use cases

The Server SDK is ideal for:

* Gaming platforms: Create seamless blockchain gaming experiences without requiring users to manage wallets.
* DeFi apps: Automate complex DeFi interactions and transaction flows.
* NFT marketplaces: Enable smooth NFT minting and trading experiences.
* Enterprise solutions: Build blockchain apps for businesses with compliance requirements.

### Documentation overview

<Steps>
  <Step title="Get started">
    Learn the basics of the Server SDK, installation, and initial setup.

    [Get started →](/sdks/server-sdk/getting-started)
  </Step>

  <Step title="Integration guide">
    Follow our comprehensive guide to integrate the SDK into your backend app.

    [Integration guide →](/sdks/server-sdk/integration-guide)
  </Step>

  <Step title="Create wallets">
    Learn how to programmatically create and manage wallets for your users.

    [Create wallets →](/sdks/server-sdk/creating-wallets)
  </Step>

  <Step title="Sign transactions">
    Understand how to sign and submit transactions across different blockchains.

    [Sign transactions →](/sdks/server-sdk/signing-transactions)
  </Step>

  <Step title="Sign messages">
    Learn how to sign arbitrary messages for authentication and verification.

    [Sign messages →](/sdks/server-sdk/signing-messages)
  </Step>

  <Step title="API reference">
    Complete reference documentation for all SDK methods and types.

    [API reference →](/sdks/server-sdk/api-reference)
  </Step>
</Steps>

## Prerequisites

* Register your app: Sign up or log in to the [Phantom Portal](https://phantom.com/portal/) and register your app.
* Get your App ID:
  * In the portal, expand your app in the left navigation, then select **Set Up**.
  * Your App ID appears at the top of the page.

## Quick start

### Step 1: Set up environment variables

Create a `.env` file in your project root:

```env theme={null}
APP_ID=your-app-id
ORGANIZATION_ID=your-organization-id
PRIVATE_KEY=your-base58-encoded-private-key
```

### Step 2: Initialize the SDK

```typescript theme={null}
import { ServerSDK, NetworkId } from "@phantom/server-sdk";
import dotenv from "dotenv";

// Load environment variables
dotenv.config();

// Initialize the SDK
const sdk = new ServerSDK({
  organizationId: process.env.ORGANIZATION_ID!,
  apiPrivateKey: process.env.PRIVATE_KEY!,
  appId: process.env.APP_ID!,
});

// Create a wallet
const wallet = await sdk.createWallet("My First Wallet");
console.log("Wallet ID:", wallet.walletId);
console.log("Addresses:", wallet.addresses);

// Sign a message
const signature = await sdk.signMessage({
  walletId: wallet.walletId,
  message: "Hello, Phantom!",
  networkId: NetworkId.SOLANA_MAINNET,
});
console.log("Signature:", signature);
```

## Usage examples

### Creating a wallet

```typescript theme={null}
// Create a wallet with a custom name
const wallet = await sdk.createWallet("User Wallet 123");

// Access addresses for different chains
const solanaAddress = wallet.addresses.find(addr => addr.addressType === "Solana")?.address;
const ethereumAddress = wallet.addresses.find(addr => addr.addressType === "Ethereum")?.address;

console.log("Solana address:", solanaAddress);
console.log("Ethereum address:", ethereumAddress);
```

### Signing and sending transactions

#### Solana-native Web3.js transaction objects

```typescript theme={null}
import { Transaction, SystemProgram, PublicKey } from "@solana/web3.js";

// Create a Solana transaction
const transaction = new Transaction().add(
  SystemProgram.transfer({
    fromPubkey: new PublicKey(solanaAddress),
    toPubkey: new PublicKey(recipientAddress),
    lamports: 1000000, // 0.001 SOL
  }),
);

// Set transaction parameters
transaction.recentBlockhash = blockhash;
transaction.feePayer = new PublicKey(solanaAddress);

// Sign and send the transaction
const signedTx = await sdk.signAndSendTransaction({
  walletId: wallet.walletId,
  transaction,
  networkId: NetworkId.SOLANA_MAINNET,
});

console.log("Signed transaction:", signedTx.rawTransaction);
```

#### Ethereum/EVM-transaction objects

```typescript theme={null}
// Viem transaction object
const evmTransaction = {
  to: "0x742d35Cc6634C0532925a3b8D4C8db86fB5C4A7E",
  value: 1000000000000000000n, // 1 ETH in wei
  data: "0x",
  gasLimit: 21000n,
};

const signedEvmTx = await sdk.signAndSendTransaction({
  walletId: wallet.walletId,
  transaction: evmTransaction, // Native EVM transaction object
  networkId: NetworkId.ETHEREUM_MAINNET,
});
```

#### Raw formats-hex strings and bytes

```typescript theme={null}
// Hex string transaction
await sdk.signAndSendTransaction({
  walletId: wallet.walletId,
  transaction: "0x02f8710182013685012a05f2008301388094742d35cc...", // Raw hex
  networkId: NetworkId.ETHEREUM_MAINNET,
});

// Raw bytes
const transactionBytes = new Uint8Array([1, 2, 3, 4, 5 /* ... */]);
await sdk.signAndSendTransaction({
  walletId: wallet.walletId,
  transaction: transactionBytes,
  networkId: NetworkId.SOLANA_MAINNET,
});
```

### Signing messages

```typescript theme={null}
const solanaSignature = await sdk.signMessage({
  walletId: wallet.walletId,
  message: "Please sign this message to authenticate",
  networkId: NetworkId.SOLANA_MAINNET,
});

// Unicode messages work too
const unicodeSignature = await sdk.signMessage({
  walletId: wallet.walletId,
  message: "Welcome to Web3! 你好世界", // Unicode text
  networkId: NetworkId.SOLANA_MAINNET,
});

const ethSignature = await sdk.signMessage({
  walletId: wallet.walletId,
  message: "Sign in to our dApp",
  networkId: NetworkId.ETHEREUM_MAINNET,
});
```

### Managing wallets

```typescript theme={null}
// Get all wallets for your organization with pagination
const result = await sdk.getWallets(20, 0); // limit: 20, offset: 0

console.log(`Total wallets: ${result.totalCount}`);
console.log("Wallets:", result.wallets);

// Get addresses for a specific wallet
const addresses = await sdk.getWalletAddresses(walletId);

// Get specific addresses by derivation path
const customAddresses = await sdk.getWalletAddresses(
  walletId,
  ["m/44'/501'/0'/0'", "m/44'/60'/0'/0/0"], // Solana and Ethereum
);
```

## Network support

The Server SDK uses the `NetworkId` enum to identify blockchain networks for signing transactions and messages.

### Solana networks

* `NetworkId.SOLANA_MAINNET`: Solana mainnet-beta
* `NetworkId.SOLANA_DEVNET`: Solana devnet
* `NetworkId.SOLANA_TESTNET`: Solana testnet

### Ethereum networks

* `NetworkId.ETHEREUM_MAINNET`: Ethereum mainnet
* `NetworkId.ETHEREUM_SEPOLIA`: Sepolia testnet

### Polygon networks

* `NetworkId.POLYGON_MAINNET`: Polygon mainnet (Chain ID: 137)
* `NetworkId.POLYGON_AMOY`: Polygon Amoy testnet (Chain ID: 80002)

### Base networks

* `NetworkId.BASE_MAINNET`: Base mainnet (Chain ID: 8453)
* `NetworkId.BASE_SEPOLIA`: Base Sepolia testnet (Chain ID: 84532)

### Arbitrum networks

* `NetworkId.ARBITRUM_ONE`: Arbitrum One (Chain ID: 42161)
* `NetworkId.ARBITRUM_SEPOLIA`: Arbitrum Sepolia testnet (Chain ID: 421614)

### Monad networks

* `NetworkId.MONAD_MAINNET`: Monad mainnet (Chain ID: 143)
* `NetworkId.MONAD_TESTNET`: Monad testnet (Chain ID: 10143)

### Future support

* `NetworkId.BITCOIN_MAINNET`: Bitcoin mainnet
* `NetworkId.BITCOIN_TESTNET`: Bitcoin testnet
* `NetworkId.SUI_MAINNET`: Sui mainnet
* `NetworkId.SUI_TESTNET`: Sui testnet
* `NetworkId.SUI_DEVNET`: Sui devnet

## Support

* Documentation issues: Open an issue on our [GitHub repository](https://github.com/phantom/docs).
* Access requests: Contact [partnerships@phantom.com](mailto:partnerships@phantom.com).
* Technical support: Available for enterprise customers.

***

Ready to get started? Check out our [Get started](/sdks/server-sdk/getting-started) guide to begin building with the Phantom Server SDK.

## What you can do

<CardGroup cols={3}>
  <Card title="Get started" icon="rocket" href="/sdks/server-sdk/getting-started">
    Install and initialize the Server SDK in your backend
  </Card>

  <Card title="Create wallets" icon="wallet" href="/sdks/server-sdk/creating-wallets">
    Programmatically create and manage wallets for your users
  </Card>

  <Card title="Sign transactions" icon="paper-plane" href="/sdks/server-sdk/signing-transactions">
    Sign and send transactions across multiple blockchains
  </Card>
</CardGroup>

<CardGroup cols={3}>
  <Card title="Sign messages" icon="signature" href="/sdks/server-sdk/signing-messages">
    Sign messages for authentication and verification
  </Card>

  <Card title="Integration guide" icon="book" href="/sdks/server-sdk/integration-guide">
    Complete guide to integrating the Server SDK
  </Card>

  <Card title="API reference" icon="code" href="/sdks/server-sdk/api-reference">
    Complete API documentation for all SDK methods
  </Card>
</CardGroup>

## Additional resources

<CardGroup cols={3}>
  <Card title="SDK overview" icon="book" href="/wallet-sdks-overview">
    Compare all Phantom SDKs and choose the right one
  </Card>

  <Card title="Request access" icon="envelope" href="mailto:partnerships@phantom.com">
    Contact us to get access to the Server SDK
  </Card>

  <Card title="Developer support" icon="life-ring" href="https://docs.google.com/forms/d/e/1FAIpQLSeHWETFkEJbHQCF-lnl1AHmVQPuyfC0HbnxjDjIp6VYV1sBZQ/viewform">
    Get help from our developer support team
  </Card>
</CardGroup>

## Disclaimers

The Server SDK is a beta version, and Phantom will not be liable for any losses or damages suffered by you or your end users.
Any suggestions, enhancement requests, recommendations, or other feedback provided by you regarding the Server SDK will be the exclusive property of Phantom. By using this beta version and providing feedback, you agree to assign any rights in that feedback to Phantom.
