@colony/purser-trezor

These docs serve to outline the API format and methods provided by the @colony/purser-trezor library.

Unlike other wallet libraries, this one works entirely in async mode, meaning every return will be a Promise that must resolve (or reject, if something goes wrong...).

Console output

In development mode there will be a number of warnings or errors outputted verbosely to the console.

When building with NODE_ENV=production all output will be silenced.

Hardware

A hardware device that gives you access to it's internal stored account(s). Usually enforced by a hardware true random number generator.

For a more in-depth look at what the resulting object looks like, see the Common Wallet Interface docs.

Note: Trezor Bridge

To be able to use the Trezor Wallet inside a browser, you'll need to install and start a Trezor Bridge Service, otherwise the hardware device won't be able to talk to the browser.

If the above link doesn't work, here's an alternative download location

Note: Firmware Version

The Trezor Wallet only started supporting Ethereum methods in firmware version 1.4.0, so make sure your device has this version at least. (But most likely it will have a newer version). A safe bet is to update it to the latest one.

Just make sure that, if you're updating your firmware version, it will wipe all your device's memory and you'll have to restore it from a saved seed.

Imports:

There are different ways in which you can import the library in your project (as a module), but in the end they all bring in the same thing:

Using ES5 require() statements:

var trezor = require('@colony/purser-trezor'); // trezor.open().then();

var open = require('@colony/purser-trezor').open; // open().then();

Using ES6 import statements:

import trezor from '@colony/purser-trezor'; // await trezor.open();

import { open } from '@colony/purser-trezor'; // await open();

Methods

open

await open(walletArguments: Object);

This method returns a Promise which, after confirming the Ethereum Account Export via the window prompt (and optionally entering your PIN), it will resolve and return a new TrezorWallet instance object. (See: Common Wallet Interface for details).

By default, without any arguments it will open the first 10 accounts in the derivation path, but you can change that via the addressCount object prop argument (Unlike the software wallet, this is the only argument the open method takes, but to preserved consistency, it's still being passed in as an object).

Also, the first index from the addresses that you opened will be selected as the default one (See: the setDefaultAddress() method from the Common Wallet Interface), while the rest of them will be available under the otherAddresses Array prop on the wallet instance.

Argument props

walletArguments.addressCount: Number = 10

Sets the number of addresses to derive from the derivation path. Defaults to 10 and cannot be set lower than 1.

It will set first one as the default (index 0), while the rest will be available through the otherAddresses Array, found as a prop on the Wallet Instance (index 0 through 9 in this case).

You will be able to change them using the setDefaultAddress() instance method (See: Common Wallet Interface for details)).

walletArguments.chainId: Number = 1

Sets the id of the network (eg: homestead, ropsten, etc...) you want your account to be opened under (changes the derivationPath of the opened addresses).

It will also be used if you don't provide one when trying to sign a transaction.

Defaults to id 1: homestead.

Usage examples:

Open the trezor wallet using the default number of addresses:

import { open } from '@colony/purser-trezor';

const wallet = await open();

Open the trezor wallet using a custom number of addresses:

import { open } from '@colony/purser-trezor';

const wallet = await open({ addressCount: 100 });

// Optionally set another address as the default

await wallet.setDefaultAddress(12); //true

Open the trezor wallet using a different chain id:

import { open } from '@colony/purser-trezor';

const wallet = await open({ chainId: 3 }); // ropsten

await wallet.derivationPath; // m/44'/1'/0'/0/0