Ledger Hardware Wallet Ethereum Application API that enables developers to integrate Ledger wallet support into Ethereum applications for address generation, transaction signing, message signing, and various Ethereum operations.
—
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Pending
The risk profile of this skill
Advanced capabilities including Ethereum 2.0 support, EIP-1024 encryption, Uniswap integration, domain resolution, and EIP712 advanced features. These features extend the core functionality for specialized use cases and modern Ethereum applications.
Support for Ethereum 2.0 operations including validator key generation and withdrawal management.
/**
* Get Ethereum 2.0 public key for validator operations
* @param path - BIP32 derivation path for ETH2 key
* @param boolDisplay - Optionally display key on device screen
* @returns ETH2 public key
*/
eth2GetPublicKey(path: string, boolDisplay?: boolean): Promise<{publicKey: string}>;
/**
* Set withdrawal index for ETH2 validator operations
* @param withdrawalIndex - Withdrawal index for validator
* @returns Success status
*/
eth2SetWithdrawalIndex(withdrawalIndex: number): Promise<boolean>;Usage Examples:
// Generate ETH2 validator public key
const eth2Key = await eth.eth2GetPublicKey("12381/3600/0/0");
console.log(eth2Key.publicKey); // BLS public key for ETH2
// Display ETH2 key on device for verification
const eth2Key = await eth.eth2GetPublicKey("12381/3600/0/0", true);
// Set withdrawal index for validator
const result = await eth.eth2SetWithdrawalIndex(42);
console.log(result); // true if successfulSupport for EIP-1024 public key encryption including key generation and shared secret calculation.
/**
* Get EIP-1024 public encryption key
* @param path - BIP32 derivation path for encryption key
* @param boolDisplay - Optionally display key on device screen
* @returns Public encryption key
*/
getEIP1024PublicEncryptionKey(path: string, boolDisplay?: boolean): Promise<{publicKey: string}>;
/**
* Calculate EIP-1024 shared secret with remote public key
* @param path - BIP32 derivation path for local key
* @param remotePublicKeyHex - Remote party's public key as hex
* @param boolDisplay - Optionally display operation on device screen
* @returns Shared secret for encryption/decryption
*/
getEIP1024SharedSecret(
path: string,
remotePublicKeyHex: string,
boolDisplay?: boolean
): Promise<{sharedSecret: string}>;Usage Examples:
// Generate encryption public key
const encryptionKey = await eth.getEIP1024PublicEncryptionKey("44'/60'/0'/0/0");
console.log(encryptionKey.publicKey); // Public key for encryption
// Calculate shared secret for secure communication
const sharedSecret = await eth.getEIP1024SharedSecret(
"44'/60'/0'/0/0",
"0x04a1b2c3d4e5f6...", // Remote party's public key
false
);
console.log(sharedSecret.sharedSecret); // Shared secret for encryption
// Display shared secret calculation on device
const sharedSecret = await eth.getEIP1024SharedSecret(
"44'/60'/0'/0/0",
remotePublicKey,
true // Show on device screen
);Support for Uniswap Universal Router transactions with automatic command parsing and plugin loading.
/**
* Check if Uniswap transaction is supported for clear signing
* @param calldata - Transaction calldata as hex string
* @param to - Transaction recipient address
* @param chainId - Blockchain chain ID
* @param commandsAndTokens - Parsed commands and tokens
* @returns True if transaction is supported
*/
function isSupported(
calldata: `0x${string}`,
to: string | undefined,
chainId: number,
commandsAndTokens: CommandsAndTokens
): boolean;
/**
* Extract commands and tokens from Uniswap calldata
* @param calldata - Uniswap Universal Router calldata
* @param chainId - Blockchain chain ID
* @returns Parsed commands and tokens
*/
function getCommandsAndTokensFromUniswapCalldata(
calldata: `0x${string}`,
chainId: number
): CommandsAndTokens;
/**
* Load Uniswap plugin information for transaction
* @param transaction - Transaction object
* @param chainId - Blockchain chain ID
* @param userConfig - Optional user configuration
* @returns Plugin data and token descriptors
*/
function loadInfosForUniswap(
transaction: Transaction,
chainId: number,
userConfig?: LoadConfig
): Promise<{
pluginData?: Buffer;
tokenDescriptors?: Buffer[];
}>;Usage Examples:
// Parse Uniswap transaction
const commandsAndTokens = getCommandsAndTokensFromUniswapCalldata(
"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000625c6520000000000000000000000000000000000000000000000000000000000000000020b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000054eb1e0e72e75900000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86a33e6776a9fedac4f0c0bfb3f4a9d7d3e7",
1 // Ethereum mainnet
);
// Check if transaction is supported
const isUniswapSupported = isSupported(
calldataHex,
"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", // Uniswap Universal Router
1,
commandsAndTokens
);
if (isUniswapSupported) {
// Load plugin information
const uniswapInfo = await loadInfosForUniswap(
transaction,
1,
loadConfig
);
console.log(uniswapInfo.pluginData); // Plugin data buffer
console.log(uniswapInfo.tokenDescriptors); // Token descriptor buffers
}Support for domain name resolution flow including ENS and other domain systems.
/**
* Execute domain resolution flow for transaction enhancement
* @param appBinding - Eth instance for device communication
* @param domainDescriptor - Domain information to resolve
* @returns Promise that resolves when flow completes
*/
function domainResolutionFlow(
appBinding: Eth,
domainDescriptor: DomainDescriptor
): Promise<void>;
interface DomainDescriptor {
/** Registry type (e.g., "ens") */
registry: string;
/** Domain name (e.g., "example.eth") */
domain: string;
/** Resolved address */
address: string;
}Usage Example:
import { domainResolutionFlow } from "@ledgerhq/hw-app-eth";
// Resolve ENS domain for transaction display
await domainResolutionFlow(eth, {
registry: "ens",
domain: "vitalik.eth",
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
});
// The domain information is now available for clear signing displayAdvanced EIP-712 capabilities including custom filtering and display configuration.
/**
* Get app version information for EIP-712 compatibility
* @param transport - Hardware wallet transport
* @returns App version information
*/
function getAppAndVersion(transport: Transport): Promise<{version: string}>;
/**
* Create filter display buffers for EIP-712 message customization
* @param displayName - Custom display name
* @param sig - Filter signature
* @returns Display name and signature buffers
*/
function getFilterDisplayNameAndSigBuffers(displayName: string, sig: string): any;
/**
* Create V2 filter payload for advanced EIP-712 filtering
* @param format - Filter format specification
* @param coinRef - Coin reference identifier
* @param coinRefsTokensMap - Token reference mapping
* @param displayNameBuffer - Display name buffer
* @param sigBuffer - Signature buffer
* @returns V2 filter payload buffer
*/
function getPayloadForFilterV2(
format: any,
coinRef: number,
coinRefsTokensMap: any,
displayNameBuffer: Buffer,
sigBuffer: Buffer
): Buffer;Usage Examples:
// Check app version for EIP-712 compatibility
const appInfo = await getAppAndVersion(transport);
console.log(appInfo.version); // "1.10.3"
// Create custom filter for EIP-712 display
const filterBuffers = getFilterDisplayNameAndSigBuffers(
"Custom Token Transfer",
"0x1234567890abcdef..."
);
// Create advanced V2 filter payload
const payload = getPayloadForFilterV2(
{ type: "erc20", decimals: 18 },
1, // Coin reference
tokenMap,
displayNameBuffer,
signatureBuffer
);interface CommandsAndTokens {
/** Array of Uniswap command types */
commands: UniswapSupportedCommand[];
/** Array of token addresses involved */
tokens: string[];
}
type UniswapSupportedCommand =
| "V3_SWAP_EXACT_IN"
| "V3_SWAP_EXACT_OUT"
| "V2_SWAP_EXACT_IN"
| "V2_SWAP_EXACT_OUT"
| "WRAP_ETH"
| "UNWRAP_WETH";
interface StructImplemData {
/** Structure implementation configuration */
structType: string;
structData: any;
}
interface StructDefData {
/** Structure definition data */
name: string;
type: string;
arraySize?: number;
}
interface FilteringInfoShowField {
/** Field path to display */
path: string;
/** Optional display name override */
displayName?: string;
}
interface FilteringInfoDiscardField {
/** Field path to hide from display */
path: string;
}
interface FilteringInfoContractName {
/** Contract name for display */
name: string;
/** Contract signature for verification */
signature: string;
}/** Uniswap Universal Router contract address */
const UNISWAP_UNIVERSAL_ROUTER_ADDRESS: string;
/** Uniswap execute method selector */
const UNISWAP_EXECUTE_SELECTOR: string;
/** WETH addresses per chain ID */
const WETH_PER_CHAIN_ID: Record<number, string>;
/** Uniswap command mappings */
const UNISWAP_COMMANDS: Record<string, number>;
/** Swap command identifiers */
const SWAP_COMMANDS: number[];
/** EIP-712 type property definitions */
const EIP712_TYPE_PROPERTIES: Record<string, any>;
/** EIP-712 type encoder functions */
const EIP712_TYPE_ENCODERS: Record<string, Function>;Usage Examples:
// Check if transaction is to Uniswap Universal Router
if (transaction.to === UNISWAP_UNIVERSAL_ROUTER_ADDRESS) {
console.log("This is a Uniswap transaction");
}
// Get WETH address for specific chain
const wethAddress = WETH_PER_CHAIN_ID[1]; // Ethereum mainnet WETH
console.log(wethAddress); // "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
// Check if command is a swap command
const commandId = UNISWAP_COMMANDS["V3_SWAP_EXACT_IN"];
const isSwap = SWAP_COMMANDS.includes(commandId);
console.log(isSwap); // true