Norse Polytheistic Mythology
    Have ideas to improve npm?Join in the discussion! »


    1.6.0 • Public • Published

    trezor-wallet / ReadmeContributingChangelog


    Licence Dependencies Vulnerabilities Bundle Downloads

    Easy Trezor wallet support for Stellar applications.

    (Weekly updates: Reddit, Twitter, Keybase, Telegram)


    This library is a convenient wrapper around the official TrezorConnect library.

    It provides a way to support Trezor devices with a few one-liners:

    // Step 1: Connect
    await trezorWallet.connect()
    // Step 2: Get public key
    const pubkey = trezorWallet.publicKey
    // Step 3: Sign
    await trezorWallet.sign(transaction)
    // Extra: Event handlers
    trezorWallet.onConnect = connectionHandler
    trezorWallet.onDisconnect = disconnectionHandler

    This library is browser-only.

    Known limitations

    A few operations & parameters are not supported yet. An explicit error message will get thrown if you try to sign a transaction including them:

    • Binary text memo containing NULL characters,
    • The manageBuyOffer operation,
    • The pathPaymentStrictSend operation.

    If you encounter an unexpected error, please fill an issue.



    • NPM: npm install @cosmic-plus/trezor-wallet
    • Yarn: yarn add @cosmic-plus/trezor-wallet

    In your script: const trezorWallet = require("@cosmic-plus/trezor-wallet")


    bower install cosmic-plus-trezor-wallet

    In your HTML page:

    <script src="./bower_components/cosmic-plus-trezor-wallet/trezor-wallet.js"></script>


    In your HTML page:

    <script src=""></script>

    Note: For production release it is advised to serve your copy of the library.



    trezorWallet.register(appUrl, email)

    Registers yourself in the Trezor Connect Manifest. This provides them the ability to reach you in case of any required maintenance.

    This subscription is mandatory and the library register the contact by default.

    See: Trezor Connect Manifest

    • appUrl: String - Application URL.
    • email: String - Developer email.

    await trezorWallet.connect([account])

    Waits for a connection with a Trezor wallet. If account is not provided, account 1 is used. The library will stop listening for a connection if trezorWallet.disconnect() is called.

    Once the connection is established, you can use await trezorWallet.connect(account) again at any time to ensure the device is still connected.

    When switching to another account, you can await trezorWallet.connect(new_account) without prior disconnection.

    Note: To stay consistent with the way Trezor numbers accounts, account starts at 1 (derivation path: m/44'/148'/0').


    • account: Number | String (default: 1) - Either an account number (starts at 1) or a derivation path (e.g: m/44'/148'/0').

    await trezorWallet.sign(transaction)

    Prompts the user to accept transaction using the connected account of their Trezor device.

    If the user accepts, adds the signature to transaction. Else, throws an error.


    • transaction: Transaction - A StellarSdk Transaction


    Close the connection with the Trezor device, or stop waiting for one in case a connection has not been established yet.


    Connects the first unused account.

    Note: merged accounts are considered as used.


    • horizon: String | Server (default: - The Horizon server where to check for account existence. It can be either an URL or a StellarSdk.Server object.

    trezorWallet.scan([params]) ⇒ Array

    Scans the Trezor device for accounts that exist on params.horizon. The scanning stops after encountering params.attempts unused accounts.

    Merged accounts are considered as existing accounts and will reset the params.attempts counter when encountered.

    Returns an Array of Objects containing account number, publicKey, path, and state (either "open" or "merged").


    • params: Object - Optional parameters.
      • horizon: String | Server (default: - The Horizon server where to check for account existence. It can be either an URL or a StellarSdk.Server object.
      • attempts: Number (default: 3) - The number of empty accounts before scanning stops.
      • includeMerged: Boolean (default: false) - List merged accounts as well.

    trezorWallet.getPublicKeys([start], [length]) ⇒ Array

    Request multiple public keys from the Trezor device. The request will return length accounts, starting by start (minimum 1).

    Returns an Array of Objects with properties account, publicKey, and path.


    • start: Number (default: 1) - Starting account number
    • length: Number (default: 1) - Number of account to be listed.


    trezorWallet.onConnect : function

    Function to execute on each connection.

    trezorWallet.onDisconnect : function

    Function to execute on each disconnection.


    trezorWallet.publicKey : String

    PublicKey of the connected account.

    trezorWallet.path : String

    Derivation path of the connected account. (default: m/44'/148'/0')


    Organization: | @GitHub | @NPM

    Follow: Reddit | Twitter | Medium | Codepen

    Talk: Telegram | Keybase


    npm i @cosmic-plus/trezor-wallet

    DownloadsWeekly Downloads






    Unpacked Size

    53.5 kB

    Total Files


    Last publish


    • avatar