Choose from our specialized SDKs for different development needs and blockchain integrations. Each SDK is designed to provide secure, reliable access to Ledger hardware wallets and blockchain networks.
JavaScript SDK
The Ledger JavaScript SDK provides comprehensive tools for web applications to interact with Ledger hardware wallets and blockchain networks. Perfect for building web-based cryptocurrency applications, DeFi platforms, and blockchain services.
// Install the SDK packages
npm install @ledgerhq/hw-transport-webhid
npm install @ledgerhq/hw-app-btc
npm install @ledgerhq/hw-app-eth
// Basic usage example
import TransportWebHID from "@ledgerhq/hw-transport-webhid";
import AppBtc from "@ledgerhq/hw-app-btc";
import AppEth from "@ledgerhq/hw-app-eth";
async function connectLedger() {
try {
// Create transport connection
const transport = await TransportWebHID.create();
// Initialize Bitcoin application
const appBtc = new AppBtc(transport);
// Get Bitcoin address
const { bitcoinAddress } = await appBtc.getWalletPublicKey("44'/0'/0'/0/0");
console.log("Bitcoin Address:", bitcoinAddress);
// Initialize Ethereum application
const appEth = new AppEth(transport);
// Get Ethereum address
const { address } = await appEth.getAddress("44'/60'/0'/0/0");
console.log("Ethereum Address:", address);
} catch (error) {
console.error("Connection failed:", error);
}
}
// Transaction signing example
async function signBitcoinTransaction() {
const transport = await TransportWebHID.create();
const appBtc = new AppBtc(transport);
const tx = await appBtc.createPaymentTransaction({
inputs: [[
"hash of input transaction",
index of the output,
"redeem script",
sequence number
]],
associatedKeysets: ["path of the input"],
outputScriptHex: "output script in hex",
lockTime: 0,
sigHashType: 1,
segwit: true
});
return tx;
}
React Components
Pre-built React components for quickly integrating Ledger functionality into your web applications with minimal setup. Perfect for modern React-based cryptocurrency applications and DeFi platforms.
import React from 'react';
import { LedgerProvider, useLedger } from '@ledgerhq/react-ledger';
// Main application component
function App() {
return (
<LedgerProvider
dappName="My Crypto App"
network="mainnet"
autoConnect={true}
>
<WalletInterface />
</LedgerProvider>
);
}
// Wallet connection component
function WalletConnection() {
const {
connect,
disconnect,
isConnected,
address,
balance,
error
} = useLedger();
return (
<div className="wallet-connection">
{isConnected ? (
<>
<div className="wallet-info">
<p>Connected: {address}</p>
<p>Balance: {balance} ETH</p>
</div>
<button onClick={disconnect} className="disconnect-btn">
Disconnect Ledger
</button>
</>
) : (
<button onClick={connect} className="connect-btn">
Connect Ledger Device
</button>
)}
{error && <p className="error">{error}</p>}
</div>
);
}
// Transaction signing component
function TransactionSigner({ to, amount }) {
const { signTransaction, isConnected } = useLedger();
const handleSign = async () => {
if (!isConnected) {
alert('Please connect your Ledger device first');
return;
}
try {
const signedTx = await signTransaction({
to: to,
value: amount,
gasLimit: '21000',
gasPrice: '20000000000'
});
console.log('Signed transaction:', signedTx);
// Broadcast transaction to network
} catch (error) {
console.error('Signing failed:', error);
}
};
return (
<button onClick={handleSign} disabled={!isConnected}>
Sign Transaction
</button>
);
}
Live Embedded SDK
Embed the full Ledger Live experience directly into your applications with customizable UI components and branding options. Perfect for exchanges, wallet services, and financial platforms.
import { LedgerLive } from '@ledgerhq/live-embedded';
// Initialize Ledger Live Embedded
const ledgerLive = new LedgerLive({
apiKey: 'your-api-key-here',
theme: 'dark', // 'dark' or 'light'
currency: 'USD',
language: 'en',
disableAccounts: false,
disableSend: false,
disableReceive: false,
disableSwap: false,
disableBuySell: false
});
// Mount to DOM element
ledgerLive.mount('#ledger-container');
// Listen for important events
ledgerLive.on('accountUpdate', (account) => {
console.log('Account updated:', account);
});
ledgerLive.on('transaction', (transaction) => {
console.log('New transaction:', transaction);
// Update your application state
});
ledgerLive.on('deviceConnection', (device) => {
console.log('Device connected:', device);
});
ledgerLive.on('error', (error) => {
console.error('Ledger Live error:', error);
});
// Programmatic controls
function showAccount(accountId) {
ledgerLive.showAccount(accountId);
}
function sendTransaction(transaction) {
ledgerLive.sendTransaction(transaction);
}
function disconnect() {
ledgerLive.unmount();
}
Mobile SDK
Build native mobile applications for iOS and Android with Ledger hardware wallet integration and secure Bluetooth communication. Perfect for mobile-first cryptocurrency experiences.
// React Native example
import React, { useEffect, useState } from 'react';
import { View, Text, Button } from 'react-native';
import LedgerModule from 'react-native-ledger-module';
function MobileWallet() {
const [devices, setDevices] = useState([]);
const [connectedDevice, setConnectedDevice] = useState(null);
const [address, setAddress] = useState('');
// Scan for Ledger devices
const scanDevices = async () => {
try {
const availableDevices = await LedgerModule.scanDevices();
setDevices(availableDevices);
} catch (error) {
console.error('Scan failed:', error);
}
};
// Connect to a device
const connectDevice = async (deviceId) => {
try {
const device = await LedgerModule.connect(deviceId);
setConnectedDevice(device);
// Get Ethereum address
const ethAddress = await LedgerModule.getEthereumAddress("44'/60'/0'/0/0");
setAddress(ethAddress);
} catch (error) {
console.error('Connection failed:', error);
}
};
// Sign transaction
const signTransaction = async (txData) => {
if (!connectedDevice) {
alert('No device connected');
return;
}
try {
const signature = await LedgerModule.signTransaction(txData);
return signature;
} catch (error) {
console.error('Signing failed:', error);
}
};
return (
<View>
<Text>Ledger Mobile Integration</Text>
<Button title="Scan for Devices" onPress={scanDevices} />
{devices.map(device => (
<Button
key={device.id}
title={`Connect to ${device.name}`}
onPress={() => connectDevice(device.id)}
/>
))}
{address && <Text>Connected: {address}</Text>}
</View>
);
}
// Android Native (Kotlin) example
/*
class LedgerService : Service() {
private lateinit var bleManager: BluetoothManager
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
bleManager = BluetoothManager(this)
bleManager.scanForLedgerDevices { device ->
// Handle discovered device
}
return START_STICKY
}
}
*/