Developers guide:Trezor Connect API Methods

From Trezor Wiki
Jump to: navigation, search
Trezor Wiki/Developer/Developers guide/ Trezor Connect API Methods


Trezor Connect is a platform for easy integration of various functions that can be used with the Trezor device into websites or applications (eg. cryptocurrency web wallets). Every method requires an object with a combination of common fields and method specific fields.

Methods that can be used with all cryptocurrencies implemented in Trezor device firmware are the following:


NoteAdditional technical documentation of Trezor Connect API methods can be found on this GitHub page


getPublicKey[edit]

Get public key method retrieves BIP32 the extended public key derived by the given BIP32 path. The user is presented with a description of the requested key and asked to confirm the export.

How it works[edit]

1. After using the getPublicKey, a new method tab is open which connects to the trezor.io domain (https://connect.trezor.io/5/popup.html) or to localhost (if connected to Trezor Connect which runs locally). If the Trezor device is not plugged in or it is locked with a PIN, the user is asked to connect (unlock with PIN) the device to continue.

GetPublicKey0.png

2. Trusted domain (trezor.io or localhost) now requires permissions to read public keys from the Trezor device:

It is possible to allow permissions just for the session...

GetPublicKey1.png

...or for every time this method is called.

GetPublicKey2.png

3. Now it is possible to export the public keys.

GetPublicKey3.png

4. Confirm the action on the Trezor device.

GetPublicKey4.png

5. Trezor Connect will respond with the public key.

getAddress[edit]

Get Address method displays the requested address derived by the given BIP32 path on the device and returns it to the caller. It is possible to use the "Show on Trezor" option or not. The user is asked to confirm the export on the Trezor device.

How it works[edit]

1. The first and the second steps are the same as in the getPublicKey method. The user is asked to plug in and unlock the Trezor device and has to allow the trusted domain permissions to read public keys from the Trezor device.

2. If the "Show on Trezor" option is enabled, the address will be now shown on the Trezor screen.

GetAddress1.png

3. Trezor connect will now respond with the address.

signMessage[edit]

The sign message method asks the device to sign a message using the private key derived by the given BIP32 path. The message is an obligatory part.

How it works[edit]

1. The first step is the same as in the getPublicKey method. The user is asked to plug in and unlock the Trezor device.

2. The trusted domain (trezor.io or localhost) now requires permissions to read public keys from the Trezor device and to prepare it for the transaction and data signing.

It is possible to allow permissions just for the session...

SignMessage1.png

...or for every time this method is called.

SignMessage2.png

3. Now it is necessary to confirm the signing on the Trezor device.

4. Trezor Connect will respond with the signed or unsigned(error) message.

verifyMessage[edit]

Verify message asks the device to verify a message using the signer address and signature. The obligatory parts are the address, message, signature and coin type.

How it works[edit]

1. The first and the second steps are the same as for the signMessage method. The user is asked to plug in and unlock the Trezor device. The trusted domain (trezor.io or localhost) now requires permissions to read the public keys from the Trezor device and to prepare it for the transaction and data signing. It is possible to allow permissions just for the session or for every time this method is called.

2. The user has to confirm the address and then the message being verified on the device.

3. Trezor connect will respond with the verified or unverified(error) response

signTransaction[edit]

Sign transaction asks the device to sign given inputs and outputs of a pre-composed transaction. The user is asked to confirm all transaction details on the Trezor device. Obligatory parts are inputs, outputs and coin type. An optional part is if it should be pushed/broadcasted to blockchain or not.

How it works[edit]

1. The first and the second steps are the same as in the signMessage method. The user is asked to plug in and unlock the Trezor device. Teh trusted domain (trezor.io or localhost) now requires permissions to read the public keys from the Trezor device and to prepare it for te transaction and data signing. It is possible to allow permissions just for the session or for every time this method is called.

2. Check the recipient address and confirm it on the device.

SignTransaction1.png

3. Check the transaction details (total amount including fee) and hold to confirm on the device.

4. Trezor Connect will respond with the signed or unsigned(error) transaction

See also Trezor Connect API

Like Trezor? Get one here!