Comprehensive technical documentation for building secure applications with hardware wallet integration. Learn USB communication protocols, security architecture, and cryptographic key isolation.
Hardware wallets use HID (Human Interface Device) protocol over USB for secure communication. The APDU (Application Protocol Data Unit) format is used for command/response exchanges.
// USB HID Transport Implementation
import TransportWebUSB from "@ledgerhq/hw-transport-webusb";
async function connectToDevice() {
try {
// Request USB device permission
const transport = await TransportWebUSB.create();
// Send APDU command
const command = Buffer.from([
0xE0, // CLA: Instruction class
0x01, // INS: Get version
0x00, // P1: Parameter 1
0x00, // P2: Parameter 2
0x00 // Le: Expected response length
]);
// Exchange APDU
const response = await transport.exchange(command);
console.log("Device response:", response.toString('hex'));
return transport;
} catch (error) {
console.error("Connection failed:", error);
}
}
// Listen for device connection
TransportWebUSB.listen({
next: (event) => {
if (event.type === "add") {
console.log("Device connected:", event.descriptor);
}
},
error: (error) => console.error("USB error:", error),
complete: () => console.log("Listening stopped")
});Maximum packet size: 64 bytes
Fragmentation required for larger payloads
Default timeout: 30 seconds
User confirmation may extend duration
Download SDKs, documentation, and code examples