The Server SDK is currently experimental and not ready for production use. Reach out to partnerships@phantom.com for access.
ServerSDK class
Constructor
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.jstransaction 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.jstransaction 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
TheNetworkId 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
- Configuration errors: Missing or invalid configuration.
- Authentication errors: Invalid credentials or unauthorized access.
- Validation errors: Invalid parameters or data.
- Network errors: Connection or timeout issues.
- 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.