Skip to main content

Class: Ledger

A connection to the IOTA app on a Ledger device.

Every call completes once the device answers, which for address verification includes waiting for the user to confirm on the device. Calls on the same Ledger, including through the LedgerSigners created from it, run one at a time.

Extends​

  • UniffiAbstractObject

Implements​

Properties​

[destructorGuardSymbol]​

readonly [destructorGuardSymbol]: UniffiGcObject;

[pointerLiteralSymbol]​

readonly [pointerLiteralSymbol]: bigint;

[uniffiTypeNameSymbol]​

readonly [uniffiTypeNameSymbol]: "Ledger" = "Ledger";

Methods​

exitApp()​

exitApp(asyncOpts_?): Promise<void>;

Close the app running on the device and return to the dashboard.

On Speculos, this ends the emulated app.

Parameters​

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<void>

Implementation of​

LedgerLike.exitApp


getPublicKey()​

getPublicKey(path, asyncOpts_?): Promise<Ed25519PublicKeyLike>;

Read the public key at a derivation path such as m/44'/4218'/0'/0'/0'.

Parameters​

path​

string

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<Ed25519PublicKeyLike>

Implementation of​

LedgerLike.getPublicKey


isAppOpen()​

isAppOpen(asyncOpts_?): Promise<boolean>;

Check whether the IOTA app is the app running on the device.

Speculos reports a placeholder app name unless started with SPECULOS_APPNAME=IOTA:<version>, so this returns false there.

Parameters​

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<boolean>

Implementation of​

LedgerLike.isAppOpen


openApp()​

openApp(asyncOpts_?): Promise<void>;

Open the IOTA app, from the dashboard or by closing another app first.

Does nothing if the IOTA app is already running, or on a speculos connection.

Parameters​

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<void>

Implementation of​

LedgerLike.openApp


signer()​

signer(path, asyncOpts_?): Promise<LedgerSignerLike>;

Create a signer for the key at a derivation path such as m/44'/4218'/0'/0'/0', reading its public key from the device.

The signer shares this Ledger's connection, which stays usable.

Parameters​

path​

string

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<LedgerSignerLike>

Implementation of​

LedgerLike.signer


uniffiDestroy()​

uniffiDestroy(): void;

Explicitly tell Rust to destroy the native peer that backs this object.

Once this method has been called, any following method calls will throw an error.

Can be called more than once.

Returns​

void

Overrides​

UniffiAbstractObject.uniffiDestroy


uniffiUse()​

uniffiUse<T>(block): T;

A convenience method to use this object, then destroy it after its use.

Type Parameters​

T​

T

Parameters​

block​

(obj) => T

Returns​

T

Inherited from​

UniffiAbstractObject.uniffiUse


verifyAddress()​

verifyAddress(path, asyncOpts_?): Promise<Ed25519PublicKeyLike>;

Show the address at a derivation path on the device for the user to confirm, and return its public key.

Parameters​

path​

string

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<Ed25519PublicKeyLike>

Implementation of​

LedgerLike.verifyAddress


version()​

version(asyncOpts_?): Promise<LedgerAppVersion>;

Read the version of the IOTA app.

Parameters​

asyncOpts_?​
signal​

AbortSignal

Returns​

Promise<LedgerAppVersion>

Implementation of​

LedgerLike.version


fromTransport()​

static fromTransport(transport): LedgerLike;

Communicate with the device through a transport implemented in the host language.

open_app closes whichever other app the transport reports as running, so do not call it on an emulator that reports a placeholder app name, such as Speculos started without SPECULOS_APPNAME=IOTA:<version>: it ends the emulated app.

Parameters​

transport​

LedgerTransport

Returns​

LedgerLike


instanceOf()​

static instanceOf(obj_): obj_ is Ledger;

Parameters​

obj_​

any

Returns​

obj_ is Ledger


nativeHid()​

static nativeHid(): LedgerLike;

Connect to the first Ledger device attached over USB.

Fails in builds of the SDK without USB support, such as those for Android, iOS and the web.

Returns​

LedgerLike


speculos()​

static speculos(host, port): LedgerLike;

Connect to the APDU port of a Speculos emulator (by default this is 127.0.0.1:9999 in the emulator).

Calls through this connection block the thread running them until the emulator answers, and fail in the WASM bindings, which have no TCP sockets.

Parameters​

host​

string

port​

number

Returns​

LedgerLike