Skip to main content

Python library for communicating with Trezor Hardware Wallet

Project description

trezorlib

repology image

Python library and command-line client for communicating with Trezor Hardware Wallet.

See https://trezor.io for more information.

Install

Python Trezor tools require Python 3.9 or higher, and libusb 1.0. The easiest way to install it is with pip. The rest of this guide assumes you have a working pip; if not, you can refer to this guide.

On a typical system, you already have all you need. Install trezor with:

pip3 install trezor

On Windows, you also need to either install Trezor Bridge, or libusb and the appropriate drivers.

Firmware version requirements

Current trezorlib version supports Trezor One version 1.8.0 and up, Trezor T version 2.1.0 and up, and all versions of the Trezor Safe family.

For firmware versions below 1.8.0 and 2.1.0 respectively, the only supported operation is "upgrade firmware".

Trezor One with firmware older than 1.7.0 and bootloader older than 1.6.0 (including pre-2021 fresh-out-of-the-box units) will not be recognized, unless you install HIDAPI support (see below).

Installation options

  • Bluetooth: To support connecting to T3W1 or later models via Bluetooth, additional dependencies are needed. Install with:

    pip3 install trezor[ble]
    
  • Ethereum: To support Ethereum signing from command line, additional packages are needed. Install with:

    pip3 install trezor[ethereum]
    
  • Stellar: To support Stellar signing from command line, additional packages are needed. Install with:

    pip3 install trezor[stellar]
    
  • Firmware-less Trezor One: If you are setting up a brand new Trezor One manufactured before 2021 (with pre-installed bootloader older than 1.6.0), you will need HIDAPI support. On Linux, you will need the following packages (or their equivalents) as prerequisites: python3-dev, cython3, libusb-1.0-0-dev, libudev-dev.

    Install with:

    pip3 install trezor[hidapi]
    

To install all four, use pip3 install trezor[ble,hidapi,ethereum,stellar].

Distro packages

Check out Repology to see if your operating system has an up-to-date python-trezor package.

Running from source

Install the uv tool, checkout trezor-firmware from git, and activate the uv environment:

git clone https://github.com/trezor/trezor-firmware
cd trezor-firmware
git submodule update --init --recursive
uv sync
source .venv/bin/activate

In this environment, trezorlib and the trezorctl tool is running from the live sources, so your changes are immediately effective.

Command line client (trezorctl)

The included trezorctl python script can perform various tasks such as changing setting in the Trezor, signing transactions, retrieving account info and addresses. See the python/docs/ sub folder for detailed examples and options.

NOTE: An older version of the trezorctl command is available for Debian Stretch (and comes pre-installed on Tails OS).

Python Library

You can use this python library to interact with a Trezor and use its capabilities in your application. See examples here in the tools/ sub folder.

Changelog

Visit CHANGELOG.md for the latest changes.

Contributing

If you want to change protobuf definitions, you will need to regenerate definitions in the python/ subdirectory.

First, make sure your submodules are up-to-date with:

git submodule update --init --recursive

Then, rebuild the protobuf messages by running, from the trezor-firmware top-level directory:

make gen

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trezor-0.20.0.tar.gz (362.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trezor-0.20.0-py3-none-any.whl (290.2 kB view details)

Uploaded Python 3

File details

Details for the file trezor-0.20.0.tar.gz.

File metadata

  • Download URL: trezor-0.20.0.tar.gz
  • Upload date:
  • Size: 362.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trezor-0.20.0.tar.gz
Algorithm Hash digest
SHA256 4c098e20315b2716673abdef402822e7189101598c7c03f23749dd2010ee2504
MD5 27ead4d28c19d18631585134f4b7c502
BLAKE2b-256 91b48f7ac04be8942f088f724598752b1f348b3f6f819efad75f82602ec3781c

See more details on using hashes here.

File details

Details for the file trezor-0.20.0-py3-none-any.whl.

File metadata

  • Download URL: trezor-0.20.0-py3-none-any.whl
  • Upload date:
  • Size: 290.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.16 {"installer":{"name":"uv","version":"0.9.16","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for trezor-0.20.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2be1456cc68686828702e612b8ce133afef8e9b188fe29130ef367e84b013e9f
MD5 1a7405666aba67baad0dedafd51250c5
BLAKE2b-256 ed47e4b6da5187c0d06e25053654cd1207f2f98340f487b5fdfd2bd0b282b0e6

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page