Skip to main content
The Server SDK is currently experimental and not ready for production use. Reach out to partnerships@phantom.com for access.
This page provides a comprehensive reference for all methods, types, and utilities available in the Phantom Server SDK.

ServerSDK class

Constructor

Creates a new instance of the Server SDK.

Parameters

config (ServerSDKConfig): Configuration object.

ServerSDKConfig type

Example

Methods

createWallet

Creates a new wallet with addresses for multiple blockchains.

Parameters

walletName (string, optional): Custom name for the wallet.

Returns

Promise<CreateWalletResult>: Object containing:
  • walletId (string): Unique identifier for the wallet.
  • addresses (WalletAddress[]): Array of blockchain addresses.

Example

getWallets

Lists all wallets in your organization with pagination support.

Parameters

  • limit (number, optional): Number of results per page (default: 20, max: 100).
  • offset (number, optional): Pagination offset (default: 0).

Returns

Promise<GetWalletsResult>: Object containing:
  • wallets (Wallet[]): Array of wallet objects.
  • totalCount (number): Total number of wallets.
  • limit (number): Results per page.
  • offset (number): Current offset.

Example

getWalletAddresses

Retrieves addresses for a specific wallet.

Parameters

  • walletId (string): The wallet ID.
  • derivationPaths (string[], optional): Custom derivation paths.

Returns

Promise<WalletAddress[]>: Array of wallet addresses.

Example

signTransaction

Signs a transaction without submitting it to the network. Use this when you want to broadcast the transaction yourself.

Parameters

  • walletId (string): The wallet ID to sign with.
  • transaction (any): The transaction to sign. Accepts @solana/web3.js transaction objects, EVM transaction objects (viem or ethers.js), hex strings, or raw bytes.
  • networkId (NetworkId): The target network.
  • derivationIndex (number, optional): Account derivation index (defaults to 0).
  • account (string, optional): Specific account address for simulation.

Returns

Promise<ParsedTransactionResult>: Object containing:
  • rawTransaction (string): The signed transaction payload.

Example

signAndSendTransaction

Signs a transaction and submits it to the network.

Parameters

  • walletId (string): The wallet ID to sign with.
  • transaction (any): The transaction to sign. Accepts @solana/web3.js transaction objects, EVM transaction objects (viem or ethers.js), hex strings, or raw bytes.
  • networkId (NetworkId): The target network.
  • derivationIndex (number, optional): Account derivation index (defaults to 0).
  • account (string, optional): Specific account address for simulation.

Returns

Promise<ParsedTransactionResult>: Object containing:
  • rawTransaction (string): The signed transaction payload.
  • hash (string): The transaction hash (when submitted to the network).

Example

signMessage

Signs an arbitrary message.

Parameters

  • walletId (string): The wallet ID to sign with.
  • message (string): The message to sign.
  • networkId (NetworkId): The network context for signing.

Returns

Promise<string>: Base64-encoded signature.

Example

Types

CreateWalletResult

WalletAddress

Wallet

GetWalletsResult

ParsedTransactionResult

ParsedSignatureResult

NetworkId enum

The NetworkId enum specifies which blockchain network to use:

Solana networks

Ethereum networks

Other EVM networks

Future networks

Utility functions

Network information

getNetworkDescription

Get a human-readable description of a network.

getSupportedNetworkIds

Get all supported network IDs.

getNetworkIdsByChain

Get all networks for a specific blockchain.

supportsTransactionSubmission

Check if a network supports automatic transaction submission.

Error handling

The SDK throws errors for various failure scenarios. Always wrap SDK calls in try-catch blocks:

Common errors

Error types

  1. Configuration errors: Missing or invalid configuration.
  2. Authentication errors: Invalid credentials or unauthorized access.
  3. Validation errors: Invalid parameters or data.
  4. Network errors: Connection or timeout issues.
  5. Wallet errors: Wallet not found or access denied.

Rate limits

The Phantom API implements rate limiting to ensure fair usage:
  • Wallet Creation: Limited per organization.
  • Transaction Signing: Limited per wallet.
  • API calls: General rate limit per organization.
Handle rate limit errors gracefully:

Complete example

Here’s a complete example using multiple SDK features:

CAIP-2 network utilities

The SDK includes utilities for working with CAIP-2 network identifiers:

License

This SDK is distributed under the MIT License. See the LICENSE file for details.

Next steps

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.