0
# Advanced Features
1
2
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.
3
4
## Capabilities
5
6
### Ethereum 2.0 Support
7
8
Support for Ethereum 2.0 operations including validator key generation and withdrawal management.
9
10
```typescript { .api }
11
/**
12
* Get Ethereum 2.0 public key for validator operations
13
* @param path - BIP32 derivation path for ETH2 key
14
* @param boolDisplay - Optionally display key on device screen
15
* @returns ETH2 public key
16
*/
17
eth2GetPublicKey(path: string, boolDisplay?: boolean): Promise<{publicKey: string}>;
18
19
/**
20
* Set withdrawal index for ETH2 validator operations
21
* @param withdrawalIndex - Withdrawal index for validator
22
* @returns Success status
23
*/
24
eth2SetWithdrawalIndex(withdrawalIndex: number): Promise<boolean>;
25
```
26
27
**Usage Examples:**
28
29
```typescript
30
// Generate ETH2 validator public key
31
const eth2Key = await eth.eth2GetPublicKey("12381/3600/0/0");
32
console.log(eth2Key.publicKey); // BLS public key for ETH2
33
34
// Display ETH2 key on device for verification
35
const eth2Key = await eth.eth2GetPublicKey("12381/3600/0/0", true);
36
37
// Set withdrawal index for validator
38
const result = await eth.eth2SetWithdrawalIndex(42);
39
console.log(result); // true if successful
40
```
41
42
### EIP-1024 Encryption
43
44
Support for EIP-1024 public key encryption including key generation and shared secret calculation.
45
46
```typescript { .api }
47
/**
48
* Get EIP-1024 public encryption key
49
* @param path - BIP32 derivation path for encryption key
50
* @param boolDisplay - Optionally display key on device screen
51
* @returns Public encryption key
52
*/
53
getEIP1024PublicEncryptionKey(path: string, boolDisplay?: boolean): Promise<{publicKey: string}>;
54
55
/**
56
* Calculate EIP-1024 shared secret with remote public key
57
* @param path - BIP32 derivation path for local key
58
* @param remotePublicKeyHex - Remote party's public key as hex
59
* @param boolDisplay - Optionally display operation on device screen
60
* @returns Shared secret for encryption/decryption
61
*/
62
getEIP1024SharedSecret(
63
path: string,
64
remotePublicKeyHex: string,
65
boolDisplay?: boolean
66
): Promise<{sharedSecret: string}>;
67
```
68
69
**Usage Examples:**
70
71
```typescript
72
// Generate encryption public key
73
const encryptionKey = await eth.getEIP1024PublicEncryptionKey("44'/60'/0'/0/0");
74
console.log(encryptionKey.publicKey); // Public key for encryption
75
76
// Calculate shared secret for secure communication
77
const sharedSecret = await eth.getEIP1024SharedSecret(
78
"44'/60'/0'/0/0",
79
"0x04a1b2c3d4e5f6...", // Remote party's public key
80
false
81
);
82
console.log(sharedSecret.sharedSecret); // Shared secret for encryption
83
84
// Display shared secret calculation on device
85
const sharedSecret = await eth.getEIP1024SharedSecret(
86
"44'/60'/0'/0/0",
87
remotePublicKey,
88
true // Show on device screen
89
);
90
```
91
92
### Uniswap Integration
93
94
Support for Uniswap Universal Router transactions with automatic command parsing and plugin loading.
95
96
```typescript { .api }
97
/**
98
* Check if Uniswap transaction is supported for clear signing
99
* @param calldata - Transaction calldata as hex string
100
* @param to - Transaction recipient address
101
* @param chainId - Blockchain chain ID
102
* @param commandsAndTokens - Parsed commands and tokens
103
* @returns True if transaction is supported
104
*/
105
function isSupported(
106
calldata: `0x${string}`,
107
to: string | undefined,
108
chainId: number,
109
commandsAndTokens: CommandsAndTokens
110
): boolean;
111
112
/**
113
* Extract commands and tokens from Uniswap calldata
114
* @param calldata - Uniswap Universal Router calldata
115
* @param chainId - Blockchain chain ID
116
* @returns Parsed commands and tokens
117
*/
118
function getCommandsAndTokensFromUniswapCalldata(
119
calldata: `0x${string}`,
120
chainId: number
121
): CommandsAndTokens;
122
123
/**
124
* Load Uniswap plugin information for transaction
125
* @param transaction - Transaction object
126
* @param chainId - Blockchain chain ID
127
* @param userConfig - Optional user configuration
128
* @returns Plugin data and token descriptors
129
*/
130
function loadInfosForUniswap(
131
transaction: Transaction,
132
chainId: number,
133
userConfig?: LoadConfig
134
): Promise<{
135
pluginData?: Buffer;
136
tokenDescriptors?: Buffer[];
137
}>;
138
```
139
140
**Usage Examples:**
141
142
```typescript
143
// Parse Uniswap transaction
144
const commandsAndTokens = getCommandsAndTokensFromUniswapCalldata(
145
"0x3593564c000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000625c6520000000000000000000000000000000000000000000000000000000000000000020b080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000006f05b59d3b200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000006f05b59d3b20000000000000000000000000000000000000000000000000000054eb1e0e72e75900000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2000000000000000000000000a0b86a33e6776a9fedac4f0c0bfb3f4a9d7d3e7",
146
1 // Ethereum mainnet
147
);
148
149
// Check if transaction is supported
150
const isUniswapSupported = isSupported(
151
calldataHex,
152
"0x68b3465833fb72A70ecDF485E0e4C7bD8665Fc45", // Uniswap Universal Router
153
1,
154
commandsAndTokens
155
);
156
157
if (isUniswapSupported) {
158
// Load plugin information
159
const uniswapInfo = await loadInfosForUniswap(
160
transaction,
161
1,
162
loadConfig
163
);
164
165
console.log(uniswapInfo.pluginData); // Plugin data buffer
166
console.log(uniswapInfo.tokenDescriptors); // Token descriptor buffers
167
}
168
```
169
170
### Domain Resolution
171
172
Support for domain name resolution flow including ENS and other domain systems.
173
174
```typescript { .api }
175
/**
176
* Execute domain resolution flow for transaction enhancement
177
* @param appBinding - Eth instance for device communication
178
* @param domainDescriptor - Domain information to resolve
179
* @returns Promise that resolves when flow completes
180
*/
181
function domainResolutionFlow(
182
appBinding: Eth,
183
domainDescriptor: DomainDescriptor
184
): Promise<void>;
185
186
interface DomainDescriptor {
187
/** Registry type (e.g., "ens") */
188
registry: string;
189
/** Domain name (e.g., "example.eth") */
190
domain: string;
191
/** Resolved address */
192
address: string;
193
}
194
```
195
196
**Usage Example:**
197
198
```typescript
199
import { domainResolutionFlow } from "@ledgerhq/hw-app-eth";
200
201
// Resolve ENS domain for transaction display
202
await domainResolutionFlow(eth, {
203
registry: "ens",
204
domain: "vitalik.eth",
205
address: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
206
});
207
208
// The domain information is now available for clear signing display
209
```
210
211
### Advanced EIP712 Features
212
213
Advanced EIP-712 capabilities including custom filtering and display configuration.
214
215
```typescript { .api }
216
/**
217
* Get app version information for EIP-712 compatibility
218
* @param transport - Hardware wallet transport
219
* @returns App version information
220
*/
221
function getAppAndVersion(transport: Transport): Promise<{version: string}>;
222
223
/**
224
* Create filter display buffers for EIP-712 message customization
225
* @param displayName - Custom display name
226
* @param sig - Filter signature
227
* @returns Display name and signature buffers
228
*/
229
function getFilterDisplayNameAndSigBuffers(displayName: string, sig: string): any;
230
231
/**
232
* Create V2 filter payload for advanced EIP-712 filtering
233
* @param format - Filter format specification
234
* @param coinRef - Coin reference identifier
235
* @param coinRefsTokensMap - Token reference mapping
236
* @param displayNameBuffer - Display name buffer
237
* @param sigBuffer - Signature buffer
238
* @returns V2 filter payload buffer
239
*/
240
function getPayloadForFilterV2(
241
format: any,
242
coinRef: number,
243
coinRefsTokensMap: any,
244
displayNameBuffer: Buffer,
245
sigBuffer: Buffer
246
): Buffer;
247
```
248
249
**Usage Examples:**
250
251
```typescript
252
// Check app version for EIP-712 compatibility
253
const appInfo = await getAppAndVersion(transport);
254
console.log(appInfo.version); // "1.10.3"
255
256
// Create custom filter for EIP-712 display
257
const filterBuffers = getFilterDisplayNameAndSigBuffers(
258
"Custom Token Transfer",
259
"0x1234567890abcdef..."
260
);
261
262
// Create advanced V2 filter payload
263
const payload = getPayloadForFilterV2(
264
{ type: "erc20", decimals: 18 },
265
1, // Coin reference
266
tokenMap,
267
displayNameBuffer,
268
signatureBuffer
269
);
270
```
271
272
## Advanced Types and Constants
273
274
```typescript { .api }
275
interface CommandsAndTokens {
276
/** Array of Uniswap command types */
277
commands: UniswapSupportedCommand[];
278
/** Array of token addresses involved */
279
tokens: string[];
280
}
281
282
type UniswapSupportedCommand =
283
| "V3_SWAP_EXACT_IN"
284
| "V3_SWAP_EXACT_OUT"
285
| "V2_SWAP_EXACT_IN"
286
| "V2_SWAP_EXACT_OUT"
287
| "WRAP_ETH"
288
| "UNWRAP_WETH";
289
290
interface StructImplemData {
291
/** Structure implementation configuration */
292
structType: string;
293
structData: any;
294
}
295
296
interface StructDefData {
297
/** Structure definition data */
298
name: string;
299
type: string;
300
arraySize?: number;
301
}
302
303
interface FilteringInfoShowField {
304
/** Field path to display */
305
path: string;
306
/** Optional display name override */
307
displayName?: string;
308
}
309
310
interface FilteringInfoDiscardField {
311
/** Field path to hide from display */
312
path: string;
313
}
314
315
interface FilteringInfoContractName {
316
/** Contract name for display */
317
name: string;
318
/** Contract signature for verification */
319
signature: string;
320
}
321
```
322
323
## Constants and Configurations
324
325
```typescript { .api }
326
/** Uniswap Universal Router contract address */
327
const UNISWAP_UNIVERSAL_ROUTER_ADDRESS: string;
328
329
/** Uniswap execute method selector */
330
const UNISWAP_EXECUTE_SELECTOR: string;
331
332
/** WETH addresses per chain ID */
333
const WETH_PER_CHAIN_ID: Record<number, string>;
334
335
/** Uniswap command mappings */
336
const UNISWAP_COMMANDS: Record<string, number>;
337
338
/** Swap command identifiers */
339
const SWAP_COMMANDS: number[];
340
341
/** EIP-712 type property definitions */
342
const EIP712_TYPE_PROPERTIES: Record<string, any>;
343
344
/** EIP-712 type encoder functions */
345
const EIP712_TYPE_ENCODERS: Record<string, Function>;
346
```
347
348
**Usage Examples:**
349
350
```typescript
351
// Check if transaction is to Uniswap Universal Router
352
if (transaction.to === UNISWAP_UNIVERSAL_ROUTER_ADDRESS) {
353
console.log("This is a Uniswap transaction");
354
}
355
356
// Get WETH address for specific chain
357
const wethAddress = WETH_PER_CHAIN_ID[1]; // Ethereum mainnet WETH
358
console.log(wethAddress); // "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
359
360
// Check if command is a swap command
361
const commandId = UNISWAP_COMMANDS["V3_SWAP_EXACT_IN"];
362
const isSwap = SWAP_COMMANDS.includes(commandId);
363
console.log(isSwap); // true
364
```