Class: LedgerSigner111<Transport>
Defined in: src/signer/ledgerSigner111.ts:42
Signer for accounts using a Ledger Nano S+/X signature (Starknet Ledger APP version 1.1.1)
The Ledger has to be connected, unlocked and the Starknet APP has to be selected prior of use of this class.
Deprecated
Import it from starknet/ledger instead: it is the same class, with the transport typed as a
Ledger Transport. Importing it from starknet is kept only for backward compatibility, and will be
removed in v12.
Extended by
Type Parameters
Transport
Transport extends Record<any, any> = any
Implements
Constructors
Constructor
new LedgerSigner111<
Transport>(transport,accountID,eip2645application?,pathFunction?):LedgerSigner111<Transport>
Defined in: src/signer/ledgerSigner111.ts:77
constructor of the LedgerSigner class.
Parameters
transport
Transport
5 transports are available to handle USB, bluetooth, Node, Web, Mobile. See Guides for more details.
accountID
number
ID of Ledger Nano (can handle 2**31 accounts).
eip2645application?
string = 'LedgerW'
A wallet is defined by an ERC2645 derivation path (6 items),
and one item is the application and can be customized.
Default value is LedgerW.
pathFunction?
LedgerPathCalculation = getLedgerPathBuffer111
defines the function that will calculate the path. By default getLedgerPathBuffer111 is selected.
Returns
LedgerSigner111<Transport>
Example
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
const myNodeTransport = await TransportNodeHid.create();
const myLedgerSigner = new LedgerSigner111(myNodeTransport, 0);
Properties
transporter
readonlytransporter:Transport
Defined in: src/signer/ledgerSigner111.ts:43
accountID
readonlyaccountID:number
Defined in: src/signer/ledgerSigner111.ts:48
eip2645applicationName
readonlyeip2645applicationName:string
Defined in: src/signer/ledgerSigner111.ts:50
pathBuffer
readonlypathBuffer:Uint8Array
Defined in: src/signer/ledgerSigner111.ts:52
Methods
getPubKey()
getPubKey():
Promise<string>
Defined in: src/signer/ledgerSigner111.ts:105
provides the Starknet public key
Returns
Promise<string>
an hex string : 64 characters are Point X coordinate.
Example
const result = await myLedgerSigner.getPubKey();
// result= "0x03681417ba3e1f050dd3ccdceb8d22b5e44fa70ee7844d472c6a768bded5174e"
Implementation of
getFullPubKey()
getFullPubKey():
Promise<string>
Defined in: src/signer/ledgerSigner111.ts:119
provides the full public key (with parity prefix)
Returns
Promise<string>
an hex string : 2 first characters are the parity, the 64 following characters are Point X coordinate. 64 last characters are Point Y coordinate.
Example
const result = await myLedgerSigner.getFullPubKey();
// result= "0x0403681417ba3e1f050dd3ccdceb8d22b5e44fa70ee7844d472c6a768bded5174e03cbc86f805dcfcb0c1922dd4daf181afa289d86223a18bc856276615bcc7787"
getAppVersion()
getAppVersion():
Promise<string>
Defined in: src/signer/ledgerSigner111.ts:133
Returns the version of the Starknet APP implemented in the Ledger.
Returns
Promise<string>
version.
Example
const result = await myLedgerSigner.getAppVersion();
// result= "1.1.1"
signMessage()
signMessage(
typedDataToHash,accountAddress):Promise<Signature>
Defined in: src/signer/ledgerSigner111.ts:154
Sign a TypedData message (SNIP-12) in a Ledger.
Parameters
typedDataToHash
A TypedData message compatible with SNIP-12.
accountAddress
string
Signer account address (Hex or num string)
Returns
Promise<Signature>
The signed message.
Example
const result = myLedgerSigner.signMessage(snip12Message, account0.address);
// result = Signature { r: 611475243393396148729326917410546146405234155928298353899191529090923298688n,
// s: 798839819213540985856952481651392652149797817551686626114697493101433761982n,
// recovery: 0}
Implementation of
signTransaction()
signTransaction(
transactions,transactionsDetail):Promise<Signature>
Defined in: src/signer/ledgerSigner111.ts:194
Sign in a Ledger a V3 transaction. This is a blind sign on the Ledger screen.
Parameters
transactions
Call[]
An array of Call transactions (generated for example by myContract.populate()).
transactionsDetail
An object that includes all the necessary inputs to hash the transaction.
Returns
Promise<Signature>
The signed transaction.
Example
const txDetailsV3: V3InvocationsSignerDetails = {
chainId: constants.StarknetChainId.SN_MAIN,
nonce: "28",
accountDeploymentData: [],
paymasterData: [],
cairoVersion: "1",
feeDataAvailabilityMode: "L1",
nonceDataAvailabilityMode: "L1",
resourceBounds: {
l1_gas: {
max_amount: "0x2a00",
max_price_per_unit: "0x5c00000"
},
l2_gas: {
max_amount: "0x00",
max_price_per_unit: "0x00"
},
},
tip: 0,
version: "0x3",
walletAddress: account0.address
}
const result = myLedgerSigner.signTransaction([call0, call1], txDetailsV3);
// result = Signature { r: 611475243393396148729326917410546146405234155928298353899191529090923298688n,
// s: 798839819213540985856952481651392652149797817551686626114697493101433761982n,
// recovery: 0}
Implementation of
SignerInterface.signTransaction
signDeployAccountTransaction()
signDeployAccountTransaction(
details):Promise<Signature>
Defined in: src/signer/ledgerSigner111.ts:223
Sign in a Ledger the deployment of a new account. This is a blind sign on the Ledger screen.
Parameters
details
An object that includes all necessary data to calculate the Hash.
Returns
Promise<Signature>
The deploy account signature.
Example
const result = myLedgerSigner.signDeployAccountTransaction(details);
// result = Signature { r: 611475243393396148729326917410546146405234155928298353899191529090923298688n,
// s: 798839819213540985856952481651392652149797817551686626114697493101433761982n,
// recovery: 0}
Implementation of
SignerInterface.signDeployAccountTransaction
signDeclareTransaction()
signDeclareTransaction(
details):Promise<Signature>
Defined in: src/signer/ledgerSigner111.ts:251
Sign in a Ledger the declaration of a new class. This is a blind sign on the Ledger screen.
Parameters
details
An object that includes all necessary data to calculate the Hash.
Returns
Promise<Signature>
The declare Signature.
Example
const result = myLedgerSigner.signDeclareTransaction(details);
// result = Signature { r: 611475243393396148729326917410546146405234155928298353899191529090923298688n,
// s: 798839819213540985856952481651392652149797817551686626114697493101433761982n,
// recovery: 0}