Skip to main content
Version: Next

Class: LedgerSigner111<Transport>

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.

Type parameters​

NameType
Transportextends Record<any, any> = any

Hierarchy​

Implements​

Constructors​

constructor​

• new LedgerSigner111<Transport>(transport, accountID, eip2645application?, pathFunction?): LedgerSigner111<Transport>

constructor of the LedgerSigner class.

Type parameters​

NameType
Transportextends Record<any, any> = any

Parameters​

NameTypeDefault valueDescription
transportTransportundefined5 transports are available to handle USB, bluetooth, Node, Web, Mobile. See Guides for more details.
accountIDnumberundefinedID 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?LedgerPathCalculationgetLedgerPathBuffer111defines 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);

Defined in​

src/signer/ledgerSigner111.ts:81

Properties​

transporter​

• Readonly transporter: Transport

Defined in​

src/signer/ledgerSigner111.ts:47


_transporter​

• Protected _transporter: any

Defined in​

src/signer/ledgerSigner111.ts:50


accountID​

• Readonly accountID: number

Defined in​

src/signer/ledgerSigner111.ts:52


eip2645applicationName​

• Readonly eip2645applicationName: string

Defined in​

src/signer/ledgerSigner111.ts:54


pathBuffer​

• Readonly pathBuffer: Uint8Array

Defined in​

src/signer/ledgerSigner111.ts:56


appVersion​

• Protected appVersion: string

Defined in​

src/signer/ledgerSigner111.ts:58


pubKey​

• Protected pubKey: string

Defined in​

src/signer/ledgerSigner111.ts:60


fullPubKey​

• Protected fullPubKey: string

Defined in​

src/signer/ledgerSigner111.ts:62

Methods​

getPubKey​

â–¸ getPubKey(): Promise<string>

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​

SignerInterface.getPubKey

Defined in​

src/signer/ledgerSigner111.ts:109


getFullPubKey​

â–¸ getFullPubKey(): Promise<string>

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"

Defined in​

src/signer/ledgerSigner111.ts:123


getAppVersion​

â–¸ getAppVersion(): Promise<string>

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"

Defined in​

src/signer/ledgerSigner111.ts:137


signMessage​

â–¸ signMessage(typedDataToHash, accountAddress): Promise<Signature>

Sign a TypedData message (SNIP-12) in a Ledger.

Parameters​

NameTypeDescription
typedDataToHashTypedDataA TypedData message compatible with SNIP-12.
accountAddressstringSigner 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​

SignerInterface.signMessage

Defined in​

src/signer/ledgerSigner111.ts:158


signTransaction​

â–¸ signTransaction(transactions, transactionsDetail): Promise<Signature>

Sign in a Ledger a V1 or a V3 transaction. This is a blind sign on the Ledger screen.

Parameters​

NameTypeDescription
transactionsCall[]An array of Call transactions (generated for example by myContract.populate()).
transactionsDetailInvocationsSignerDetailsAn object that includes all the necessary inputs to hash the transaction. Can be V2InvocationsSignerDetails or V3InvocationsSignerDetails type.

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

Defined in​

src/signer/ledgerSigner111.ts:198


signDeployAccountTransaction​

â–¸ signDeployAccountTransaction(details): Promise<Signature>

Sign in a Ledger the deployment of a new account. This is a blind sign on the Ledger screen.

Parameters​

NameTypeDescription
detailsDeployAccountSignerDetailsAn object that includes all necessary data to calculate the Hash. It can be V2DeployAccountSignerDetails or V3DeployAccountSignerDetails types.

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

Defined in​

src/signer/ledgerSigner111.ts:243


signDeclareTransaction​

â–¸ signDeclareTransaction(details): Promise<Signature>

Sign in a Ledger the declaration of a new class. This is a blind sign on the Ledger screen.

Parameters​

NameTypeDescription
detailsDeclareSignerDetailsAn object that includes all necessary data to calculate the Hash. It can be V3DeclareSignerDetails or V2DeclareSignerDetails types.

Returns​

Promise<Signature>

The declare Signature.

Example

const result = myLedgerSigner.signDeclareTransaction(details);
// result = Signature { r: 611475243393396148729326917410546146405234155928298353899191529090923298688n,
// s: 798839819213540985856952481651392652149797817551686626114697493101433761982n,
// recovery: 0}

Implementation of​

SignerInterface.signDeclareTransaction

Defined in​

src/signer/ledgerSigner111.ts:287


signRaw​

â–¸ signRaw(msgHash): Promise<Signature>

Internal function to sign a hash in a Ledger Nano. This is a blind sign in the Ledger ; no display of what you are signing.

Parameters​

NameType
msgHashstring

Returns​

Promise<Signature>

Defined in​

src/signer/ledgerSigner111.ts:316


getPublicKeys​

â–¸ getPublicKeys(): Promise<void>

internal function to get both the Starknet public key and the full public key

Returns​

Promise<void>

Defined in​

src/signer/ledgerSigner111.ts:335