ServerWallet is the composed wallet type for server-side (Node.js) applications. It extends WalletCore with server-specific payment receiving methods, plus all module methods mixed in.
Source:src/server.ts
Import:
// In Next.js API routes, always use dynamic import:const{ServerWallet}=awaitimport('@bsv/simple/server')// In standalone Node.js scripts:import{ServerWallet}from'@bsv/simple/server'
Important: In Next.js, use await import() instead of static import at the top of the file. Static imports cause Turbopack bundling issues.
Factory function that creates a fully-composed ServerWallet.
Parameter
Type
Required
Description
config.privateKey
string
Yes
Hex-encoded private key
config.network
Network
No
'main' (default) or 'testnet'
config.storageUrl
string
No
Storage service URL (default: 'https://storage.babbage.systems')
What happens:
Creates a PrivateKey and KeyDeriver from the hex key
Initializes WalletStorageManager and WalletSigner
Connects to the storage service via StorageClient
Mixes in all module methods
Example:
Server-Specific Methods
createPaymentRequest()
Generate a BRC-29 payment request that a browser wallet can fulfill.
Parameter
Type
Required
Description
options.satoshis
number
Yes
Amount requested
options.memo
string
No
Human-readable memo
Returns:
receivePayment()
Internalize a payment received from a browser wallet using the wallet payment protocol.
Parameter
Type
Required
Description
payment.tx
number[] | Uint8Array
Yes
AtomicBEEF transaction bytes
payment.senderIdentityKey
string
Yes
Sender's identity key
payment.derivationPrefix
string
Yes
BRC-29 derivation prefix
payment.derivationSuffix
string
Yes
BRC-29 derivation suffix
payment.outputIndex
number
Yes
Index of the payment output
payment.description
string
No
Transaction description
Shared Methods
ServerWallet inherits all methods from WalletCore and all module methods (tokens, inscriptions, messagebox, certification, overlay, DID, credentials). See the BrowserWallet page for the full method listing.
In production, set the private key via environment variable:
For development, use the handler factory which manages key persistence automatically:
Or for lower-level access, use generatePrivateKey() (no @bsv/sdk import needed):
Add .server-wallet.json to .gitignore.
Dependencies
ServerWallet requires @bsv/wallet-toolbox, which is a Node.js-only dependency. It must be listed in serverExternalPackages in next.config.ts to avoid Turbopack bundling it for the browser: