Skip to content
Easy Trezor wallet support for Stellar applications (sources)
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
web @ d89ad7e

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)

This library is browser-only.

Beta Release

This is a beta release that is made public for testing purposes. While the library is stable & secure, several issues are still being worked out with Trezor teams.

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 manageData operation,
  • The manageBuyOffer operation

If you encounter an unexpected error, please play the game and fill an issue.

The public release will possibly contain one or more breaking changes. Please check the changelog before upgrading.



  • 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

Param Type Description
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() 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 number accounts, account starts at 1 (derivation path: m/44'/148'/0').

Param Type Default Description
[account] Number | String 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.

Param Type Description
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.

Param Type Default Description
[horizon] String | Server &quot;; 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").

Param Type Default Description
[params] Object Optional parameters.
[params.horizon] String | Server &quot;; The Horizon server where to check for account existence. It can be either an URL or a StellarSdk.Server object.
[params.attempts] Number 3 The number of empty accounts before scanning stops.
[params.includeMerged] Boolean 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.

Param Type Default Description
[start] Number 1 Starting account number
[length] Number 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

You can’t perform that action at this time.