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 |
|
9 | Ledger Hardware Wallet ETH JavaScript bindings.
|
10 |
|
11 | ***
|
12 |
|
13 | ## Are you adding Ledger support to your software wallet?
|
14 |
|
15 | You may be using this package to communicate with the Ethereum Nano App.
|
16 |
|
17 | For 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 |
|
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 |
|
87 | Ethereum API
|
88 |
|
89 | #### Parameters
|
90 |
|
91 | * `transport` **Transport**
|
92 | * `scrambleKey` (optional, default `"w0w"`)
|
93 | * `loadConfig` **LoadConfig** (optional, default `{}`)
|
94 |
|
95 | #### Examples
|
96 |
|
97 | ```javascript
|
98 | import Eth from "@ledgerhq/hw-app-eth";
|
99 | const eth = new Eth(transport)
|
100 | ```
|
101 |
|
102 | #### getAddress
|
103 |
|
104 | get 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
|
115 | eth.getAddress("44'/60'/0'/0/0").then(o => o.address)
|
116 | ```
|
117 |
|
118 | Returns **[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 |
|
122 | You 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
|
133 | import { ledgerService } from "@ledgerhq/hw-app-eth"
|
134 | const tx = "e8018504e3b292008252089428ee52a8f3d6e5d15f8b131996950d7f296c7952872bd72a2487400080"; // raw tx to sign
|
135 | const resolution = await ledgerService.resolveTransaction(tx);
|
136 | const result = eth.signTransaction("44'/60'/0'/0/0", tx, resolution);
|
137 | console.log(result);
|
138 | ```
|
139 |
|
140 | Returns **[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 |
|
144 | Returns **[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 |
|
148 | You 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
|
158 | eth.signPersonalMessage("44'/60'/0'/0/0", Buffer.from("test").toString("hex")).then(result => {
|
159 | var v = result['v'] - 27;
|
160 | v = v.toString(16);
|
161 | if (v.length < 2) {
|
162 | v = "0" + v;
|
163 | }
|
164 | console.log("Signature 0x" + result['r'] + result['s'] + v);
|
165 | })
|
166 | ```
|
167 |
|
168 | Returns **[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 |
|
172 | Sign 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
|
183 | eth.signEIP712HashedMessage("44'/60'/0'/0/0", Buffer.from("0101010101010101010101010101010101010101010101010101010101010101").toString("hex"), Buffer.from("0202020202020202020202020202020202020202020202020202020202020202").toString("hex")).then(result => {
|
184 | var v = result['v'] - 27;
|
185 | v = v.toString(16);
|
186 | if (v.length < 2) {
|
187 | v = "0" + v;
|
188 | }
|
189 | console.log("Signature 0x" + result['r'] + result['s'] + v);
|
190 | })
|
191 | ```
|
192 |
|
193 | Returns **[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 |
|
197 | Sign an EIP-721 formatted message following the specification here:
|
198 | https://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
|
210 | eth.signEIP721Message("44'/60'/0'/0/0", {
|
211 | domain: {
|
212 | chainId: 69,
|
213 | name: "Da Domain",
|
214 | verifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
|
215 | version: "1"
|
216 | },
|
217 | types: {
|
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 | },
|
228 | primaryType: "Test",
|
229 | message: {contents: "Hello, Bob!"},
|
230 | })
|
231 | ```
|
232 |
|
233 | Returns **[Promise](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Promise)**
|
234 |
|
235 | #### starkGetPublicKey
|
236 |
|
237 | get 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 |
|
244 | Returns **[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 |
|
248 | sign 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 |
|
264 | Returns **[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 |
|
268 | sign 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 |
|
288 | Returns **[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 |
|
292 | sign 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 |
|
306 | Returns **[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 |
|
310 | sign 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 |
|
328 | Returns **[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 |
|
332 | provide quantization information before singing a deposit or withdrawal Stark powered contract call
|
333 |
|
334 | It 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 |
|
341 | Returns **[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 |
|
345 | provide quantization information before singing a deposit or withdrawal Stark powered contract call using the Starkex V2 protocol
|
346 |
|
347 | It 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 |
|
356 | Returns **[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 |
|
360 | sign the given hash over the Stark curve
|
361 | It 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 |
|
368 | Returns **[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 |
|
372 | get 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
|
382 | eth.eth2GetPublicKey("12381/3600/0/0").then(o => o.publicKey)
|
383 | ```
|
384 |
|
385 | Returns **[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 |
|
389 | Set the index of a Withdrawal key used as withdrawal credentials in an ETH 2 deposit contract call signature
|
390 |
|
391 | It 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 |
|
397 | Returns **[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 |
|
401 | get 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
|
411 | eth.getEIP1024PublicEncryptionKey("44'/60'/0'/0/0").then(o => o.publicKey)
|
412 | ```
|
413 |
|
414 | Returns **[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 |
|
418 | get 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
|
429 | eth.getEIP1024SharedSecret("44'/60'/0'/0/0", "87020e80af6e07a6e4697f091eacadb9e7e6629cb7e5a8a371689a3ed53b3d64").then(o => o.sharedSecret)
|
430 | ```
|
431 |
|
432 | Returns **[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 |
|
436 | Retrieve 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 |
|
445 | Returns **[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 |
|
449 | Retrieve 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 |
|
457 | Returns **(TokenInfo | null | [undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined))**
|
458 |
|
459 | ### list
|
460 |
|
461 | list all the ERC20 tokens informations
|
462 |
|
463 | #### Parameters
|
464 |
|
465 | * `erc20SignaturesBlob` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?**
|
466 |
|
467 | Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<TokenInfo>**
|
468 |
|
469 | ### ResolutionConfig
|
470 |
|
471 | Allows to configure precisely what the service need to resolve.
|
472 | for 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 |
|
474 | Type: {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)?**
|