npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

trezor-cli-wallet-provider

v1.0.8

Published

A CLI based web3 trezor wallet provider

Downloads

69

Readme

trezor-cli-wallet-provider

A CLI based web3 trezor wallet provider. This provider relies on the Trezor wallet's Python based command line interface trezorctl https://wiki.trezor.io/Using_trezorctl_commands_with_Trezor . In order to use this you must ensure the trezorctl is installed correctly.

Note: Please ensure your trezor firmware is up-to-date

Installing trezorctl

  • Install python 3.5+
    brew update
    brew install pip3
  • Install python dependencies
    pip3 install setuptools wheel attrs web3 rlp trezor
  • update your $PATH by sourcing your profile so that trezorctl is available in your path. Execute the following to confirm trezorctl has been installed.
    trezorctl --version
  • Install Trezor Bridge https://wiki.trezor.io/Trezor_Bridge. And reconnect your Trezor device after this step.

Unlocking Your Trezor (Model One only)

The trezor will go into sleep mode after a specified period of inactivity (10 minute by default). When you are asked for PIN, you have to enter scrambled PIN. Follow the numbers shown on Trezor display and enter the their positions using the numeric keyboard mapping (this will be displayed on the CLI to aid you):

| | | | |---|---|---| | 7 | 8 | 9 | | 4 | 5 | 6 | | 1 | 2 | 3 |

Example: your PIN is 1234 and Trezor is displaying the following:

| | | | |---|---|---| | 2 | 8 | 3 | | 5 | 4 | 6 | | 7 | 9 | 1 |

You have to enter: 3795

You may bypass the CLI unlock prompt by using the Trezor Bridge to unlock your wallet (the CLI unlock is a bit of a mind puzzle 🤪). To do so, navigate to https://wallet.trezor.io, make sure your trezor is connected, and enter the PIN to unlock your trezor when prompted.

Unlocking Your Trezor (Model T only)

For a Model T, then just unlock your Trezor from its screen before you start using it.

Configuring Truffle

To use this provider in truffle you can add this provider like so in your truffle-config.js:

const TrezorWalletProvider = require("trezor-cli-wallet-provider");
module.exports = {
  networks: {
    xdai: {
      provider: function () {
      return new TrezorWalletProvider("https://rpc.xdaichain.com/", {
        chainId: 100,
      });
    },
    gasPrice: 1000000000,
    network_id: 100,
    }
  }
}

Where the constructor is initialized with a:

  • A JSON-RPC URL like infura, blockscout, etc.
  • An optional options object that can specify:
    • chainId The chain ID of the network. This is exactly the same as the network_id, we provide it here too, because not all web3 clients initialize the txn object in a way that includes the chain ID. If this is not specified, then chain ID of 1 (Ethereum mainnet) is used as the default.
    • derviationPath A specific derivation path to use, e.g. m/44'/60'/0'/0/13. When this option is specified the only account available in your wallet will be the derivation path that you specify and the derviationPathPrefix and numberOfAccounts options will be ignored.
    • derivationPathPrefix The derivation path prefix (not including the address index) to use. This defaults to m/44'/60'/0'/0 which is the default derivation path for Ethereum.
    • numberOfAccounts This is used to return address on the Trezor wallet. This defaults to just a single address (the first derivation path), but you can include more. There is a pretty significant performance penalty for additional addresses.

When truffle migrate or a truffle script sign a transaction, a prompt will appear on the command line to confirm the details of the transaction, like so:

Please confirm action on your Trezor device.

If the trezor is locked, it will first prompt you to enter your pin using the procedure described above.

Here is a little video demo of the provider in action: https://www.loom.com/share/364c1321eadf488aaf767ad008365e44

Additional Considerations

Do note that this web3 provider does not seem to work with the OpenZeppelin CLI (if someone can figure out why, I'd love to get a PR). So if you'd like to use upgradeable contracts, I's suggest using truffle migrate paired with @openzeppelin/truffle-upgrades pkg https://docs.openzeppelin.com/upgrades-plugins/1.x/.