Class: LedgerSigner231<Transport>
Defined in: src/signer/ledgerSigner231.ts:41
Signer for accounts using a Ledger Nano S+/X signature (Starknet Ledger APP from version 2.3.1 to 2.4.3).
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.
Extends
Type Parameters
Transport
Transport extends Record<any, any> = any
Implements
Constructors
Constructor
new LedgerSigner231<
Transport>(transport,accountID,eip2645application?,pathFunction?):LedgerSigner231<Transport>
Defined in: src/signer/ledgerSigner231.ts:67
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 account (can handle 2**31 accounts).
eip2645application?
string = 'LedgerW'
A wallet is defined by an ERC2645 derivation path (6 items).
One item is called application and can be customized.
Default value is LedgerW.
pathFunction?
LedgerPathCalculation = getLedgerPathBuffer221
defines the function that will calculate the path. By default getLedgerPathBuffer221 is selected.
If you are using APP v2.3.1 with an account created with the v1.1.1, you need to use :
const myLedgerSigner = new LedgerSigner231(myNodeTransport, 0, undefined, getLedgerPathBuffer111);
Returns
LedgerSigner231<Transport>
Example
import TransportNodeHid from "@ledgerhq/hw-transport-node-hid";
const myNodeTransport = await TransportNodeHid.create();
const myLedgerSigner = new LedgerSigner231(myNodeTransport, 0);
Overrides
Properties
transporter
readonlytransporter:any
Defined in: src/signer/ledgerSigner111.ts:43
Inherited from
accountID
readonlyaccountID:number
Defined in: src/signer/ledgerSigner111.ts:48
Inherited from
eip2645applicationName
readonlyeip2645applicationName:string
Defined in: src/signer/ledgerSigner111.ts:50
Inherited from
LedgerSigner221.eip2645applicationName
pathBuffer
readonlypathBuffer:Uint8Array
Defined in: src/signer/ledgerSigner111.ts:52
Inherited from
Methods
signTxV3()
signTxV3(
txDetails,calls):Promise<{hash:bigint;signature:Signature; }>
Defined in: src/signer/ledgerSigner231.ts:104
Ask to the Ledger Nano to display and sign a Starknet V3 transaction.
Parameters
txDetails
All the details needed for a txV3.
calls
Call[]
array of Starknet invocations
Returns
Promise<{ hash: bigint; signature: Signature; }>
an object including the transaction Hash and the signature
Example
const calls: Call[] = [{contractAddress: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
entrypoint: "transfer",
calldata:["0x11f5fc2a92ac03434a7937fe982f5e5293b65ad438a989c5b78fb8f04a12016",
"0x9184e72a000", "0x0"]}];
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 res = await myLedgerSigner.signTxV3(txDetailsV3, calls);
// res = {hash:
// signature:
// }
Overrides
signDeployAccountV3()
signDeployAccountV3(
deployAccountDetail):Promise<{hash:bigint;signature:Signature; }>
Defined in: src/signer/ledgerSigner231.ts:221
Ask the Ledger Nano to display and sign a Starknet V3 account deployment.
Parameters
deployAccountDetail
All the details needed for a V3 deploy account.
Returns
Promise<{ hash: bigint; signature: Signature; }>
an object including the transaction Hash and the signature
Example
const deployData: V3DeployAccountSignerDetails =
{
tip: 0, paymasterData: [], accountDeploymentData: [],
nonceDataAvailabilityMode: 'L1', feeDataAvailabilityMode: 'L1',
resourceBounds: {
l2_gas: { max_amount: '0x0', max_price_per_unit: '0x0' },
l1_gas: { max_amount: '0x226', max_price_per_unit: '0x22ecb25c00' }
},
classHash: '0x540d7f5ec7ecf317e68d48564934cb99259781b1ee3cedbbc37ec5337f8e688',
constructorCalldata: [
'3571125127744830445572285574469842579401255431821644822726857471463672199621'
],
contractAddress: '0x4ca062add1cf12a107be1107af17981cf6e544a24d987693230ea481d3d5e34',
addressSalt: '0x07e52f68e3160e1ef698211cdf6d3792368fe347e7e2d4a8ace14d9b248f39c5',
chainId: '0x534e5f5345504f4c4941',
version: '0x3', nonce: 0n
}
const res = await myLedgerSigner.signDeployAccountV3(deployData);
// res = {hash:
// signature:
// }
Overrides
LedgerSigner221.signDeployAccountV3
signTransaction()
signTransaction(
transactions,transactionsDetail):Promise<Signature>
Defined in: src/signer/ledgerSigner221.ts:117
Sign in a Ledger a V3 transaction. The details are displayed 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
Inherited from
LedgerSigner221.signTransaction
signDeployAccountTransaction()
signDeployAccountTransaction(
details):Promise<Signature>
Defined in: src/signer/ledgerSigner221.ts:150
Sign in a Ledger the deployment of a new account. The details are displayed 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
Inherited from
LedgerSigner221.signDeployAccountTransaction
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
Inherited from
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"
Inherited from
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"
Inherited from
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
Inherited from
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}
Implementation of
SignerInterface.signDeclareTransaction