When to Use Ledger
Use Ledger when:- You need maximum security for your keys
- You’re handling valuable assets or high-value transactions
- You want physical confirmation of transactions
- You’re building applications that prioritize security
- You need programmatic or automated transactions
- You’re building automated systems
- You’re testing or developing quickly
Full Example
Step-by-Step Breakdown
1. Create User Interface
- Displaying prompts and instructions
- Showing account selection
- Providing feedback during the payment process
2. Select Ledger Account
- Scans the first 5 Solana accounts on your Ledger
- Displays them in the terminal
- Prompts you to select which account to use
- Returns the selected account’s address and derivation path
3. Create Ledger Wallet
- Uses the selected derivation path
- Signs transactions on the device
- Never exposes private keys to your computer
4. Make Payment
- The payment handler creates a transaction
- The transaction is sent to your Ledger
- You physically confirm on the device
- The signed transaction is submitted
5. Cleanup
Ledger Setup Requirements
Ledger Solana App Documentation
For detailed setup instructions for the Solana app on Ledger devices, see the official Ledger support documentation.
Hardware Setup
- Connect your Ledger device via USB
- Unlock your Ledger with your PIN
- Open the Solana app on your Ledger
Software Requirements
- Ledger Live installed (or Ledger CLI tools)
- Node.js with USB support (works on macOS, Linux, Windows)
Command Line Arguments
- First argument: Server port (default:
3000) - Second argument: Endpoint path (default:
protected)
Security Considerations
- Physical confirmation: Every transaction requires you to approve on the device
- Private keys never leave device: Keys stay secure even if your computer is compromised
- Transaction verification: Always verify transaction details on the Ledger screen before approving
Error Handling
The example includes error handling for:- Missing Ledger connection
- Server connection failures
- Transaction rejections on the device
Comparison: Ledger vs Software Wallets
- Ledger: Maximum security, requires physical device, slower for automation
- Software: Fast, automated, but keys stored on computer
Related Resources
- Solana Exact Payment - Software wallet example
- Package Reference - Ledger wallet adapter
- Ledger Documentation - Ledger setup and troubleshooting