UNPKG

27.7 kBMarkdownView Raw
1<img src="https://user-images.githubusercontent.com/4631227/191834116-59cf590e-25cc-4956-ae5c-812ea464f324.png" height="100" />
2
3[GitHub](https://github.com/LedgerHQ/ledger-live/),
4[Ledger Devs Discord](https://developers.ledger.com/discord-pro),
5[Developer Portal](https://developers.ledger.com/)
6
7## @ledgerhq/hw-app-eth
8
9Ledger Hardware Wallet ETH JavaScript bindings.
10
11***
12
13## Are you adding Ledger support to your software wallet?
14
15You may be using this package to communicate with the Ethereum Nano App.
16
17For a smooth and quick integration:
18
19* See the developers’ documentation on the [Developer Portal](https://developers.ledger.com/docs/transport/overview/) and
20* Go on [Discord](https://developers.ledger.com/discord-pro/) to chat with developer support and the developer community.
21
22***
23
24## API
25
26<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
27
28#### Table of Contents
29
30* [Eth](#eth)
31 * [Parameters](#parameters)
32 * [Examples](#examples)
33 * [getAddress](#getaddress)
34 * [Parameters](#parameters-1)
35 * [Examples](#examples-1)
36 * [signTransaction](#signtransaction)
37 * [Parameters](#parameters-2)
38 * [Examples](#examples-2)
39 * [getAppConfiguration](#getappconfiguration)
40 * [signPersonalMessage](#signpersonalmessage)
41 * [Parameters](#parameters-3)
42 * [Examples](#examples-3)
43 * [signEIP712HashedMessage](#signeip712hashedmessage)
44 * [Parameters](#parameters-4)
45 * [Examples](#examples-4)
46 * [signEIP712Message](#signeip712message)
47 * [Parameters](#parameters-5)
48 * [Examples](#examples-5)
49 * [starkGetPublicKey](#starkgetpublickey)
50 * [Parameters](#parameters-6)
51 * [starkSignOrder](#starksignorder)
52 * [Parameters](#parameters-7)
53 * [starkSignOrder_v2](#starksignorder_v2)
54 * [Parameters](#parameters-8)
55 * [starkSignTransfer](#starksigntransfer)
56 * [Parameters](#parameters-9)
57 * [starkSignTransfer_v2](#starksigntransfer_v2)
58 * [Parameters](#parameters-10)
59 * [starkProvideQuantum](#starkprovidequantum)
60 * [Parameters](#parameters-11)
61 * [starkProvideQuantum_v2](#starkprovidequantum_v2)
62 * [Parameters](#parameters-12)
63 * [starkUnsafeSign](#starkunsafesign)
64 * [Parameters](#parameters-13)
65 * [eth2GetPublicKey](#eth2getpublickey)
66 * [Parameters](#parameters-14)
67 * [Examples](#examples-6)
68 * [eth2SetWithdrawalIndex](#eth2setwithdrawalindex)
69 * [Parameters](#parameters-15)
70 * [getEIP1024PublicEncryptionKey](#geteip1024publicencryptionkey)
71 * [Parameters](#parameters-16)
72 * [Examples](#examples-7)
73 * [getEIP1024SharedSecret](#geteip1024sharedsecret)
74 * [Parameters](#parameters-17)
75 * [Examples](#examples-8)
76* [loadInfosForContractMethod](#loadinfosforcontractmethod)
77 * [Parameters](#parameters-18)
78* [byContractAddressAndChainId](#bycontractaddressandchainid)
79 * [Parameters](#parameters-19)
80* [list](#list)
81 * [Parameters](#parameters-20)
82* [ResolutionConfig](#resolutionconfig)
83 * [Properties](#properties)
84
85### Eth
86
87Ethereum API
88
89#### Parameters
90
91* `transport` **Transport**
92* `scrambleKey` (optional, default `"w0w"`)
93* `loadConfig` **LoadConfig** (optional, default `{}`)
94
95#### Examples
96
97```javascript
98import Eth from "@ledgerhq/hw-app-eth";
99const eth = new Eth(transport)
100```
101
102#### getAddress
103
104get Ethereum address for a given BIP 32 path.
105
106##### Parameters
107
108* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
109* `boolDisplay` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
110* `boolChaincode` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
111
112##### Examples
113
114```javascript
115eth.getAddress("44'/60'/0'/0/0").then(o => o.address)
116```
117
118Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), address: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), chainCode: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?}>** an object with a publicKey, address and (optionally) chainCode
119
120#### signTransaction
121
122You can sign a transaction and retrieve v, r, s given the raw transaction and the BIP 32 path of the account to sign.
123
124##### Parameters
125
126* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : the BIP32 path to sign the transaction on
127* `rawTxHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** : the raw ethereum transaction in hexadecimal to sign
128* `resolution` **(LedgerEthTransactionResolution | null)?** : resolution is an object with all "resolved" metadata necessary to allow the device to clear sign information. This includes: ERC20 token information, plugins, contracts, NFT signatures,... You must explicitly provide something to avoid having a warning. By default, you can use Ledger's service or your own resolution service. See services/types.js for the contract. Setting the value to "null" will fallback everything to blind signing but will still allow the device to sign the transaction.
129
130##### Examples
131
132```javascript
133import { ledgerService } from "@ledgerhq/hw-app-eth"
134const tx = "e8018504e3b292008252089428ee52a8f3d6e5d15f8b131996950d7f296c7952872bd72a2487400080"; // raw tx to sign
135const resolution = await ledgerService.resolveTransaction(tx);
136const result = eth.signTransaction("44'/60'/0'/0/0", tx, resolution);
137console.log(result);
138```
139
140Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), v: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
141
142#### getAppConfiguration
143
144Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{arbitraryDataEnabled: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), erc20ProvisioningNecessary: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), starkEnabled: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), starkv2Supported: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), version: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
145
146#### signPersonalMessage
147
148You can sign a message according to eth_sign RPC call and retrieve v, r, s given the message and the BIP 32 path of the account to sign.
149
150##### Parameters
151
152* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
153* `messageHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
154
155##### Examples
156
157```javascript
158eth.signPersonalMessage("44'/60'/0'/0/0", Buffer.from("test").toString("hex")).then(result => {
159var v = result['v'] - 27;
160v = v.toString(16);
161if (v.length < 2) {
162v = "0" + v;
163}
164console.log("Signature 0x" + result['r'] + result['s'] + v);
165})
166```
167
168Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
169
170#### signEIP712HashedMessage
171
172Sign a prepared message following web3.eth.signTypedData specification. The host computes the domain separator and hashStruct(message)
173
174##### Parameters
175
176* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
177* `domainSeparatorHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
178* `hashStructMessageHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
179
180##### Examples
181
182```javascript
183eth.signEIP712HashedMessage("44'/60'/0'/0/0", Buffer.from("0101010101010101010101010101010101010101010101010101010101010101").toString("hex"), Buffer.from("0202020202020202020202020202020202020202020202020202020202020202").toString("hex")).then(result => {
184var v = result['v'] - 27;
185v = v.toString(16);
186if (v.length < 2) {
187v = "0" + v;
188}
189console.log("Signature 0x" + result['r'] + result['s'] + v);
190})
191```
192
193Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{v: [number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>**
194
195#### signEIP712Message
196
197Sign an EIP-721 formatted message following the specification here:
198https://github.com/LedgerHQ/app-ethereum/blob/develop/doc/ethapp.asc#sign-eth-eip-712
199⚠️ This method is not compatible with nano S (LNS). Make sure to use a try/catch to fallback on the signEIP712HashedMessage method ⚠️
200
201##### Parameters
202
203* `path` **[String](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** derivationPath
204* `jsonMessage` **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object)** message to sign
205* `fullImplem` **[Boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** use the legacy implementation (optional, default `false`)
206
207##### Examples
208
209```javascript
210eth.signEIP721Message("44'/60'/0'/0/0", {
211domain: {
212chainId: 69,
213name: "Da Domain",
214verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
215version: "1"
216},
217types: {
218"EIP712Domain": [
219{ name: "name", type: "string" },
220{ name: "version", type: "string" },
221{ name: "chainId", type: "uint256" },
222{ name: "verifyingContract", type: "address" }
223],
224"Test": [
225{ name: "contents", type: "string" }
226]
227},
228primaryType: "Test",
229message: {contents: "Hello, Bob!"},
230})
231```
232
233Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
234
235#### starkGetPublicKey
236
237get Stark public key for a given BIP 32 path.
238
239##### Parameters
240
241* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
242* `boolDisplay` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
243
244Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[Buffer](https://nodejs.org/api/buffer.html)>** the Stark public key
245
246#### starkSignOrder
247
248sign a Stark order
249
250##### Parameters
251
252* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
253* `sourceTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
254* `sourceQuantization` **BigNumber** quantization used for the source token
255* `destinationTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
256* `destinationQuantization` **BigNumber** quantization used for the destination token
257* `sourceVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the source vault
258* `destinationVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the destination vault
259* `amountSell` **BigNumber** amount to sell
260* `amountBuy` **BigNumber** amount to buy
261* `nonce` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction nonce
262* `timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction validity timestamp
263
264Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<([Buffer](https://nodejs.org/api/buffer.html) | {r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)})>** the signature
265
266#### starkSignOrder_v2
267
268sign a Stark order using the Starkex V2 protocol
269
270##### Parameters
271
272* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
273* `sourceTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
274* `sourceQuantizationType` **StarkQuantizationType** quantization type used for the source token
275* `sourceQuantization` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
276* `sourceMintableBlobOrTokenId` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
277* `destinationTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
278* `destinationQuantizationType` **StarkQuantizationType** quantization type used for the destination token
279* `destinationQuantization` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
280* `destinationMintableBlobOrTokenId` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
281* `sourceVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the source vault
282* `destinationVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the destination vault
283* `amountSell` **BigNumber** amount to sell
284* `amountBuy` **BigNumber** amount to buy
285* `nonce` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction nonce
286* `timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction validity timestamp
287
288Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<([Buffer](https://nodejs.org/api/buffer.html) | {r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)})>** the signature
289
290#### starkSignTransfer
291
292sign a Stark transfer
293
294##### Parameters
295
296* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
297* `transferTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
298* `transferQuantization` **BigNumber** quantization used for the token to be transferred
299* `targetPublicKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** target Stark public key
300* `sourceVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the source vault
301* `destinationVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the destination vault
302* `amountTransfer` **BigNumber** amount to transfer
303* `nonce` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction nonce
304* `timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction validity timestamp
305
306Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<([Buffer](https://nodejs.org/api/buffer.html) | {r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)})>** the signature
307
308#### starkSignTransfer_v2
309
310sign a Stark transfer or conditional transfer using the Starkex V2 protocol
311
312##### Parameters
313
314* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
315* `transferTokenAddress` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
316* `transferQuantizationType` **StarkQuantizationType** quantization type used for the token to be transferred
317* `transferQuantization` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
318* `transferMintableBlobOrTokenId` **(BigNumber | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
319* `targetPublicKey` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** target Stark public key
320* `sourceVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the source vault
321* `destinationVault` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** ID of the destination vault
322* `amountTransfer` **BigNumber** amount to transfer
323* `nonce` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction nonce
324* `timestamp` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** transaction validity timestamp
325* `conditionalTransferAddress` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
326* `conditionalTransferFact` **BigNumber?**
327
328Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<([Buffer](https://nodejs.org/api/buffer.html) | {r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)})>** the signature
329
330#### starkProvideQuantum
331
332provide quantization information before singing a deposit or withdrawal Stark powered contract call
333
334It shall be run following a provideERC20TokenInformation call for the given contract
335
336##### Parameters
337
338* `operationContract` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** contract address of the token to be transferred (not present for ETH)
339* `operationQuantization` **BigNumber** quantization used for the token to be transferred
340
341Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**
342
343#### starkProvideQuantum_v2
344
345provide quantization information before singing a deposit or withdrawal Stark powered contract call using the Starkex V2 protocol
346
347It shall be run following a provideERC20TokenInformation call for the given contract
348
349##### Parameters
350
351* `operationContract` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))** contract address of the token to be transferred (not present for ETH)
352* `operationQuantizationType` **StarkQuantizationType** quantization type of the token to be transferred
353* `operationQuantization` **BigNumber?**
354* `operationMintableBlobOrTokenId` **BigNumber?**
355
356Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>**
357
358#### starkUnsafeSign
359
360sign the given hash over the Stark curve
361It is intended for speed of execution in case an unknown Stark model is pushed and should be avoided as much as possible.
362
363##### Parameters
364
365* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
366* `hash` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** hexadecimal hash to sign
367
368Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<([Buffer](https://nodejs.org/api/buffer.html) | {r: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), s: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)})>** the signature
369
370#### eth2GetPublicKey
371
372get an Ethereum 2 BLS-12 381 public key for a given BIP 32 path.
373
374##### Parameters
375
376* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
377* `boolDisplay` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
378
379##### Examples
380
381```javascript
382eth.eth2GetPublicKey("12381/3600/0/0").then(o => o.publicKey)
383```
384
385Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** an object with a publicKey
386
387#### eth2SetWithdrawalIndex
388
389Set the index of a Withdrawal key used as withdrawal credentials in an ETH 2 deposit contract call signature
390
391It shall be run before the ETH 2 deposit transaction is signed. If not called, the index is set to 0
392
393##### Parameters
394
395* `withdrawalIndex` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)** index path in the EIP 2334 path m/12381/3600/withdrawalIndex/0
396
397Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)>** True if the method was executed successfully
398
399#### getEIP1024PublicEncryptionKey
400
401get a public encryption key on Curve25519 according to EIP 1024
402
403##### Parameters
404
405* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
406* `boolDisplay` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
407
408##### Examples
409
410```javascript
411eth.getEIP1024PublicEncryptionKey("44'/60'/0'/0/0").then(o => o.publicKey)
412```
413
414Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{publicKey: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** an object with a publicKey
415
416#### getEIP1024SharedSecret
417
418get a shared secret on Curve25519 according to EIP 1024
419
420##### Parameters
421
422* `path` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** a path in BIP 32 format
423* `remotePublicKeyHex` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** remote Curve25519 public key
424* `boolDisplay` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
425
426##### Examples
427
428```javascript
429eth.getEIP1024SharedSecret("44'/60'/0'/0/0", "87020e80af6e07a6e4697f091eacadb9e7e6629cb7e5a8a371689a3ed53b3d64").then(o => o.sharedSecret)
430```
431
432Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<{sharedSecret: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)}>** an object with a shared secret
433
434### loadInfosForContractMethod
435
436Retrieve the metadatas a given contract address and a method selector
437
438#### Parameters
439
440* `contractAddress` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
441* `selector` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
442* `chainId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
443* `userLoadConfig` **LoadConfig**
444
445Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)<(ContractMethod | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))>**
446
447### byContractAddressAndChainId
448
449Retrieve the token information by a given contract address if any
450
451#### Parameters
452
453* `contract` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
454* `chainId` **[number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number)**
455* `erc20SignaturesBlob` **([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | null)?**
456
457Returns **(TokenInfo | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
458
459### list
460
461list all the ERC20 tokens informations
462
463#### Parameters
464
465* `erc20SignaturesBlob` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
466
467Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<TokenInfo>**
468
469### ResolutionConfig
470
471Allows to configure precisely what the service need to resolve.
472for instance you can set nft:true if you need clear signing on NFTs. If you set it and it is not a NFT transaction, it should still work but will do a useless service resolution.
473
474Type: {nft: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, externalPlugins: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, erc20: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?}
475
476#### Properties
477
478* `nft` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
479* `externalPlugins` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**
480* `erc20` **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?**