When to Use Ledger for EVM
Use Ledger when:- You need maximum security for your keys
- You’re handling valuable assets
- You want physical confirmation of EIP-712 signatures
- 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
2. Select Ledger Account
- Scans the first 5 Ethereum 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 EIP-712 typed data on the device
- Never exposes private keys to your computer
4. Adapt Wallet Interface
signTypedData method that matches viem’s signature. The Ledger wallet’s signTypedData method has a slightly different signature, so this adapter:
- Wraps the Ledger wallet’s
signTypedDatamethod - Accepts the parameters in the format expected by the payment handler
- Casts them to
TypedDataDefinition(from viem) for the Ledger wallet - Ensures type compatibility between the payment handler and Ledger wallet interfaces
5. Make Payment
- The payment handler creates an EIP-712 typed data message
- The message is sent to your Ledger
- You physically confirm on the device
- The signed authorization is returned
- The facilitator submits the transaction
6. Cleanup
Ledger Setup Requirements
Ledger EIP-712 Documentation
Learn about EIP-712 structured data signing and how Ledger devices support it, including blind signing requirements.
Hardware Setup
- Connect your Ledger device via USB
- Unlock your Ledger with your PIN
- Open the Ethereum app on your Ledger
Software Settings
Critical: You must enable “Blind signing” in the Ethereum app settings:- Open Ethereum app on Ledger
- Go to Settings
- Enable “Blind signing”
- This is required for EIP-712 signing
Why Blind Signing?
EIP-712 structured data signing requires “blind signing” because:- The message structure isn’t standardized in older Ledger firmware
- The device shows hashes rather than full message content
- Newer firmware may support EIP-712 natively (check your version)
EIP-712 Signing on Ledger
When you sign an EIP-712 message, your Ledger will display:- Domain separator hash
- Message hash
- Your address
- The hashes match what you expect
- Your address is correct
- The payment amount (if shown)
Command Line Arguments
- First argument: Server port (default:
4021) - Second argument: Endpoint path (default:
weather)
Ledger vs Software Wallets
- Ledger: Maximum security, requires physical device, slower for automation
- Software: Fast, automated, but keys stored on computer
Security Considerations
- Physical confirmation: Every EIP-712 signature requires device approval
- Private keys never leave device: Keys stay secure even if your computer is compromised
- Hash verification: Always verify the hashes shown on your Ledger screen
- Blind signing warning: Understand what you’re signing when using blind signing
Error Handling
The example includes error handling for:- Missing Ledger connection
- Server connection failures
- Signature rejections on the device
- Invalid derivation paths
Troubleshooting
“Blind signing disabled” error:- Enable blind signing in Ethereum app settings on your Ledger
- Make sure the Ethereum app (not Solana) is open on your Ledger
- Check that you’re approving the correct transaction on the device
- Verify the payment amount matches what you expect
Related Resources
- Base Exact Payment - Software wallet example
- Package Reference - Ledger wallet adapter
- Ledger Documentation - Ledger setup and troubleshooting
- EIP-712 Specification - Structured data signing