mirror of
https://github.com/trezor/trezor-suite.git
synced 2026-02-20 00:33:07 +01:00
docs(connect): remove docs that are replaced by Connect Explorer
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 66 KiB |
@@ -1,98 +1,5 @@
|
||||
# Trezor javascript SDK
|
||||
|
||||
There are couple of options how to integrate Trezor devices with your project. This page walks you through
|
||||
installation and lets you explore SDK API.
|
||||
Most of Trezor Connect documentation has been moved to [Connect Explorer](https://connect.trezor.io/).
|
||||
|
||||
## Chose your SDK
|
||||
|
||||
Depending on your environment you need to chose the right package.
|
||||
|
||||
| package | environment |
|
||||
| :---------------------------------------------------------------------------------------------------------------- | :-------------------------------- |
|
||||
| [@trezor/connect](https://github.com/trezor/trezor-suite/tree/develop/packages/connect) | node.js |
|
||||
| [@trezor/connect-web](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-web) | web based (DOM required) |
|
||||
| [@trezor/connect-webextension](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-webextension) | webextension using service worker |
|
||||
|
||||
If you are still unsure which package is the right one you may refer to the following table with a collection of examples.
|
||||
|
||||
| env example | package |
|
||||
| :-------------------------------------------------------------------------------------------------------------------------------------------------- | :--------------------------- |
|
||||
| [node](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/node) | @trezor/connect |
|
||||
| [web app](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/browser-inline-script) | @trezor/connect-web |
|
||||
| [web extension mv2 (foreground or background)](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/webextension-mv2) | @trezor/connect-web |
|
||||
| [web extension mv3 (foreground)](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/webextension-mv3) | @trezor/connect-web |
|
||||
| [web extension mv3 (background)](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/webextension-mv3-sw) | @trezor/connect-webextension |
|
||||
| [electron in main layer](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/electron-main-process) | @trezor/connect |
|
||||
| [electron in renderer layer with popup](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-examples/electron-renderer-with-popup) | @trezor/connect-web |
|
||||
| [Trezor Suite (desktop) electron app](https://github.com/trezor/trezor-suite/blob/develop/packages/suite-desktop/README.md) | @trezor/connect |
|
||||
|
||||
## Quick start
|
||||
|
||||
Import from your selected package
|
||||
|
||||
```javascript
|
||||
// in node
|
||||
import TrezorConnect from '@trezor/connect';
|
||||
// or in web based
|
||||
import TrezorConnect from '@trezor/connect-web';
|
||||
// or in webextension service worker
|
||||
import TrezorConnect from '@trezor/connect-webextension';
|
||||
```
|
||||
|
||||
Initialize in project
|
||||
|
||||
```javascript
|
||||
TrezorConnect.init({
|
||||
lazyLoad: true, // this param will prevent iframe injection until TrezorConnect.method will be called
|
||||
manifest: {
|
||||
email: 'developer@xyz.com',
|
||||
appUrl: 'http://your.application.com',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Trezor Connect Manifest requires that you, as a Trezor Connect integrator, share your e-mail and application url with us.
|
||||
This provides us with the **ability to reach you in case of any required maintenance.**
|
||||
This subscription is mandatory. Trezor Connect raises an error that reads "Manifest not set" if manifest is not provided. It can be either set via `manifest` method or passed as a param in `init` method.
|
||||
|
||||
```javascript
|
||||
TrezorConnect.manifest({
|
||||
email: 'developer@xyz.com',
|
||||
appUrl: 'http://your.application.com',
|
||||
});
|
||||
```
|
||||
|
||||
If you need more customization, refer to [init method documentation](./methods/init.md)
|
||||
|
||||
## API methods
|
||||
|
||||
- [List of methods](methods.md)
|
||||
|
||||
## Handling events
|
||||
|
||||
- [Events](events.md)
|
||||
|
||||
## How it works under the hood
|
||||
|
||||
There is a major difference between node.js based package (`@trezor/connect`) and web based packages (`@trezor/connect-web` and `@trezor/connect-webextension`).
|
||||
In the former the entire SDK logic is a module of the 3rd party application whereas in the latter, there is strict isolation between 3rd party application code and SDK core logic.
|
||||
|
||||
### Node.js
|
||||
|
||||
In node.js core SDK is loaded as a javascript module without any specificities.
|
||||
|
||||

|
||||
|
||||
### Web
|
||||
|
||||
`@trezor/connect-web` imports only a thin layer with API description into your 3rd party application. When initiated, it injects iframe containing core SDK logic from trezor.io
|
||||
into your app. User input, if needed, is served by popup.html page opened on trezor.io on behalf of your application. This way users input such as pin or passphrase is isolated from you and persistent connection between your app and core SDK is kept so events such as device connected/disconnected or blockchain subscriptions are available.
|
||||
|
||||

|
||||
|
||||
### Webextension
|
||||
|
||||
In case of `@trezor/connect-webextension`, TrezorConnect object is created in a service worker. In this env we can't inject iframe so in order to uphold the same security model as with
|
||||
`@trezor/connect-web` we open popup.html and load core SDK logic into it. This however does not build persistent connection between SDK and 3rd party application meaning that events cannot be used.
|
||||
|
||||

|
||||
This page contains some remaining documentation useful for developers or internal purposes.
|
||||
|
||||
@@ -1,91 +1,3 @@
|
||||
# Methods
|
||||
# Connect Methods
|
||||
|
||||
API call return a [`Promise`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise). Resolve is guaranteed to get called
|
||||
with a `result` object, even if user closes the window, network connection times
|
||||
out, etc. In case of failure `result.success` is set to false and `result.payload.error` is
|
||||
the error message. It is recommended to log the error message and let user
|
||||
restart the action.
|
||||
|
||||
Every method require an [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) with combination of [`common`](methods/commonParams.md) fields and method specific fields.
|
||||
|
||||
- [TrezorConnect.getPublicKey](methods/getPublicKey.md)
|
||||
- [TrezorConnect.requestLogin](methods/requestLogin.md)
|
||||
- [TrezorConnect.cipherKeyValue](methods/cipherKeyValue.md)
|
||||
- [TrezorConnect.wipeDevice](methods/wipeDevice.md)
|
||||
- [TrezorConnect.resetDevice](methods/resetDevice.md)
|
||||
- [TrezorConnect.getCoinInfo](methods/getCoinInfo.md)
|
||||
- [TrezorConnect.getDeviceState](methods/getDeviceState.md)
|
||||
|
||||
## Bitcoin, Bitcoin Cash, Bitcoin Gold, Litecoin, Dash, ZCash, Testnet
|
||||
|
||||
- [TrezorConnect.getAddress](methods/getAddress.md)
|
||||
- [TrezorConnect.getAccountInfo](methods/getAccountInfo.md)
|
||||
- [TrezorConnect.getOwnershipId](methods/getOwnershipId.md)
|
||||
- [TrezorConnect.getOwnershipProof](methods/getOwnershipProof.md)
|
||||
- [TrezorConnect.composeTransaction](methods/composeTransaction.md)
|
||||
- [TrezorConnect.signTransaction](methods/signTransaction.md)
|
||||
- [TrezorConnect.pushTransaction](methods/pushTransaction.md)
|
||||
- [TrezorConnect.signMessage](methods/signMessage.md)
|
||||
- [TrezorConnect.verifyMessage](methods/verifyMessage.md)
|
||||
- [TrezorConnect.authorizeCoinjoin](methods/authorizeCoinjoin.md)
|
||||
|
||||
## Ethereum
|
||||
|
||||
- [TrezorConnect.ethereumGetAddress](methods/ethereumGetAddress.md)
|
||||
- [TrezorConnect.ethereumSignTransaction](methods/ethereumSignTransaction.md)
|
||||
- [TrezorConnect.ethereumSignMessage](methods/ethereumSignMessage.md)
|
||||
- [TrezorConnect.ethereumSignTypedData](methods/ethereumSignTypedData.md)
|
||||
- [TrezorConnect.ethereumVerifyMessage](methods/ethereumVerifyMessage.md)
|
||||
|
||||
## Eos
|
||||
|
||||
- [TrezorConnect.eosGetPublicKey](methods/eosGetPublicKey.md)
|
||||
- [TrezorConnect.eosSignTransaction](methods/eosSignTransaction.md)
|
||||
|
||||
## NEM
|
||||
|
||||
- [TrezorConnect.nemGetAddress](methods/nemGetAddress.md)
|
||||
- [TrezorConnect.nemSignTransaction](methods/nemSignTransaction.md)
|
||||
|
||||
## Stellar
|
||||
|
||||
- [TrezorConnect.stellarGetAddress](methods/stellarGetAddress.md)
|
||||
- [TrezorConnect.stellarSignTransaction](methods/stellarSignTransaction.md)
|
||||
|
||||
## Cardano
|
||||
|
||||
- [TrezorConnect.cardanoGetPublicKey](methods/cardanoGetPublicKey.md)
|
||||
- [TrezorConnect.cardanoGetAddress](methods/cardanoGetAddress.md)
|
||||
- [TrezorConnect.cardanoSignTransaction](methods/cardanoSignTransaction.md)
|
||||
|
||||
## Ripple
|
||||
|
||||
- [TrezorConnect.rippleGetAddress](methods/rippleGetAddress.md)
|
||||
- [TrezorConnect.rippleSignTransaction](methods/rippleSignTransaction.md)
|
||||
|
||||
## Solana
|
||||
|
||||
- [TrezorConnect.solanaGetPublicKey](methods/solanaGetPublicKey.md)
|
||||
- [TrezorConnect.solanaGetAddress](methods/solanaGetAddress.md)
|
||||
- [TrezorConnect.solanaSignTransaction](methods/solanaSignTransaction.md)
|
||||
|
||||
## Tezos
|
||||
|
||||
- [TrezorConnect.tezosGetAddress](methods/tezosGetAddress.md)
|
||||
- [TrezorConnect.tezosGetPublicKey](methods/tezosGetPublicKey.md)
|
||||
- [TrezorConnect.tezosSignTransaction](methods/tezosSignTransaction.md)
|
||||
|
||||
## Binance
|
||||
|
||||
- [TrezorConnect.binanceGetAddress](methods/binanceGetAddress.md)
|
||||
- [TrezorConnect.binanceGetPublicKey](methods/binanceGetPublicKey.md)
|
||||
- [TrezorConnect.binanceSignTransaction](methods/binanceSignTransaction.md)
|
||||
|
||||
## Management
|
||||
|
||||
> please note that these method are not available from popup mode
|
||||
|
||||
- [TrezorConnect.firmwareUpdate](methods/firmwareUpdate.md)
|
||||
- [TrezorConnect.getFirmwareHash](methods/getFirmwareHash.md)
|
||||
- [TrezorConnect.changePin](methods/changePin.md)
|
||||
- [TrezorConnect.changeWipeCode](methods/changeWipeCode.md)
|
||||
Connect methods documentation has been moved to [Connect Explorer](https://connect.trezor.io/).
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
## Apply flags
|
||||
|
||||
Change device flags. This methods allows you to set a mark on device (number) which must not be lower than
|
||||
previously set flag.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.applyFlags(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `flags` — required `number`
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "Flags applied"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,44 +0,0 @@
|
||||
## Apply settings
|
||||
|
||||
Change device settings
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.applySettings(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `flags` — _optional_ `string`
|
||||
- `use_passphrase` - _optional_ `boolean`
|
||||
- `homescreen` - _optional_ `bytes`
|
||||
- `auto_lock_delay_ms` - _optional_ `number`
|
||||
- `display_rotation` - _optional_ `0|90|180|270`
|
||||
- `passphrase_always_on_device` - _optional_ `boolean`
|
||||
- `safety_checks` - _optional_ enum `"PromptTemporarily" | "Strict" | "PromptAlways"`
|
||||
- `experimental_features` - _optional_ `boolean`
|
||||
- `hide_passphrase_from_host` - _optional_ `boolean`
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "Settings applied"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,27 +0,0 @@
|
||||
## authenticateDevice
|
||||
|
||||
> :note: **Not supported on T1B1 and T2T1**
|
||||
|
||||
Request a signature and validate certificate issued by the Trezor company.
|
||||
Returns [DeviceAuthenticityResult type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/authenticateDevice.ts)
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `config` — _optional_ [`DeviceAuthenticityConfig`](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/authenticateDevice.ts)
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.authenticateDevice({ config });
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: DeviceAuthenticityResult
|
||||
}
|
||||
```
|
||||
@@ -1,77 +0,0 @@
|
||||
## Bitcoin: authorize coinjoin
|
||||
|
||||
Allow device to do preauthorized operations in `signTransaction` and `getOwnershipProof` methods without further user interaction.
|
||||
|
||||
Permission persists until physical device disconnection or `maxRounds` limit is reached.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.authorizeCoinjoin(params);
|
||||
```
|
||||
|
||||
> :warning: **This feature is experimental! Do not use it in production!**
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.5.3 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single id
|
||||
|
||||
- `path` — _required_ `string | Array<number>`
|
||||
> prefix of the BIP-32 path leading to the account (m / purpose' / coin_type' / account')[read more](../path.md)
|
||||
- `coordinator` — _required_ `string`
|
||||
> coordinator identifier to approve as a prefix in commitment data (max. 36 ASCII characters)
|
||||
- `maxRounds` — _required_ `number`
|
||||
> maximum number of rounds that Trezor is authorized to take part in
|
||||
- `maxCoordinatorFeeRate` — _required_ `number`
|
||||
> maximum coordination fee rate in units of 10\*\*6 percent
|
||||
- `maxFeePerKvbyte` — _required_ `number`
|
||||
> maximum mining fee rate in units of satoshis per 1000 vbytes
|
||||
- `coin` - _optional_ `string`
|
||||
> Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file.
|
||||
> Coin `shortcut`, `name` or `label` can be used.
|
||||
- `scriptType` — _optional_ `PROTO.InputScriptType`
|
||||
> used to distinguish between various address formats (non-segwit, segwit, etc.)
|
||||
- `amountUnit` — _optional_ `PROTO.AmountUnit`
|
||||
> show amounts in
|
||||
- `preauthorized` — _optional_
|
||||
> Check if device session is already preauthorized and take no further action if so
|
||||
- `coinjoinRequest` — _optional_ `PROTO.CoinJoinRequest`
|
||||
> Signing request for a coinjoin transaction
|
||||
|
||||
### Example:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.authorizeCoinjoin({
|
||||
path: "m/10086'/0'/0'",
|
||||
maxRounds: 3,
|
||||
maxCoordinatorFeeRate: 500000, // 0.5% => 0.005 * 10**8;
|
||||
maxFeePerKvbyte: 3500,
|
||||
scriptType: 'SPENDWITNESS',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Coinjoin authorized'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,116 +0,0 @@
|
||||
## Binance: get address
|
||||
|
||||
Display requested address derived by given [BIP44 path](../path.md) on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.binanceGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of first Binance account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceGetAddress({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of Binance addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/714'/0'/0/0", showOnTrezor: false }, // account 1, address 1
|
||||
{ path: "m/44'/714'/1'/0/1", showOnTrezor: false }, // account 2, address 2
|
||||
{ path: "m/44'/714'/2'/0/2", showOnTrezor: false }, // account 3, address 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.binanceGetAddress({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
address: 'bnb1afwh46v6nn30nkmugw5swdmsyjmlxslgjfugre',
|
||||
});
|
||||
// don't forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
address: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path: Array<number>, serializedPath: string, address: string }, // account 1, address 1
|
||||
{ path: Array<number>, serializedPath: string, address: string }, // account 2, address 2
|
||||
{ path: Array<number>, serializedPath: string, address: string } // account 3, address 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,84 +0,0 @@
|
||||
## Binance: get public key
|
||||
|
||||
Display requested public key derived by given [BIP44 path](../path.md) on device and returns it to caller.
|
||||
User is presented with a description of the requested public key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.binanceGetPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
### Example
|
||||
|
||||
Displays public key derived from BIP44 path:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceGetPublicKey({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of public keys without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceGetPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/44'/714'/0'/0/0", showOnTrezor: false }, // public key 1
|
||||
{ path: "m/44'/714'/1'/0/0", showOnTrezor: false }, // public key 2
|
||||
{ path: "m/44'/714'/2'/0/0", showOnTrezor: false }, // public key 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[PublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
publicKey: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of public keys sorted by FIFO
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string }, // public key 1
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string }, // public key 2
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string } // public key 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,115 +0,0 @@
|
||||
## Binance: sign transaction
|
||||
|
||||
Asks device to sign given transaction using the private key derived by given [BIP44 path](../path.md). User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.binanceSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `transaction` - _required_ `Object` type of [BinanceSDKTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/binance/index.ts)
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Transfer example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceSignTransaction({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
transaction: {
|
||||
chain_id: 'Binance-Chain-Nile',
|
||||
account_number: 34,
|
||||
memo: 'test',
|
||||
sequence: 31,
|
||||
source: 1,
|
||||
transfer: {
|
||||
inputs: [
|
||||
{
|
||||
address: 'tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd',
|
||||
coins: [{ amount: 1000000000, denom: 'BNB' }],
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address: 'tbnb1ss57e8sa7xnwq030k2ctr775uac9gjzglqhvpy',
|
||||
coins: [{ amount: 1000000000, denom: 'BNB' }],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Place order example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceSignTransaction({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
transaction: {
|
||||
chain_id: 'Binance-Chain-Nile',
|
||||
account_number: 34,
|
||||
memo: '',
|
||||
sequence: 32,
|
||||
source: 1,
|
||||
placeOrder: {
|
||||
id: 'BA36F0FAD74D8F41045463E4774F328F4AF779E5-33',
|
||||
ordertype: 2,
|
||||
price: 100000000,
|
||||
quantity: 100000000,
|
||||
sender: 'tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd',
|
||||
side: 1,
|
||||
symbol: 'ADA.B-B63_BNB',
|
||||
timeinforce: 1,
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Cancel order example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.binanceSignTransaction({
|
||||
path: "m/44'/714'/0'/0/0",
|
||||
transaction: {
|
||||
chain_id: 'Binance-Chain-Nile',
|
||||
account_number: 34,
|
||||
memo: '',
|
||||
sequence: 33,
|
||||
source: 1,
|
||||
cancelOrder: {
|
||||
refid: 'BA36F0FAD74D8F41045463E4774F328F4AF779E5-29',
|
||||
sender: 'tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd',
|
||||
symbol: 'BCHSV.B-10F_BNB',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[BinanceSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signature: string,
|
||||
public_key: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,48 +0,0 @@
|
||||
## Bitcoin: cancel coinjoin authorization
|
||||
|
||||
Clear device's authorization for coinjoin-related operations.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cancelCoinjoinAuthorization(params);
|
||||
```
|
||||
|
||||
> :warning: **This feature is experimental! Do not use it in production!**
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.5.3 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
### Example:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cancelCoinjoinAuthorization({
|
||||
device,
|
||||
useEmptyPassphrase: device?.useEmptyPassphrase,
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Authorization cancelled'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,387 +0,0 @@
|
||||
## Cardano: get address
|
||||
|
||||
Display requested address derived by given [BIP32-Ed25519](https://cardanolaunch.com/assets/Ed25519_BIP.pdf) path on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cardanoGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[CardanoGetAddress type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `addressParameters` — _required_ see description below
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `protocolMagic` - _required_ `Integer` 764824073 for Mainnet, 1 for Preprod Testnet, 2 for Preview Testnet
|
||||
- `networkId` - _required_ `Integer` 1 for Mainnet, 0 for Testnet
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `derivationType` — _optional_ `CardanoDerivationType` enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with single address fields
|
||||
|
||||
#### Address Parameters
|
||||
|
||||
##### [CardanoAddressParameters type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
- `addressType` - _required_ `CardanoAddressType`/`number` - you can use the flow `CARDANO.ADDRESS_TYPE` object or typescript `CardanoAddressType` enum. Supports all address types.
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `stakingPath` — _optional_ `string | Array<number>` minimum length is `5`. [read more](../path.md) Used for base and reward address derivation
|
||||
- `stakingKeyHash` - _optional_ `string` hex string of staking key hash. Used for base address derivation (as an alternative to `stakingPath`)
|
||||
- `certificatePointer` - _optional_ [CardanoCertificatePointer](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts) object. Must contain `number`s `blockIndex`, `txIndex` and `certificateIndex`. Used for pointer address derivation. [read more about pointer address](https://hydra.iohk.io/build/2006688/download/1/delegation_design_spec.pdf#subsubsection.3.2.2)
|
||||
- `paymentScriptHash` - _optional_ `string` hex string of payment script hash.
|
||||
- `stakingScriptHash` - _optional_ `string` hex string of staking script hash.
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display byron address of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BYRON,
|
||||
path: "m/44'/1815'/0'/0/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display base address of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BASE,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
stakingPath: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display base address with script payment part:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BASE_SCRIPT_KEY,
|
||||
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
|
||||
stakingPath: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display base address with script staking part:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BASE_KEY_SCRIPT,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display base address with both payment and staking part being a script:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BASE_SCRIPT_SCRIPT,
|
||||
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
|
||||
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display pointer address of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.POINTER,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
certificatePointer: {
|
||||
blockIndex: 1,
|
||||
txIndex: 2,
|
||||
certificateIndex: 3,
|
||||
},
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display pointer script address:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.POINTER_SCRIPT,
|
||||
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
|
||||
certificatePointer: {
|
||||
blockIndex: 1,
|
||||
txIndex: 2,
|
||||
certificateIndex: 3,
|
||||
},
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display enterprise address of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.ENTERPRISE,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display enterprise script address:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.ENTERPRISE_SCRIPT,
|
||||
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display reward address of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.REWARD,
|
||||
stakingPath: "m/1852'/1815'/0'/0/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Display reward script address:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.REWARD_SCRIPT,
|
||||
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of cardano addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
bundle: [
|
||||
// byron address, account 1, address 1
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: 8,
|
||||
path: "m/44'/1815'/0'/0/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
showOnTrezor: false,
|
||||
},
|
||||
// base address with staking key hash, account 1, address 1
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: 0,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
stakingKeyHash: '1bc428e4720702ebd5dab4fb175324c192dc9bb76cc5da956e3c8dff',
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
showOnTrezor: false,
|
||||
},
|
||||
// byron address, account 2, address 3, testnet
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: 8,
|
||||
path: "m/44'/1815'/1'/0/2",
|
||||
},
|
||||
protocolMagic: 1,
|
||||
networkId: 0,
|
||||
showOnTrezor: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.cardanoGetAddress({
|
||||
addressParameters: {
|
||||
addressType: 8,
|
||||
path: "m/44'/1815'/0'/0/0",
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 0,
|
||||
address: 'Ae2tdPwUPEZ5YUb8sM3eS8JqKgrRLzhiu71crfuH2MFtqaYr5ACNRdsswsZ',
|
||||
});
|
||||
// don't forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[CardanoAddress type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
addressParameters: {
|
||||
addressType: number,
|
||||
path: Array<number>, // hardened path
|
||||
stakingPath?: Array<number>, // hardened path
|
||||
stakingKeyHash?: string,
|
||||
certificatePointer?: {
|
||||
blockIndex: number,
|
||||
txIndex: number,
|
||||
certificatePointer: number,
|
||||
},
|
||||
paymentScriptHash?: string,
|
||||
stakingScriptHash?: string,
|
||||
}
|
||||
serializedPath?: string,
|
||||
serializedStakingPath?: string,
|
||||
protocolMagic: number,
|
||||
networkId: number,
|
||||
address: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: number,
|
||||
path: Array<number>, // hardened path
|
||||
stakingPath?: Array<number>, // hardened path
|
||||
stakingKeyHash?: string,
|
||||
certificatePointer?: {
|
||||
blockIndex: number,
|
||||
txIndex: number,
|
||||
certificatePointer: number,
|
||||
},
|
||||
paymentScriptHash?: string,
|
||||
stakingScriptHash?: string,
|
||||
}
|
||||
serializedPath?: string,
|
||||
serializedStakingPath?: string,
|
||||
protocolMagic: number,
|
||||
networkId: number,
|
||||
address: string,
|
||||
},
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: number,
|
||||
path: Array<number>, // hardened path
|
||||
stakingPath?: Array<number>, // hardened path
|
||||
stakingKeyHash?: string,
|
||||
certificatePointer?: {
|
||||
blockIndex: number,
|
||||
txIndex: number,
|
||||
certificatePointer: number,
|
||||
},
|
||||
paymentScriptHash?: string,
|
||||
stakingScriptHash?: string,
|
||||
}
|
||||
serializedPath?: string,
|
||||
serializedStakingPath?: string,
|
||||
protocolMagic: number,
|
||||
networkId: number,
|
||||
address: string,
|
||||
},
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: number,
|
||||
path: Array<number>, // hardened path
|
||||
stakingPath?: Array<number>, // hardened path
|
||||
stakingKeyHash?: string,
|
||||
certificatePointer?: {
|
||||
blockIndex: number,
|
||||
txIndex: number,
|
||||
certificatePointer: number,
|
||||
},
|
||||
paymentScriptHash?: string,
|
||||
stakingScriptHash?: string,
|
||||
}
|
||||
serializedPath?: string,
|
||||
serializedStakingPath?: string,
|
||||
protocolMagic: number,
|
||||
networkId: number,
|
||||
address: string,
|
||||
},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,127 +0,0 @@
|
||||
## Cardano: get native script hash
|
||||
|
||||
Display native script components on Trezor, display the calculated native script hash and return the hash to the caller.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cardanoGetNativeScriptHash(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[CardanoGetNativeScriptHash type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
- `script` — _required_ `CardanoNativeScript` see description below.
|
||||
- `displayFormat` — _required_ `CardanoNativeScriptHashDisplayFormat` enum.
|
||||
- `derivationType` — _optional_ `CardanoDerivationType` enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
|
||||
|
||||
#### CardanoNativeScript
|
||||
|
||||
[CardanoNativeScript type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
- `type` - _required_ `CardanoNativeScriptType`/`number`.
|
||||
- `scripts` — _optional_ `Array` of nested `CardanoNativeScript`s.
|
||||
- `keyHash` — _optional_ `string` hex string of key hash. Used for `CardanoScriptType.PUB_KEY`.
|
||||
- `keyPath` - _optional_ `string | Array<number>` minimum length is `3`. Used for `CardanoScriptType.PUB_KEY`.
|
||||
- `requiredSignaturesCount` - _optional_ `string` used for `CardanoScriptType.N_OF_K`.
|
||||
- `invalidBefore` - _optional_ `string` used for `CardanoScriptType.INVALID_BEFORE`.
|
||||
- `invalidHereafter` - _optional_ `string` used for `CardanoScriptType.INVALID_HEREAFTER`.
|
||||
|
||||
### Example
|
||||
|
||||
Get native script hash of a simple PUB_KEY script:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetNativeScriptHash({
|
||||
script: {
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyHash: 'c4b9265645fde9536c0795adbcc5291767a0c61fd62448341d7e0386',
|
||||
},
|
||||
displayFormat: CardanoNativeScriptHashDisplayFormat.HIDE,
|
||||
});
|
||||
```
|
||||
|
||||
Get native script hash of a nested script:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetAddress({
|
||||
script: {
|
||||
type: CardanoNativeScriptType.ALL,
|
||||
scripts: [
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyHash: 'c4b9265645fde9536c0795adbcc5291767a0c61fd62448341d7e0386',
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyPath: "m/1854'/1815'/0'/0/0",
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.ANY,
|
||||
scripts: [
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyPath: "m/1854'/1815'/0'/0/0",
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyHash: '0241f2d196f52a92fbd2183d03b370c30b6960cfdeae364ffabac889',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.N_OF_K,
|
||||
requiredSignaturesCount: 2,
|
||||
scripts: [
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyPath: "m/1854'/1815'/0'/0/0",
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyHash: '0241f2d196f52a92fbd2183d03b370c30b6960cfdeae364ffabac889',
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.PUB_KEY,
|
||||
keyHash: 'cecb1d427c4ae436d28cc0f8ae9bb37501a5b77bcc64cd1693e9ae20',
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.INVALID_BEFORE,
|
||||
invalidBefore: '100',
|
||||
},
|
||||
{
|
||||
type: CardanoNativeScriptType.INVALID_HEREAFTER,
|
||||
invalidHereafter: '200',
|
||||
},
|
||||
],
|
||||
},
|
||||
displayFormat: CardanoNativeScriptHashDisplayFormat.HIDE,
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[CardanoNativeScriptHash type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
scriptHash: 'b12ac304f89f4cd4d23f59a2b90d2b2697f7540b8f470d6aa05851b5',
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,89 +0,0 @@
|
||||
## Cardano: get public key
|
||||
|
||||
Retrieves [BIP32-Ed25519](https://cardanolaunch.com/assets/Ed25519_BIP.pdf) extended public derived by given [BIP32-Ed25519](https://cardanolaunch.com/assets/Ed25519_BIP.pdf) path.
|
||||
User is presented with a description of the requested key and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cardanoGetPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[CardanoGetPublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
#### Exporting single public key
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if publick key will be displayed on device. Default is set to `true`
|
||||
- `derivationType` — _optional_ `CardanoDerivationType` enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
|
||||
- `suppressBackupWarning` - _optional_ `boolean` By default, this method will emit an event to show a warning if the wallet does not have a backup. This option suppresses the message.
|
||||
|
||||
#### Exporting bundle of publick keys
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
### Example
|
||||
|
||||
Display public key of first cardano account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetPublicKey({
|
||||
path: "m/44'/1815'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of cardano public keys without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoGetPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/44'/1815'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/1815'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/1815'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[CardanoPublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
publicKey: string,
|
||||
node: HDPubNode,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with a bundle of public keys
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string, node: HDPubNode }, // account 1
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string, node: HDPubNode}, // account 2
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string, node: HDPubNode } // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,610 +0,0 @@
|
||||
## Cardano: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cardanoSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[CardanoSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
- `signingMode` - _required_ [CardanoTxSigningMode](#CardanoTxSigningMode)
|
||||
- `inputs` - _required_ `Array` of [CardanoInput](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `outputs` - _required_ `Array` of [CardanoOutput](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `fee` - _required_ `String`
|
||||
- `protocolMagic` - _required_ `Integer` 764824073 for Mainnet, 1 for Preprod Testnet, 2 for Preview Testnet
|
||||
- `networkId` - _required_ `Integer` 1 for Mainnet, 0 for Testnet
|
||||
- `ttl` - _optional_ `String`
|
||||
- `validityIntervalStart` - _optional_ `String`
|
||||
- `certificates` - _optional_ `Array` of [CardanoCertificate](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `withdrawals` - _optional_ `Array` of [CardanoWithdrawal](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `auxiliaryData` - _optional_ [CardanoAuxiliaryData](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `mint` - _optional_ [CardanoMint](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `scriptDataHash` - _optional_ `String`
|
||||
- `collateralInputs` - _optional_ `Array` of [CardanoCollateralInput](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `requiredSigners` - _optional_ `Array` of [CardanoRequiredSigner](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `collateralReturn` - _optional_ [CardanoOutput](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `totalCollateral` - _optional_ `String`
|
||||
- `referenceInputs` - _optional_ `Array` of [CardanoReferenceInput](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
- `additionalWitnessRequests` - _optional_ `Array` of `string | Array<number>` (paths). Used for multi-sig and token minting witness requests as those can not be determined from the transaction parameters.
|
||||
- `metadata` - _removed_ - use `auxiliaryData` instead
|
||||
- `derivationType` — _optional_ `CardanoDerivationType` enum. Determines used derivation type. Default is set to ICARUS_TREZOR=2.
|
||||
- `includeNetworkId` — _optional_ `Boolean`. Determines whether `networkId` should be explicitly serialized into the transaction body. Default is `false`.
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
- `tagCborSets` - _optional_ `boolean` determines if CBOR arrays intended to be sets will be encoded with tag 258. Default is set to `false`
|
||||
|
||||
### CardanoTxSigningMode
|
||||
|
||||
#### `ORDINARY_TRANSACTION`
|
||||
|
||||
Represents an ordinary user transaction transferring funds, delegating stake or withdrawing rewards. The transaction will be witnessed by keys derived from paths included in the `inputs`, `certificates` and `withdrawals`. Additionally, if token minting is present, transaction will also be witnessed by keys derived from paths included in `additionalWitnessRequests`.
|
||||
|
||||
The transaction
|
||||
|
||||
- _should_ have valid `path` property on all `inputs`
|
||||
- _must not_ contain a pool registration certificate
|
||||
- _must not_ contain `collateralInputs`, `collateralReturn`, `totalCollateral` and `referenceInputs`
|
||||
- _must_ contain paths as stake credentials in certificates and withdrawals (no key hashes or script hashes)
|
||||
- _may_ contain only 1852 and 1855 paths
|
||||
- _must not_ contain 1855 witness requests when transaction is not minting/burning tokens
|
||||
|
||||
#### `POOL_REGISTRATION_AS_OWNER`
|
||||
|
||||
Represents pool registration from the perspective of pool owner.
|
||||
|
||||
The transaction
|
||||
|
||||
- _must_ have `path` undefined on all `inputs` (i.e., we are not witnessing any UTxO)
|
||||
- _must_ have single Pool registration certificate
|
||||
- _must_ have single owner given by path on that certificate
|
||||
- _must not_ contain withdrawals
|
||||
- _must not_ contain token minting
|
||||
- _must not_ contain `collateralInputs`, `requiredSigners`, `collateralReturn`, `totalCollateral` and `referenceInputs`
|
||||
- _must_ contain only staking witness requests
|
||||
|
||||
These restrictions are in place due to a possibility of maliciously signing _another_ part of the transaction with the pool owner path as we are not displaying device-owned paths on the device screen.
|
||||
|
||||
#### `MULTISIG_TRANSACTION`
|
||||
|
||||
Represents a multi-sig transaction using native scripts. The transaction will only be signed by keys derived from paths included in `additionalWitnessRequests`.
|
||||
|
||||
The transaction
|
||||
|
||||
- _must_ have `path` undefined on all `inputs`
|
||||
- _must not_ contain output addresses given by parameters
|
||||
- _must not_ contain a pool registration certificate
|
||||
- _must not_ contain `collateralInputs`, `collateralReturn`, `totalCollateral` and `referenceInputs`
|
||||
- _must_ contain script hash stake credentials in certificates and withdrawals (no paths or key hashes)
|
||||
- _may_ contain only 1854 and 1855 witness requests
|
||||
- _must not_ contain 1855 witness requests when transaction is not minting/burning tokens
|
||||
|
||||
#### `PLUTUS_TRANSACTION`
|
||||
|
||||
Represents a transactions containing Plutus script evaluation. The transaction will be witnessed by keys derived from paths included in the `inputs`, `certificates`, `withdrawals`, `collateralInputs`, `requiredSigners` and `additionalWitnessRequests`.
|
||||
|
||||
The transaction
|
||||
|
||||
- _should_ contain `scriptDataHash` and `collateralInputs`
|
||||
- _must not_ contain a pool registration certificate
|
||||
- _may_ contain only 1852, 1854 and 1855 required signers
|
||||
- _may_ contain only 1852, 1854 and 1855 witness requests
|
||||
|
||||
Note: `requiredSigners` are meant for Plutus transactions (from the blockchain point of view), but some applications utilize them for their own purposes, so we allow them in all signing modes (except for pool registration as owner).
|
||||
|
||||
### Stake pool registration certificate specifics
|
||||
|
||||
Trezor supports signing of stake pool registration certificates as a pool owner. The transaction may contain external inputs (e.g. belonging to the pool operator) and Trezor is not able to verify whether they are actually external or not, so if we allowed signing the transaction with a spending key, there is the risk of losing funds from an input that the user did not intend to spend from. Moreover there is the risk of inadvertedly signing a withdrawal in the transaction if there's any. To mitigate those risks, we introduced special validation rules for stake pool registration transactions which are validated on Trezor as well. The validation rules are the following:
|
||||
|
||||
1. The transaction must not contain any other certificates, not even another stake pool registration
|
||||
1. The transaction must not contain any withdrawals
|
||||
1. The transaction inputs must all be external, i.e. path must be either undefined or null
|
||||
1. Exactly one owner should be passed as a staking path and the rest of owners should be passed as bech32-encoded reward addresses
|
||||
|
||||
### CIP-36 vote key registration (Catalyst and other)
|
||||
|
||||
Trezor supports signing transactions with auxiliary data containing a vote key registration. Vote key registrations used to follow [CIP-15](https://cips.cardano.org/cips/cip15/), which has been superseded by [CIP-36](https://cips.cardano.org/cips/cip36/). Currently, Trezor supports both CIP-15 and CIP-36 formats, the intended standard can be specified in the `format` field (with CIP-15 being the default). They differ in the following:
|
||||
|
||||
- CIP-36 allows delegating the voting power to several vote public keys with different voting power ([CardanoCVoteRegistrationDelegation](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)) as an alternative to providing only a single vote public key. Note that Trezor Firmware supports at most 32 delegations in a single registration.
|
||||
- CIP-36 registrations contain the [votingPurpose](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts) field. The value 0 is intended for Catalyst voting and the value 1 is intended for other purposes. If no value is provided, Trezor serializes 0 by default (if the CIP-36 format is used).
|
||||
|
||||
Trezor does not support the 1694 derivation paths at the moment.
|
||||
|
||||
The payment address to receive rewards can be provided either as a `paymentAddress` string or as a `paymentAddressParameters` object. For the smoothest user experience, we recommend providing `paymentAddressParameters` of a BASE address owned by the device.
|
||||
|
||||
### Transaction examples
|
||||
|
||||
#### Ordinary transaction
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoSignTransaction({
|
||||
signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION,
|
||||
inputs: [
|
||||
{
|
||||
path: "m/44'/1815'/0'/0/1",
|
||||
prev_hash: '1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address: 'Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2',
|
||||
amount: '3003112',
|
||||
},
|
||||
{
|
||||
addressParameters: {
|
||||
addressType: CardanoAddressType.BASE,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
stakingPath: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
amount: '7120787',
|
||||
},
|
||||
{
|
||||
format: CardanoTxOutputSerializationFormat.ARRAY_LEGACY,
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '2000000',
|
||||
tokenBundle: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
amount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
address: 'addr1w9rhu54nz94k9l5v6d9rzfs47h7dv7xffcwkekuxcx3evnqpvuxu0',
|
||||
amount: '1',
|
||||
datumHash: '3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
},
|
||||
{
|
||||
format: CardanoTxOutputSerializationFormat.MAP_BABBAGE,
|
||||
address: 'addr1w9rhu54nz94k9l5v6d9rzfs47h7dv7xffcwkekuxcx3evnqpvuxu0',
|
||||
amount: '1',
|
||||
inlineDatum:
|
||||
'3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
referenceScript:
|
||||
'3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b73b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
},
|
||||
],
|
||||
fee: '42',
|
||||
ttl: '10',
|
||||
validityIntervalStart: '20',
|
||||
certificates: [
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_REGISTRATION,
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DEREGISTRATION,
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DELEGATION,
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
pool: 'f61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb4973',
|
||||
},
|
||||
],
|
||||
withdrawals: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
amount: '1000',
|
||||
},
|
||||
],
|
||||
auxiliaryData: {
|
||||
hash: 'ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a',
|
||||
},
|
||||
scriptDataHash: 'd593fd793c377ac50a3169bb8378ffc257c944da31aa8f355dfa5a4f6ff89e02',
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
includeNetworkId: false,
|
||||
});
|
||||
```
|
||||
|
||||
#### Stake pool registration
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoSignTransaction({
|
||||
signingMode: CardanoTxSigningMode.POOL_REGISTRATION_AS_OWNER,
|
||||
inputs: [
|
||||
{
|
||||
// notice no path is provided here
|
||||
prev_hash: '3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
outputs: {
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '1000000',
|
||||
},
|
||||
fee: '300000',
|
||||
ttl: '500000000',
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
includeNetworkId: false,
|
||||
certificates: [
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_POOL_REGISTRATION,
|
||||
poolParameters: {
|
||||
poolId: 'f61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb4973',
|
||||
vrfKeyHash: '198890ad6c92e80fbdab554dda02da9fb49d001bbd96181f3e07f7a6ab0d0640',
|
||||
pledge: '500000000', // amount in lovelace
|
||||
cost: '340000000', // amount in lovelace
|
||||
margin: {
|
||||
// numerator/denominator should be <= 1 which is translated then to a percentage
|
||||
numerator: '1',
|
||||
denominator: '2',
|
||||
},
|
||||
rewardAccount: 'stake1uya87zwnmax0v6nnn8ptqkl6ydx4522kpsc3l3wmf3yswygwx45el', // bech32-encoded stake pool reward account
|
||||
owners: [
|
||||
{
|
||||
stakingKeyPath: "m/1852'/1815'/0'/2/0", // this is the path to the owner's key that will be signing the tx on Trezor
|
||||
},
|
||||
{
|
||||
stakingKeyHash: '3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c490711', // other owner
|
||||
},
|
||||
],
|
||||
relays: [
|
||||
{
|
||||
type: CardanoPoolRelayType.SINGLE_HOST_IP,
|
||||
ipv4Address: '192.168.0.1',
|
||||
ipv6Address: '2001:0db8:85a3:0000:0000:8a2e:0370:7334', // ipv6 address in full form
|
||||
port: 1234,
|
||||
},
|
||||
{
|
||||
type: CardanoPoolRelayType.SINGLE_HOST_IP,
|
||||
ipv6Address: '2001:0db8:85a3:0000:0000:8a2e:0370:7334',
|
||||
port: 1234,
|
||||
},
|
||||
{
|
||||
type: CardanoPoolRelayType.SINGLE_HOST_IP,
|
||||
ipv4Address: '192.168.0.1',
|
||||
port: 1234,
|
||||
},
|
||||
{
|
||||
type: CardanoPoolRelayType.SINGLE_HOST_NAME,
|
||||
hostName: 'www.test.test',
|
||||
port: 1234,
|
||||
},
|
||||
{
|
||||
type: CardanoPoolRelayType.MULTIPLE_HOST_NAME,
|
||||
hostName: 'www.test2.test', // max 64 characters long
|
||||
},
|
||||
],
|
||||
metadata: {
|
||||
url: 'https://www.test.test', // max 64 characters long
|
||||
hash: '914c57c1f12bbf4a82b12d977d4f274674856a11ed4b9b95bd70f5d41c5064a6',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
#### CIP-36 vote key registration
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoSignTransaction({
|
||||
signingMode: CardanoTxSigningMode.ORDINARY_TRANSACTION,
|
||||
inputs: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
prev_hash: '3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '3003112',
|
||||
},
|
||||
],
|
||||
fee: '42',
|
||||
ttl: '10',
|
||||
auxiliaryData: {
|
||||
cVoteRegistrationParameters: {
|
||||
stakingPath: "m/1852'/1815'/0'/2/0",
|
||||
paymentAddressParameters: {
|
||||
addressType: CardanoAddressType.BASE,
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
stakingPath: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
nonce: '22634813',
|
||||
format: CardanoCVoteRegistrationFormat.CIP36,
|
||||
delegations: [
|
||||
{
|
||||
votePublicKey:
|
||||
'1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
weight: 1,
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
includeNetworkId: false,
|
||||
});
|
||||
```
|
||||
|
||||
#### Multisig transaction
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoSignTransaction({
|
||||
signingMode: CardanoTxSigningMode.MULTISIG_TRANSACTION,
|
||||
inputs: [
|
||||
{
|
||||
prev_hash: '1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address: 'Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2',
|
||||
amount: '3003112',
|
||||
},
|
||||
{
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '2000000',
|
||||
tokenBundle: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
amount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
fee: '42',
|
||||
ttl: '10',
|
||||
validityIntervalStart: '20',
|
||||
certificates: [
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_REGISTRATION,
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DEREGISTRATION,
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DELEGATION,
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
pool: 'f61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb4973',
|
||||
},
|
||||
],
|
||||
withdrawals: [
|
||||
{
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
amount: '1000',
|
||||
},
|
||||
],
|
||||
auxiliaryData: {
|
||||
hash: 'ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a',
|
||||
},
|
||||
mint: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
mintAmount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
additionalWitnessRequests: ["m/1854'/1815'/0'/0/0", "m/1855'/1815'/0'"],
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
includeNetworkId: false,
|
||||
});
|
||||
```
|
||||
|
||||
#### Plutus transaction
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cardanoSignTransaction({
|
||||
signingMode: CardanoTxSigningMode.PLUTUS_TRANSACTION,
|
||||
inputs: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
prev_hash: '1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
prev_index: 0,
|
||||
},
|
||||
{
|
||||
prev_hash: '3b40265111d8bb3c3c608d95b3a0bf83461ace32d79336579a1939b3aad1c0b7',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address: 'Ae2tdPwUPEZCanmBz5g2GEwFqKTKpNJcGYPKfDxoNeKZ8bRHr8366kseiK2',
|
||||
amount: '3003112',
|
||||
},
|
||||
{
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '2000000',
|
||||
tokenBundle: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
amount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
fee: '42',
|
||||
ttl: '10',
|
||||
validityIntervalStart: '20',
|
||||
certificates: [
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_REGISTRATION,
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DEREGISTRATION,
|
||||
keyHash: '3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c490711',
|
||||
},
|
||||
{
|
||||
type: CardanoCertificateType.STAKE_DELEGATION,
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
pool: 'f61c42cbf7c8c53af3f520508212ad3e72f674f957fe23ff0acb4973',
|
||||
},
|
||||
],
|
||||
withdrawals: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/2/0",
|
||||
amount: '1000',
|
||||
},
|
||||
{
|
||||
keyHash: '3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c490711',
|
||||
amount: '1000',
|
||||
},
|
||||
{
|
||||
scriptHash: '29fb5fd4aa8cadd6705acc8263cee0fc62edca5ac38db593fec2f9fd',
|
||||
amount: '1000',
|
||||
},
|
||||
],
|
||||
auxiliaryData: {
|
||||
hash: 'ea4c91860dd5ec5449f8f985d227946ff39086b17f10b5afb93d12ee87050b6a',
|
||||
},
|
||||
mint: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
mintAmount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
scriptDataHash: 'd593fd793c377ac50a3169bb8378ffc257c944da31aa8f355dfa5a4f6ff89e02',
|
||||
collateralInputs: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
prev_hash: '1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
collateralReturn: {
|
||||
format: CardanoTxOutputSerializationFormat.ARRAY_LEGACY,
|
||||
address:
|
||||
'addr1q84sh2j72ux0l03fxndjnhctdg7hcppsaejafsa84vh7lwgmcs5wgus8qt4atk45lvt4xfxpjtwfhdmvchdf2m3u3hlsd5tq5r',
|
||||
amount: '1000',
|
||||
tokenBundle: [
|
||||
{
|
||||
policyId: '95a292ffee938be03e9bae5657982a74e9014eb4960108c9e23a5b39',
|
||||
tokenAmounts: [
|
||||
{
|
||||
assetNameBytes: '74652474436f696e',
|
||||
amount: '7878754',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
totalCollateral: '1000',
|
||||
referenceInputs: [
|
||||
{
|
||||
path: "m/1852'/1815'/0'/0/0",
|
||||
prev_hash: '1af8fa0b754ff99253d983894e63a2b09cbb56c833ba18c3384210163f63dcfc',
|
||||
prev_index: 0,
|
||||
},
|
||||
],
|
||||
requiredSigners: [
|
||||
{
|
||||
keyPath: "m/1852'/1815'/0'/0/1",
|
||||
},
|
||||
{
|
||||
keyHash: '3a7f09d3df4cf66a7399c2b05bfa234d5a29560c311fc5db4c490711',
|
||||
},
|
||||
],
|
||||
additionalWitnessRequests: ["m/1852'/1815'/0'/0/2", "m/1854'/1815'/0'/0/0", "m/1855'/1815'/0'"],
|
||||
protocolMagic: 764824073,
|
||||
networkId: 1,
|
||||
includeNetworkId: false,
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Since transaction streaming has been introduced to the Cardano implementation on Trezor because of memory constraints, Trezor no longer returns the whole serialized transaction as a result of the `CardanoSignTransaction` call. Instead the transaction hash, transaction witnesses and auxiliary data supplement are returned and the serialized transaction needs to be assembled by the client.
|
||||
|
||||
[CardanoSignedTxData type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cardano/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
hash: string,
|
||||
witnesses: CardanoSignedTxWitness[],
|
||||
auxiliaryDataSupplement?: CardanoAuxiliaryDataSupplement,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Example:
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
hash: "73e09bdebf98a9e0f17f86a2d11e0f14f4f8dae77cdf26ff1678e821f20c8db6",
|
||||
witnesses: [
|
||||
{
|
||||
type: CardanoTxWitnessType.BYRON_WITNESS,
|
||||
pubKey: '89053545a6c254b0d9b1464e48d2b5fcf91d4e25c128afb1fcfc61d0843338ea',
|
||||
signature:
|
||||
'da07ac5246e3f20ebd1276476a4ae34a019dd4b264ffc22eea3c28cb0f1a6bb1c7764adeecf56bcb0bc6196fd1dbe080f3a7ef5b49f56980fe5b2881a4fdfa00',
|
||||
chainCode:
|
||||
'26308151516f3b0e02bb1638142747863c520273ce9bd3e5cd91e1d46fe2a635',
|
||||
},
|
||||
{
|
||||
type: CardanoTxWitnessType.SHELLEY_WITNESS,
|
||||
pubKey: '5d010cf16fdeff40955633d6c565f3844a288a24967cf6b76acbeb271b4f13c1',
|
||||
signature:
|
||||
'622f22d03bc9651ddc5eb2f5dc709ac4240a64d2b78c70355dd62106543c407d56e8134c4df7884ba67c8a1b5c706fc021df5c4d0ff37385c30572e73c727d00',
|
||||
chainCode: null,
|
||||
},
|
||||
],
|
||||
auxiliaryDataSupplement: {
|
||||
type: 1,
|
||||
auxiliaryDataHash:
|
||||
'a943e9166f1bb6d767b175384d3bd7d23645170df36fc1861fbf344135d8e120',
|
||||
cVoteRegistrationSignature:
|
||||
'74f27d877bbb4a5fc4f7c56869905c11f70bad0af3de24b23afaa1d024e750930f434ecc4b73e5d1723c2cb8548e8bf6098ac876487b3a6ed0891cb76994d409',
|
||||
},
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,41 +0,0 @@
|
||||
## Change language
|
||||
|
||||
This method initiates language change.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.changeLanguage(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `language` — _required_ `string`. (cs-CZ, de-DE) whatever language variant is available for given model and firmware version
|
||||
- `baseUrl` - _optional_ `string`. where language blob should be downloaded from. Default value is https://data.trezor.io
|
||||
|
||||
or
|
||||
|
||||
- `binary` — _required_ `ArrayBuffer`. directly provide language file
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "Language changed"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,36 +0,0 @@
|
||||
## Change pin
|
||||
|
||||
This method initiates pin change sequence.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.changePin(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `remove` — _optional_ `boolean`
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "PIN enabled" | "PIN removed"
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,36 +0,0 @@
|
||||
## Change wipe code
|
||||
|
||||
This method initiates wipe code change sequence.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.changeWipeCode(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `remove` — _optional_ `boolean`
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: string
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,104 +0,0 @@
|
||||
## Symmetric key-value encryption
|
||||
|
||||
Cipher key value provides symmetric encryption in the Trezor device where the user might be forced to confirm the encryption/decryption on the display. The key for the encryption is constructed from the private key on the BIP address, the key displayed on the device, and the two informations about whether to ask for confirmation. It is constructed in such a way, that different path, key or the confirm information will get a different encryption key and IV. So, you cannot "skip" the confirmation by using different input. IV can be either manually set, or it is computed together with the key.The value must be divisible into 16-byte blocks. The application has to pad the blocks itself and ensure safety; for example, by using PKCS7.
|
||||
|
||||
More information can be found in [SLIP-0011](https://github.com/satoshilabs/slips/blob/master/slip-0011.md).
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.cipherKeyValue(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
Common parameter `useEmptyPassphrase` - is always set to `true` and it will be ignored by this method
|
||||
|
||||
#### Encrypt single value
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `1`. [read more](../path.md)
|
||||
- `key` — _optional_ `string` a message shown on device
|
||||
- `value` — _optional_ `string` hexadecimal value with length a multiple of 16 bytes (32 letters in hexadecimal). Value is what is actually being encrypted.
|
||||
- `askOnEncrypt` - _optional_ `boolean` should user confirm encrypt?
|
||||
- `askOnDecrypt` - _optional_ `boolean` should user confirm decrypt?
|
||||
- `iv` - _optional_ `string` initialization vector - keep unset if you don't know what it means, it will be computed automatically.
|
||||
|
||||
#### Encrypt multiple values
|
||||
|
||||
- `bundle` - `Array` of Objects with `path`, `key`, `value`, `askOnEncrypt`, `askOnDecrypt` fields
|
||||
|
||||
### Example
|
||||
|
||||
Return encrypted value:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cipherKeyValue({
|
||||
path: "m/49'/0'/0'",
|
||||
key: 'This text is displayed on Trezor during encrypt',
|
||||
value: '1c0ffeec0ffeec0ffeec0ffeec0ffee1',
|
||||
encrypt: true,
|
||||
askOnEncrypt: true,
|
||||
askOnDecrypt: true,
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of encrypted values:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.cipherKeyValue({
|
||||
bundle: [
|
||||
{
|
||||
path: "m/49'/0'/0'",
|
||||
key: '1 text on Trezor',
|
||||
value: '1c0ffeec0ffeec0ffeec0ffeec0ffee1',
|
||||
encrypt: true,
|
||||
},
|
||||
{
|
||||
path: "m/49'/0'/1'",
|
||||
key: '2 text on Trezor',
|
||||
value: '1c0ffeec0ffeec0ffeec0ffeec0ffee1',
|
||||
encrypt: false,
|
||||
},
|
||||
{ path: "m/49'/0'/2'", key: '3 text on Trezor', value: '1c0ffeec0ffeec0ffeec0ffeec0ffee1' },
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[CipheredValue type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/cipherKeyValue.ts)
|
||||
|
||||
Result with only one value
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
value: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of values
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ value: string },
|
||||
{ value: string },
|
||||
{ value: string }
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,24 +0,0 @@
|
||||
# Common parameters
|
||||
|
||||
Every call requires an [`Object`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object) with a combination of common and method-specified fields.
|
||||
All common parameters are optional.
|
||||
|
||||
- `device` - _optional_ `Object`
|
||||
- `path` - _required_ `string` call to a direct device. Useful when working with multiple connected devices. This value is emitted by [`TrezorConnectEvent`](../events.md)
|
||||
- `state` - _optional_ `string` sets expected state. This value is emitted by [`TrezorConnectEvent`](../events.md)
|
||||
- `instance` - _optional_ `number` sets an instance of device. Useful when working with one device and multiple passphrases. This value is emitted by [`TrezorConnectEvent`](../events.md)
|
||||
- `useEmptyPassphrase` — _optional_ `boolean` method will not ask for a passphrase. Default is set to `false`
|
||||
- `allowSeedlessDevice` — _optional_ `boolean` allows to use TrezorConnect methods with device with seedless setup. Default is set to `false`
|
||||
- `keepSession` — `optional boolean` Advanced feature. After method return a response device session will NOT! be released. Session should be released after all calls are performed by calling any method with `keepSession` set to false or `undefined`. Useful when you need to do multiple different calls to TrezorConnect API without releasing. Example sequence loop for 10 account should look like:
|
||||
- TrezorConnect.getPublicKey({ device: { path: "web01"}, keepSession: true, ...otherParams }) for first account,
|
||||
- Trezor.getAddress({ device: { path: "web01"}, ...otherParams }) for the same account,
|
||||
- looking up for balance in external blockchain
|
||||
- loop iteration
|
||||
- after last iteration call TrezorConnect.getFeatures({ device: { path: "web01"}, keepSession: false, ...otherParams })
|
||||
- useCardanoDerivation - _optional_ `boolean`. default is set to `true` for all cardano related methods, otherwise it is set to `false`. This parameter determines whether device should derive cardano seed for current session. Derivation of cardano seed takes longer then it does for other coins. A wallet that works with both cardano and other coins might want to set this param to `true` for every call or it must be able to cope with the following scenario:
|
||||
- Connected device is using passhprase
|
||||
- Wallet calls `getPublicKey` with `useCardanoDerivation=false`, passhprase is entered, seed derived
|
||||
- Wallet calls `cardanoGetPublicKey`.
|
||||
- At this moment user will be prompted to enter passhprase again.
|
||||
- `override` - _optional_ `boolean` Interrupt previous call, if any.
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
@@ -1,217 +0,0 @@
|
||||
# Compose transaction
|
||||
|
||||
This method works only for `Bitcoin` and `Bitcoin-like` coins.
|
||||
|
||||
Can be used in two different ways and returned result depends on used parameters.
|
||||
|
||||
## Requests a payment to a set of given outputs.
|
||||
|
||||
An automated payment process separated in to following steps:
|
||||
|
||||
1. Account discovery for requested coin is performed and the user is asked for source account selection. [[1]](#additional-notes)
|
||||
1. User is asked for fee level selection.
|
||||
1. Transaction is calculated, change output is added automatically if needed. [[2]](#additional-notes)
|
||||
1. Signing transaction with Trezor, user is asked for confirmation on device.
|
||||
|
||||
Returned response is a signed transaction in hexadecimal format same as in [signTransaction method](signTransaction.md#result).
|
||||
|
||||
## Params:
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `outputs` — _required_ `Array` of output objects described [below](#accepted-output-objects)
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
- `push` — _optional_ `boolean` determines if composed transaction will be broadcasted into blockchain network. Default is set to false.
|
||||
- `sequence` — _optional_ `number` transaction input field used in RBF or locktime transactions
|
||||
|
||||
## Precompose, prepare transaction to be signed by Trezor.
|
||||
|
||||
Skip first two steps of `payment request` (described above) by providing `account` and `feeLevels` params and perform **only** transaction calculation. [[2]](#additional-notes)
|
||||
|
||||
The result, internally called [`PrecomposedTransaction`](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/composeTransaction.ts) is a set of params that can be used in [signTransaction method](signTransaction.md#params) afterwards.
|
||||
|
||||
This useful for the quick preparation of multiple variants for the same transaction using different fee levels or using incomplete data (like missing output addresses just to calculate fee)
|
||||
|
||||
_Device and backend connection is not required for this case since all data are provided._
|
||||
|
||||
## Params:
|
||||
|
||||
- `outputs` — _required_ `Array` of output objects described [below](#accepted-output-objects)
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
- `account` — _required_ `Object` containing essential data, partial result of [getAccountInfo method](getAccountInfo.md#result)
|
||||
- `path` - _required_ `string`
|
||||
- `utxo` - _required_ `Array`
|
||||
- `addresses` - _required_ `string`
|
||||
- `feeLevels` — _required_ `Array` of objects. set of requested variants, partial result of `blockchainEstimateFee method`
|
||||
- `feePerUnit` - _required_ `string` satoshi per transaction byte.
|
||||
- `baseFee` — _optional_ `number` base fee of transaction in satoshi. used in replacement transactions calculation (RBF) and DOGE
|
||||
- `floorBaseFee` — _optional_ `boolean` decide whenever baseFee should be floored to the nearest baseFee unit, prevents from fee overpricing. used in DOGE
|
||||
- `sequence` — _optional_ `number` transaction input field used in RBF or locktime transactions
|
||||
- `skipPermutation` — _optional_ `boolean` do not sort calculated inputs/outputs (usage: RBF transactions)
|
||||
|
||||
## Accepted output objects:
|
||||
|
||||
- `regular output`
|
||||
- `amount` - _required_ `string` value to send in satoshi
|
||||
- `address` - _required_ `string` recipient address
|
||||
- `send-max` - spends all available inputs from account
|
||||
- `type` - _required_ with `send-max` value
|
||||
- `address` - _required_ `string` recipient address
|
||||
- `opreturn` - [read more](https://trezor.io/learn/a/use-op_return-in-trezor-suite-app)
|
||||
- `type` - _required_ with `opreturn` value
|
||||
- `dataHex` - _required_ `hexadecimal string` with arbitrary data
|
||||
- `payment-noaddress` - incomplete output, target address is not known yet. used only in precompose
|
||||
- `type` - _required_ with `payment-noaddress` value
|
||||
- `amount` - _required_ `string` value to send in satoshi
|
||||
- `send-max-noaddress` - incomplete output, target address is not known yet. used only in precompose
|
||||
- `type` - _required_ with `send-max-noaddress` value
|
||||
|
||||
## Examples
|
||||
|
||||
### Payment example
|
||||
|
||||
Send 0.002 BTC to "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2"
|
||||
|
||||
```javascript
|
||||
TrezorConnect.composeTransaction({
|
||||
outputs: [
|
||||
{ amount: "200000", address: "18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2" }
|
||||
]
|
||||
coin: "btc",
|
||||
push: true
|
||||
});
|
||||
```
|
||||
|
||||
### Payment result
|
||||
|
||||
[SignedTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/composeTransaction.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signatures: Array<string>, // signer signatures
|
||||
serializedTx: string, // serialized transaction
|
||||
txid?: string, // blockchain transaction id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Precompose example
|
||||
|
||||
Prepare multiple variants of the same transaction
|
||||
|
||||
```javascript
|
||||
TrezorConnect.composeTransaction({
|
||||
outputs: [{ amount: '200000', address: 'tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu' }],
|
||||
coin: 'btc',
|
||||
account: {
|
||||
path: "m/84'/0'/0'",
|
||||
addresses: {
|
||||
used: [
|
||||
{
|
||||
address: 'bc1qannfxke2tfd4l7vhepehpvt05y83v3qsf6nfkk',
|
||||
path: "m/84'/0'/0'/0/0",
|
||||
transfers: 1,
|
||||
},
|
||||
],
|
||||
unused: [
|
||||
{
|
||||
address: '',
|
||||
path: "m/84'/0'/0'/0/1",
|
||||
transfers: 0,
|
||||
},
|
||||
],
|
||||
change: [
|
||||
{
|
||||
address: 'bc1qktmhrsmsenepnnfst8x6j27l0uqv7ggrg8x38q',
|
||||
path: "m/84'/0'/0'/1/0",
|
||||
transfers: 0,
|
||||
},
|
||||
],
|
||||
},
|
||||
utxo: [
|
||||
{
|
||||
txid: '86a6e02943dcd057cfbe349f2c2274478a3a1be908eb788606a6950e727a0d36',
|
||||
vout: 0,
|
||||
amount: '300000',
|
||||
blockHeight: 590093,
|
||||
address: 'bc1qannfxke2tfd4l7vhepehpvt05y83v3qsf6nfkk',
|
||||
path: "m/84'/0'/0'/0/0",
|
||||
confirmations: 100,
|
||||
},
|
||||
],
|
||||
},
|
||||
feeLevels: [{ feePerUnit: '1' }, { feePerUnit: '5' }, { feePerUnit: '30' }],
|
||||
});
|
||||
```
|
||||
|
||||
### Precompose result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{
|
||||
type: 'final',
|
||||
totalSpent: '200167',
|
||||
fee: '167',
|
||||
feePerByte: '1',
|
||||
bytes: 167,
|
||||
inputs: [
|
||||
{
|
||||
address_n: [84 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 0, 0],
|
||||
amount: "300000",
|
||||
prev_hash: "86a6e02943dcd057cfbe349f2c2274478a3a1be908eb788606a6950e727a0d36",
|
||||
prev_index: 0,
|
||||
script_type: "SPENDWITNESS",
|
||||
}
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address_n: [84 | 0x80000000, 1 | 0x80000000, 0 | 0x80000000, 1, 0],
|
||||
amount: "99833",
|
||||
script_type: "PAYTOWITNESS",
|
||||
},
|
||||
{
|
||||
address: 'tb1q9l0rk0gkgn73d0gc57qn3t3cwvucaj3h8wtrlu',
|
||||
amount: '200000',
|
||||
script_type: 'PAYTOADDRESS',
|
||||
}
|
||||
],
|
||||
outputsPermutation: [1, 0],
|
||||
},
|
||||
{
|
||||
type: 'final',
|
||||
totalSpent: '200835',
|
||||
fee: '835',
|
||||
feePerByte: '5',
|
||||
bytes: 167,
|
||||
inputs: [{ ... }],
|
||||
outputs: [{ ... }],
|
||||
outputsPermutation: [],
|
||||
},
|
||||
{
|
||||
type: 'error',
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
For more examples see
|
||||
|
||||
### Additional notes
|
||||
|
||||
- [1] `UI.SELECT_ACCOUNT` and `UI.SELECT_FEE` events are emitted when using `trusted mode`
|
||||
- [2] Account utxo selection, fee and change calculation is performed by [@trezor/utxo-lib](https://github.com/trezor/trezor-suite/tree/develop/packages/utxo-lib/src/compose) module
|
||||
@@ -1,86 +0,0 @@
|
||||
## Eos: get public key
|
||||
|
||||
Display requested public key derived by given [BIP44 path](../path.md) on device and returns it to caller.
|
||||
User is presented with a description of the requested public key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.eosGetPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
### Example
|
||||
|
||||
Displays public key derived from BIP44 path:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.eosGetPublicKey({
|
||||
path: "m/44'/194'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of public keys without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.eosGetPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/44'/194'/0'/0/0", showOnTrezor: false }, // public key 1
|
||||
{ path: "m/44'/194'/0'/0/1", showOnTrezor: false }, // public key 2
|
||||
{ path: "m/44'/194'/0'/0/2", showOnTrezor: false }, // public key 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[EosPublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/eos/index.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
wifPublicKey: string,
|
||||
rawPublicKey: string,
|
||||
path: number[],
|
||||
serializedPath: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of public keys sorted by FIFO
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ wifPublicKey: string, rawPublicKey: string, path: number[], serializedPath: string }, // public key 1
|
||||
{ wifPublicKey: string, rawPublicKey: string, path: number[], serializedPath: string }, // public key 2
|
||||
{ wifPublicKey: string, rawPublicKey: string, path: number[], serializedPath: string } // public key 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,79 +0,0 @@
|
||||
## Eos: sign transaction
|
||||
|
||||
Asks device to sign given transaction using the private key derived by given [BIP44 path](../path.md). User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.eosSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[EosSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/eos/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `transaction` - _required_ `Object` type of [EosSDKTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/eos/index.ts)
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Transfer example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.eosSignTransaction({
|
||||
path: "m/44'/194'/0'/0/0",
|
||||
transaction: {
|
||||
chainId: 'cf057bbfb72640471fd910bcb67639c22df9f92470936cddc1ade0e2f2e7dc4f',
|
||||
header: {
|
||||
expiration: '2019-12-01T12:00:00',
|
||||
refBlockNum: 6439,
|
||||
refBlockPrefix: 2995713264,
|
||||
maxNetUsageWords: 0,
|
||||
maxCpuUsageMs: 0,
|
||||
delaySec: 0,
|
||||
},
|
||||
actions: [
|
||||
{
|
||||
account: 'eosio.token',
|
||||
authorization: [
|
||||
{
|
||||
actor: 'abcdefg12345',
|
||||
permission: 'active',
|
||||
},
|
||||
],
|
||||
name: 'transfer',
|
||||
data: {
|
||||
from: 'abcdefg12345',
|
||||
to: '12345abcdefg',
|
||||
quantity: '1.0000 EOS',
|
||||
memo: 'memo',
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[EosSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signature: string, // hexadecimal string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,116 +0,0 @@
|
||||
## Ethereum: get address
|
||||
|
||||
Display requested address derived by given BIP32 path on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.ethereumGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `address` — _required_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of first ethereum account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumGetAddress({
|
||||
path: "m/44'/60'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of ethereum addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/60'/0'/0/0", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/60'/1'/0/0", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/60'/2'/0/0", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.ethereumGetAddress({
|
||||
path: "m/44'/60'/0'/0/0",
|
||||
address: '0x73d0385F4d8E00C5e6504C6030F47BF6212736A8',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string, // displayed address
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses sorted by FIFO
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 2
|
||||
{ address: string, path: Array<number>, serializedPath: string } // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,50 +0,0 @@
|
||||
## Ethereum: sign message
|
||||
|
||||
Asks device to sign a message using the private key derived by given BIP32 path.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.ethereumSignMessage(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
[EthereumSignMessage type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `message` - _required_ `string` message to sign in plain text
|
||||
- `hex` - _optional_ `boolean` convert message from hex
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumSignMessage({
|
||||
path: "m/44'/60'/0'",
|
||||
message: 'example message',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[MessageSignature type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
signature: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,87 +0,0 @@
|
||||
## Ethereum: Sign transaction
|
||||
|
||||
Asks device to sign given transaction using the private key derived by given BIP32 path. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.ethereumSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[EthereumSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `transaction` - _required_ `Object` type of [`EthereumTransactionEIP1559`](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)`|`[`EthereumSignTransaction`](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts) "0x" prefix for each field is optional
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Examples
|
||||
|
||||
#### EIP1559 ([after The London Upgrade](https://ethereum.org/en/developers/docs/gas/#post-london))
|
||||
|
||||
> :warning: **Supported firmware versions** T1B1 v1.10.4 and T2T1 v2.4.2
|
||||
|
||||
If both parameters `maxFeePerGas` and `maxPriorityFeePerGas` are defined, transaction will be signed as the new type introduced in [EIP1559](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1559.md).
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumSignTransaction({
|
||||
path: "m/44'/60'/0'",
|
||||
transaction: {
|
||||
to: '0xd0d6d6c5fe4a677d343cc433536bb717bae167dd',
|
||||
value: '0xf4240',
|
||||
data: '0xa',
|
||||
chainId: 1,
|
||||
nonce: '0x0',
|
||||
maxFeePerGas: '0x14',
|
||||
maxPriorityFeePerGas: '0x0',
|
||||
gasLimit: '0x14',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
#### Legacy
|
||||
|
||||
For T1B1 and T2T1 with firmware older than 2.4.2 (but supported newer firmware versions too).
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumSignTransaction({
|
||||
path: "m/44'/60'/0'",
|
||||
transaction: {
|
||||
to: '0x7314e0f1c0e28474bdb6be3e2c3e0453255188f8',
|
||||
value: '0xf4240',
|
||||
data: '0x01',
|
||||
chainId: 1,
|
||||
nonce: '0x0',
|
||||
gasLimit: '0x5208',
|
||||
gasPrice: '0xbebc200',
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[EthereumSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
v: string, // hexadecimal string with "0x" prefix
|
||||
r: string, // hexadecimal string with "0x" prefix
|
||||
s: string, // hexadecimal string with "0x" prefix
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,117 +0,0 @@
|
||||
## Ethereum: Sign Typed Data
|
||||
|
||||
Asks device to sign an [EIP-712](https://eips.ethereum.org/EIPS/eip-712) typed data message using the private key derived by given BIP32 path.
|
||||
|
||||
User is asked to confirm all signing details on T2T1.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.ethereumSignTypedData(params);
|
||||
```
|
||||
|
||||
> :warning: **Supported only by T2T1 with Firmware 2.4.3 or higher!**
|
||||
> :warning: **Blind signing is supported only on T1B1 with Firmware 1.10.5 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[EthereumSignTypedData type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
> :warning: **Domain-only signing (`data.primaryType` = `"EIP712Domain"`) is supported only on T2T1 with Firmware 2.4.4 or higher!**
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `data` - _required_ `Object` type of [`EthereumSignTypedDataMessage`](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)`. A JSON Schema definition can be found in the [EIP-712 spec](https://eips.ethereum.org/EIPS/eip-712).
|
||||
- `metamask_v4_compat` - _required_ `boolean` set to `true` for compatibility with [MetaMask's signTypedData_v4](https://docs.metamask.io/guide/signing-data.html#sign-typed-data-v4).
|
||||
|
||||
#### Blind signing (optional addition for T1B1 compatibility)
|
||||
|
||||
T1B1 firmware currently does not support constructing EIP-712
|
||||
hashes.
|
||||
|
||||
However, it supports signing pre-constructed hashes.
|
||||
|
||||
EIP-712 hashes can be constructed with the plugin function at
|
||||
[@trezor/connetct-plugin-ethereum](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-plugin-ethereum).
|
||||
|
||||
You may also wish to contruct your own hashes using a different library.
|
||||
|
||||
[EthereumSignTypedHash type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
> :warning: **Domain-only signing (empty `message_hash`) is supported only on T1B1 with Firmware 1.10.6 or higher!**
|
||||
|
||||
- `domain_separator_hash` - _required_ `string` hex-encoded 32-byte hash of the EIP-712 domain.
|
||||
- `message_hash` - _optional_ `string` hex-encoded 32-byte hash of the EIP-712 message.
|
||||
This is optional for the domain-only hashes where `primaryType` is `EIP712Domain`.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
const eip712Data = {
|
||||
types: {
|
||||
EIP712Domain: [
|
||||
{
|
||||
name: 'name',
|
||||
type: 'string',
|
||||
},
|
||||
],
|
||||
Message: [
|
||||
{
|
||||
name: 'Best Wallet',
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
name: 'Number',
|
||||
type: 'uint64',
|
||||
},
|
||||
],
|
||||
},
|
||||
primaryType: 'Message',
|
||||
domain: {
|
||||
name: 'example.trezor.io',
|
||||
},
|
||||
message: {
|
||||
'Best Wallet': 'Trezor Model T',
|
||||
// be careful with JavaScript numbers: MAX_SAFE_INTEGER is quite low
|
||||
Number: `${2n ** 55n}`,
|
||||
},
|
||||
};
|
||||
|
||||
// This functionality is separate from @trezor/connect, as it requires @metamask/eth-sig-utils,
|
||||
// which is a large JavaScript dependency
|
||||
const transformTypedDataPlugin = require('@trezor/connect-plugin-ethereum');
|
||||
const { domain_separator_hash, message_hash } = transformTypedDataPlugin(eip712Data, true);
|
||||
|
||||
TrezorConnect.ethereumSignTypedData({
|
||||
path: "m/44'/60'/0'",
|
||||
data: eip712Data,
|
||||
metamask_v4_compat: true,
|
||||
// These are optional, but required for T1B1 compatibility
|
||||
domain_separator_hash,
|
||||
message_hash,
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[EthereumMessageSignature type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
signature: string, // hexadecimal string with "0x" prefix
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,54 +0,0 @@
|
||||
## Ethereum: verify message
|
||||
|
||||
Asks device to
|
||||
verify a message using the signer address and signature.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.ethereumVerifyMessage(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[EthereumVerifyMessage type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ethereum/index.ts)
|
||||
|
||||
- `address` - _required_ `string` signer address. "0x" prefix is optional
|
||||
- `message` - _required_ `string` signed message in plain text
|
||||
- `hex` - _optional_ `boolean` convert message from hex
|
||||
- `signature` - _required_ `string` signature in hexadecimal format. "0x" prefix is optional
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.ethereumVerifyMessage({
|
||||
address: '0xdA0b608bdb1a4A154325C854607c68950b4F1a34',
|
||||
message: 'Example message',
|
||||
signature:
|
||||
'11dc86c631ef5d9388c5e245501d571b864af1a717cbbb3ca1f6dacbf330742957242aa52b36bbe7bb46dce6ff0ead0548cc5a5ce76d0aaed166fd40cb3fc6e51c',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "Message verified"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,87 +0,0 @@
|
||||
## firmwareUpdate
|
||||
|
||||
Installs a new firmware
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.firmwareUpdate(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### You either provide binary
|
||||
|
||||
- `binary` — _required_ `bytes`
|
||||
|
||||
#### Or params
|
||||
|
||||
- `version`: _required_ `number[]` version of firmware to be installed
|
||||
- `btcOnly`: `boolean` should install bitcoin only or regular firmware
|
||||
- `baseUrl`: `string` url to look for releases.json
|
||||
- `intermediary`: `boolean` should install intermediary firmware
|
||||
|
||||
### Notable firmware ranges
|
||||
|
||||
It is not possible to install directly whatever version of a new firmware in all cases. Some specific firmware
|
||||
versions might be installed only on device which already run a version which is not lower then x.y.z.
|
||||
These rules are generally expressed by `bootloader_version` and `min_bootloader_version` in [releases.json document](https://data.trezor.io/firmware/t1b1/releases.json)
|
||||
|
||||
Here is a list of notable firmware ranges. `1.11.1` was the latest firmware at the time of writing this docs.
|
||||
|
||||
Firmware versions `latest` - `1.7.1`
|
||||
|
||||
- can be installed only on devices with firmware 1.6.2 and higher
|
||||
|
||||
Firmware versions `1.6.3` - `1.0.0`
|
||||
|
||||
- can not be updated to the latest firmware using single `TrezorConnect.firmwareUpdate` call
|
||||
- if device has one of these firmwares, `TrezorConnect.firmwareUpdate` should be called with `intermediary: true` which would install a special intermediary firmware first and automatically switch device into bootloader mode making it ready to accept another firmware update
|
||||
- alternatively, you may call `TrezorConnect.firmwareUpdate` with `version: '1.6.3'` and after succeeding retry this call with `version: '1.11.1'`
|
||||
|
||||
Bootloader versions `latest` - `1.8.0`
|
||||
|
||||
- the first 256 byte (containing old firmware header) must sliced off the when installing a new firmware on bootloader versions in this range.
|
||||
- TrezorConnect takes care of this automatically
|
||||
|
||||
Firmwares `1.7.2` - `1.6.2`
|
||||
|
||||
- These can be updated to the latest firmware in one `TrezorConnect.firmwareUpdate` call (this is apparent from bullets above).
|
||||
- Old firmware headers MUST NOT be sliced off when installing new firmwares onto these versions as these versions have lower bootloader than 1.8.0.
|
||||
- For the purpose of computing firmware hash of a newly installed firmware, we **MUST** slice off old firmware headers.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.firmwareUpdate({
|
||||
version: '2.5.1',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[FirmwareUpdateResponse type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/firmwareUpdate.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
// challenge used to compute expected firmware hash. only with firmware 1.11.1 and 2.5.1 or higher
|
||||
challenge: string,
|
||||
// expected firmware hash computed from the installed binary. only with firmware 1.11.1 and 2.5.1 or higher
|
||||
hash: string,
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,55 +0,0 @@
|
||||
## Get account descriptor
|
||||
|
||||
Gets an descriptor of specified account.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getAccountDescriptor(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
- `derivationType` — _optional_ `CardanoDerivationType` enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
|
||||
- `suppressBackupWarning` - `boolean` By default, this method will emit an event to show a warning if the wallet does not have a backup. This option suppresses the message.
|
||||
|
||||
### Example
|
||||
|
||||
Get descriptor of first bitcoin account
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAccountDescriptor({
|
||||
path: "m/49'/0'/0'",
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[AccountInfo type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/account.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
id: number, // account id
|
||||
path: string, // serialized path
|
||||
descriptor: string, // account public key
|
||||
legacyXpub?: string, // (optional) account public key in legacy format (only for segwit and segwit native accounts)
|
||||
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,146 +0,0 @@
|
||||
## Get account info
|
||||
|
||||
Gets an info of specified account.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getAccountInfo(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Using path
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
|
||||
#### Using public key
|
||||
|
||||
- `descriptor` — _required_ `string` public key of account
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
|
||||
#### Using discovery
|
||||
|
||||
BIP-0044 account discovery is performed and user is presented with a list of accounts. Result is returned after account selection.
|
||||
|
||||
- `coin` — _required_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
|
||||
### Other optional params
|
||||
|
||||
params are forwarded to [BlockBook backend](https://github.com/trezor/blockbook/blob/master/docs/api.md#api-v2) using `@trezor/blockchain-link` package
|
||||
|
||||
- `details` — specifies level of details returned by request
|
||||
|
||||
- `basic` (default) return only account balances, without any derived addresses or transaction history
|
||||
- `tokens` - response with derived addresses (Bitcoin-like accounts) and ERC20 tokens (Ethereum-like accounts), subject of `tokens` param
|
||||
- `tokenBalances` - same as `tokens` with balances, subject of `tokens` param
|
||||
- `txs` - `tokenBalances` + complete account transaction history
|
||||
|
||||
- `tokens` — specifies which tokens (xpub addresses) are returned by the request (default nonzero)
|
||||
|
||||
- `nonzero` - (Default) return only addresses with nonzero balance
|
||||
- `used` - return addresses with at least one transaction
|
||||
- `derived` - return all derived addresses
|
||||
|
||||
- `page` — `number` transaction history page index, subject of `details: txs`
|
||||
- `pageSize` — `number` transaction history page size, subject of `details: txs`
|
||||
- `from` — `number` transaction history from block filter, subject of `details: txs`
|
||||
- `to` — `number` transaction history to block filter, subject of `details: txs`
|
||||
- `gap` — `number` address derivation gap size, subject of `details: tokens`
|
||||
- `contractFilter` — `string` Ethereum-like accounts only: get ERC20 token info and balance
|
||||
- `marker` — `{ ledger: number, seq: number }` XRP accounts only, transaction history page marker
|
||||
- `defaultAccountType` — `'normal' | 'segwit' | 'legacy'` Bitcoin-like accounts only: specify which account group is displayed as default in popup, subject of `Using discovery`
|
||||
- `suppressBackupWarning` - `boolean` By default, this method will emit an event to show a warning if the wallet does not have a backup. This option suppresses the message.
|
||||
|
||||
### Example
|
||||
|
||||
Get info about first bitcoin account
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAccountInfo({
|
||||
path: "m/49'/0'/0'",
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
Get info about account using public key (device is not used)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAccountInfo({
|
||||
descriptor:
|
||||
'xpub6CVKsQYXc9awxgV1tWbG4foDvdcnieK2JkbpPEBKB5WwAPKBZ1mstLbKVB4ov7QzxzjaxNK6EfmNY5Jsk2cG26EVcEkycGW4tchT2dyUhrx',
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
Get info about account using BIP-0044 account discovery
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAccountInfo({
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[AccountInfo type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/account.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
id: number, // account id
|
||||
path: string, // serialized path
|
||||
descriptor: string, // account public key
|
||||
legacyXpub?: string, // (optional) account public key in legacy format (only for segwit and segwit native accounts)
|
||||
balance: string, // account balance (confirmed transactions only)
|
||||
availableBalance: string, // account balance (including unconfirmed transactions)
|
||||
addresses: {
|
||||
// subject of details:tokens param
|
||||
unused: Array<AccountAddress>, // unused addresses
|
||||
used: Array<AccountAddress>, // used addresses
|
||||
change: Array<AccountAddress>, // change addresses (internal)
|
||||
}, // list of derived addresses grouped by purpose (Bitcoin-like accounts)
|
||||
history: Array<{
|
||||
total: number,
|
||||
unconfirmed: number,
|
||||
transactions?: Array<AccountTransaction>, // subject of details:txs param
|
||||
}> // account history object
|
||||
utxo?: Array<AccountUtxo>, // account utxos (Bitcoin-like accounts), subject of details:tokens param
|
||||
tokens?: Array<TokenInfo>, // account ERC20 tokens (Ethereum-like accounts), subject of details:tokens param
|
||||
misc?: {
|
||||
// Ethereum-like accounts only
|
||||
nonce: string,
|
||||
contractInfo?: TokenInfo, // subject of contractFilter param
|
||||
// XRP accounts only
|
||||
sequence?: number,
|
||||
reserve?: string,
|
||||
},
|
||||
page?: {
|
||||
// subject of details:txs param
|
||||
index: number, // current page index
|
||||
size: number, // current page size
|
||||
total: number, // total pages count
|
||||
},
|
||||
marker?: {
|
||||
// XRP accounts only
|
||||
// subject of details:txs param
|
||||
ledger: number,
|
||||
seq: number,
|
||||
}
|
||||
|
||||
} //
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,122 +0,0 @@
|
||||
## Get address
|
||||
|
||||
Display requested address derived by given BIP32 path on device and returns it to caller. User is asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `coin` - _optional_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used. If `coin` is not set API will try to get network definition from `path`.
|
||||
- `crossChain` — _optional_ `boolean` Advanced feature. Use it only if you are know what you are doing. Allows to generate address between chains. For example Bitcoin path on Litecoin network will display cross chain address in Litecoin format.
|
||||
- `multisig` - _optional_ [MultisigRedeemScriptType](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts), redeem script information (multisig addresses only)
|
||||
- `scriptType` - _optional_ [InputScriptType](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts), address script type
|
||||
- `unlockPath` - _optional_ [PROTO.UnlockPath](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts), the result of [TrezorConnect.unlockPath](./unlockPath.md) method.
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path`, `showOnTrezor`, `coin` and `crossChain` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display third address of first bitcoin account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAddress({
|
||||
path: "m/49'/0'/0'/0/2",
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of addresses from first bitcoin account without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getAddress({
|
||||
bundle: [
|
||||
{ path: "m/49'/0'/0'/0/0", showOnTrezor: false }, // address 1
|
||||
{ path: "m/49'/0'/0'/0/1", showOnTrezor: false }, // address 2
|
||||
{ path: "m/49'/0'/0'/0/2", showOnTrezor: false }, // address 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.getAddress({
|
||||
path: "m/49'/0'/0'/0/0",
|
||||
address: '3L6TyTisPBmrDAj6RoKmDzNnj4eQi54gD2',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string, // displayed address
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // address 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // address 2
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // address 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,68 +0,0 @@
|
||||
## Get Coin Info
|
||||
|
||||
Returns information about a specified coin from the [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getCoinInfo(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `coin` — _required_ `string` coin symbol (btc, eth, bch, ...).
|
||||
|
||||
### Example
|
||||
|
||||
Get coin info for Bitcoin.
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getCoinInfo({
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Result for Bitcoin
|
||||
|
||||
[BitcoinNetworkInfo](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/coinInfo.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
blockchainLink: Object { type: "blockbook", url: (5) […] },
|
||||
blocks: 10,
|
||||
blocktime: 10,
|
||||
cashAddrPrefix: null,
|
||||
curveName: "secp256k1",
|
||||
decimals: 8,
|
||||
defaultFees: Object { Economy: 70, High: 200, Low: 10, … },
|
||||
dustLimit: 546,
|
||||
forceBip143: false,
|
||||
forkid: null,
|
||||
hashGenesisBlock: "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f",
|
||||
isBitcoin: true,
|
||||
label: "Bitcoin",
|
||||
maxAddressLength: 34,
|
||||
maxFee: 2000,
|
||||
maxFeeSatoshiKb: 2000000,
|
||||
minAddressLength: 27,
|
||||
minFee: 1,
|
||||
minFeeSatoshiKb: 1000,
|
||||
name: "Bitcoin",
|
||||
network: Object { messagePrefix: "Bitcoin Signed Message:\n", bech32: "bc", pubKeyHash: 0, … },
|
||||
segwit: true,
|
||||
shortcut: "BTC",
|
||||
slip44: 0,
|
||||
support: Object { connect: true, trezor1: "1.5.2", trezor2: "2.0.5", … },
|
||||
type: "bitcoin",
|
||||
xPubMagic: 76067358,
|
||||
xPubMagicSegwit: 77429938,
|
||||
xPubMagicSegwitNative: 78792518,
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,41 +0,0 @@
|
||||
## Get current fiat rates
|
||||
|
||||
Retrieves current selected exchange rates for selected coin.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.blockchainGetCurrentFiatRates(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
```javascript
|
||||
{
|
||||
currencies: ['currency1','currency2','currency3',...],
|
||||
coin: 'coin'
|
||||
}
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
Return current EUR, USD, BTC exchange rates for ETH:
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.blockchainGetCurrentFiatRates({
|
||||
currencies: ['EUR', 'CZK', 'BTC'],
|
||||
coin: 'ETH',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[GetCurrentFiatRates type](https://github.com/trezor/trezor-suite/blob/develop/packages/blockchain-link/src/types/responses.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
rates: {btc: 0.07461017, eur: 1768.36, usd: 1802.17},
|
||||
ts: 1659962048
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,50 +0,0 @@
|
||||
# Get Device State
|
||||
|
||||
Return information about a specific device. Devices without passphrase enabled return the same per instance.
|
||||
|
||||
[Device state](commonParams.md) can be used in any method (key derivation or TX signing) to enforce the same passphrase on furhter operations.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getDeviceState(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
## Example
|
||||
|
||||
Get the state of a device.
|
||||
|
||||
```javascript
|
||||
const capturedDevice = await TrezorConnect.getDeviceState({
|
||||
device: {
|
||||
instance: 0, // identifier for wallet A
|
||||
// `state: undefined` forces the passphrase prompt even if instance 0 is/was already using "some" passphrase (let say empty). The Trezor forgets the current state, useful when dealing with multiple hidden wallets on one or more devices
|
||||
// `state: "string" verifies state is valid, otherwise "invalid passphrase" error is returned
|
||||
state: undefined,
|
||||
},
|
||||
});
|
||||
|
||||
// Get the public key without prompting for the passphrase again
|
||||
await TrezorConnect.getPublicKey({
|
||||
device: {
|
||||
instance: 0,
|
||||
state: capturedDevice.payload.state, // by using a previously capture state identifier, passphrase will not be re-requested
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[DeviceStateResponse type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/getDeviceState.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
id: 1,
|
||||
success: true,
|
||||
payload: {
|
||||
state: "string"
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,43 +0,0 @@
|
||||
## getFirmwareHash
|
||||
|
||||
> :note: **Supported only by firmwares 1.11.1 and 2.5.1 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `challenge` — _required_ `string` a random 32-byte challenge which is return form successful [TrezorConnect.firmwareUpdate](./firmwareUpdate) call
|
||||
|
||||
### Example
|
||||
|
||||
Get hash of firmware installed in trezor device. It can be used to verify authenticity of firmware binaries intended to be installed.
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getFirmwareHash({
|
||||
challenge: '430d1ca5302edb40ac605e0ba61dc50928779336fdd02b688a833564c178307c',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[FirmwareHash type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
hash: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,89 +0,0 @@
|
||||
## Bitcoin: get Ownership identifier
|
||||
|
||||
Export SLIP-0019 ownership identifier. [Read more](https://github.com/satoshilabs/slips/blob/master/slip-0019.md#ownership-identifier)
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getOwnershipId(params);
|
||||
```
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.4.4 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single id
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `coin` - _optional_ `string`
|
||||
> Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file.
|
||||
> Coin `shortcut`, `name` or `label` can be used.
|
||||
- `scriptType` — _optional_ `InputScriptType`
|
||||
- `multisig` — _optional_ `MultisigRedeemScriptType`
|
||||
|
||||
#### Exporting bundle of ids
|
||||
|
||||
- `bundle` - `Array` of Objects with fields listed above.
|
||||
|
||||
### Example
|
||||
|
||||
Display id of the first bitcoin address:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getOwnershipId({
|
||||
path: "m/86'/0'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of ids:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getOwnershipId({
|
||||
bundle: [
|
||||
{ path: "m/86'/0'/0'/0/0" }, // taproot
|
||||
{ path: "m/84'/0'/0'/0/0" }, // bech32
|
||||
{ path: "m/49'/0'/0'/0/0" }, // segwit
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[OwnershipId type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/getOwnershipId.ts)
|
||||
|
||||
Result with single id:
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
ownership_id: string,
|
||||
path: number[],
|
||||
serializedPath: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of ids sorted by FIFO
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ ownership_id: string, path: number[], serializedPath: string }, // taproot
|
||||
{ ownership_id: string, path: number[], serializedPath: string }, // bech32
|
||||
{ ownership_id: string, path: number[], serializedPath: string } // segwit
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,94 +0,0 @@
|
||||
## Bitcoin: get Ownership proof
|
||||
|
||||
Export SLIP-0019 ownership proof. [Read more](https://github.com/satoshilabs/slips/blob/master/slip-0019.md#proof-usage)
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getOwnershipProof(params);
|
||||
```
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.4.4 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single proof
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `coin` - _optional_ `string`
|
||||
> Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file.
|
||||
> Coin `shortcut`, `name` or `label` can be used.
|
||||
- `scriptType` — _optional_ `InputScriptType`
|
||||
- `userConfirmation` — _optional_ `boolean`
|
||||
- `ownershipIds` — _optional_ `Array<string>`
|
||||
- `commitmentData` — _optional_ `string`
|
||||
- `multisig` — _optional_ `MultisigRedeemScriptType`
|
||||
- `preauthorized` — _optional_ `boolean` [read more](./authorizeCoinjoin.md)
|
||||
|
||||
#### Exporting bundle of proofs
|
||||
|
||||
- `bundle` - `Array` of Objects with fields listed above.
|
||||
|
||||
### Example
|
||||
|
||||
Display ownership proof of the first bitcoin address:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getOwnershipProof({
|
||||
path: "m/86'/0'/0'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of ownership proofs:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getOwnershipProof({
|
||||
bundle: [
|
||||
{ path: "m/86'/0'/0'/0/0" }, // taproot
|
||||
{ path: "m/84'/0'/0'/0/0" }, // bech32
|
||||
{ path: "m/49'/0'/0'/0/0" }, // segwit
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[OwnershipProof type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/getOwnershipProof.ts)
|
||||
|
||||
Result with single proof:
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
ownership_proof: string,
|
||||
signature: string,
|
||||
path: number[],
|
||||
serializedPath: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of proofs sorted by FIFO
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ ownership_proof: string, signature: string, path: number[], serializedPath: string }, // taproot
|
||||
{ ownership_proof: string, signature: string, path: number[], serializedPath: string }, // bech32
|
||||
{ ownership_proof: string, signature: string, path: number[], serializedPath: string } // segwit
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,99 +0,0 @@
|
||||
## Get public key
|
||||
|
||||
Retrieves BIP32 extended public derived by given BIP32 path.
|
||||
User is presented with a description of the requested key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.getPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single public key
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `1`. [read more](../path.md)
|
||||
- `coin` - _optional_ `string` determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used. If `coin` is not set API will try to get network definition from `path`.
|
||||
- `scriptType` — _optional_ `string` used to distinguish between various address formats (non-segwit, segwit, etc.).
|
||||
- `ignoreXpubMagic` — _optional_ `boolean` ignore SLIP-0132 XPUB magic, use xpub/tpub prefix for all account types.
|
||||
- `ecdsaCurveName` — _optional_ `string` ECDSA curve name to use
|
||||
- `crossChain` — _optional_ `boolean` Advanced feature. Use it only if you are know what you are doing. Allows to generate address between chains. For example Bitcoin path on Litecoin network will display cross chain address in Litecoin format.
|
||||
- `unlockPath` - _optional_ [PROTO.UnlockPath](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts), the result of [TrezorConnect.unlockPath](./unlockPath.md) method.
|
||||
- `suppressBackupWarning` - _optional_ `boolean` By default, this method will emit an event to show a warning if the wallet does not have a backup. This option suppresses the message.
|
||||
|
||||
#### Exporting bundle of public keys
|
||||
|
||||
- `bundle` - `Array` of Objects with `path`, `coin` and `crossChain` fields
|
||||
|
||||
### Example
|
||||
|
||||
Return public key of fifth bitcoin account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getPublicKey({
|
||||
path: "m/49'/0'/4'",
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of public keys for multiple bitcoin accounts:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.getPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/49'/0'/0'" }, // account 1
|
||||
{ path: "m/49'/0'/1'" }, // account 2
|
||||
{ path: "m/49'/0'/2'" }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[HDNodeResponse type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/getPublicKey.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string, // serialized path
|
||||
xpub: string, // xpub in legacy format
|
||||
xpubSegwit?: string, // optional for segwit accounts: xpub in segwit format
|
||||
chainCode: string, // BIP32 serialization format
|
||||
childNum: number, // BIP32 serialization format
|
||||
publicKey: string, // BIP32 serialization format
|
||||
fingerprint: number, // BIP32 serialization format
|
||||
depth: number, // BIP32 serialization format
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
[Read more about BIP32 serialization format](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Serialization_format)
|
||||
|
||||
Result with bundle of public keys
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth }, // account 1
|
||||
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth }, // account 2
|
||||
{ path, serializedPath, xpub, xpubSegwit?, chainCode, childNum, publicKey, fingerprint, depth } // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
3
docs/packages/connect/methods/index.md
Normal file
3
docs/packages/connect/methods/index.md
Normal file
@@ -0,0 +1,3 @@
|
||||
# Connect Methods
|
||||
|
||||
Connect methods documentation has been moved to [Connect Explorer](https://connect.trezor.io/).
|
||||
@@ -1,26 +0,0 @@
|
||||
## Init
|
||||
|
||||
Initiate TrezorConnect
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.init(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[init type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/init.ts)
|
||||
|
||||
- `manifest` - _required_ `Object` of type `[Manifest]`(https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/settings.ts#L3),
|
||||
- `connectSrc` - _optional_ `string`. Set custom src for TrezorConnect iframe.
|
||||
- `debug` - _optional_ `boolean`, default `false`. Prints debug logs.
|
||||
- `transportReconnect` - _optional_ `boolean`, default `true`. If transport dies during lifecycle of application, this field decides whether TrezorConnect tries to reestablish connection with transport layer.
|
||||
- `pendingTransportEvent` - _optional_ `boolean`, default `true`. Postpone emitting TRANSPORT.START event to the moment when connected device becomes available.
|
||||
- `interactionTimeout` - _optional_ `number`, default `600`. Time in seconds after which popup automatically closes.
|
||||
- `lazyLoad` - _optional_ `boolean`, default `false`. Postpone iframe creation until TrezorConnect is called for the first time.
|
||||
- `popup` - _optional_ `boolean`, default `true`. Projects running on trusted domains (trezor.io) are not required to use popup. For other domains this option is ignored.
|
||||
- `transports` — \_optional `'(BridgeTransport' | 'WebUsbTransport | 'NodeUsbTransport')[]'`, Array of transports that should be use. If not provided, TrezorConnect will chose a reasonable
|
||||
default based on your environment.
|
||||
|
||||
### Result
|
||||
|
||||
TrezorConnect.init returns `Promise<void>`
|
||||
@@ -1,118 +0,0 @@
|
||||
## NEM: get address
|
||||
|
||||
Display requested address on device and returns it to caller.
|
||||
User is presented with a description of the requested key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.nemGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `network` — _optional_ `number` `0x68` - Mainnet, `0x96` - Testnet, `0x60` - Mijin. Default is set to `Mainnet`
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path`, `network` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of third nem account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.nemGetAddress({
|
||||
path: "m/44'/43'/2'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of NEM addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.nemGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/43'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/43'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/43'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.nemGetAddress({
|
||||
path: "m/44'/43'/0'",
|
||||
address: 'TDS7OQUHKNYMSC2WPJA6QUTLJIO22S27B4FMU2AJ',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 2
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,105 +0,0 @@
|
||||
## NEM: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.nemSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[NEMSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/nem/index.ts)
|
||||
|
||||
- `path` - _required_ `string | Array<number>`
|
||||
- `transaction` - _required_ `Object` type of [NEMTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/nem/index.ts)
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Example
|
||||
|
||||
Sign simple transaction
|
||||
|
||||
```javascript
|
||||
// common utility for hexlify message
|
||||
function hexlify(str) {
|
||||
var result = '';
|
||||
var padding = '00';
|
||||
for (var i=0, l=str.length; i<l; i++) {
|
||||
var digit = str.charCodeAt(i).toString(16);
|
||||
var padded = (padding+digit).slice(-2);
|
||||
result += padded;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
TrezorConnect.nemSignTransaction(
|
||||
path: "m/44'/1'/0'/0'/0'",
|
||||
transaction: {
|
||||
timeStamp: 74649215,
|
||||
amount: 2000000,
|
||||
fee: 2000000,
|
||||
recipient: "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
type: 257,
|
||||
deadline: 74735615,
|
||||
version: (0x98 << 24),
|
||||
message: {
|
||||
payload: hexlify('test_nem_transaction_transfer'),
|
||||
type: 1,
|
||||
},
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Sign mosaic transaction
|
||||
|
||||
```javascript
|
||||
TrezorConnect.nemSignTransaction(
|
||||
path: "m/44'/1'/0'/0'/0'",
|
||||
transaction: {
|
||||
timeStamp: 76809215,
|
||||
amount: 1000000,
|
||||
fee: 1000000,
|
||||
recipient: "TALICE2GMA34CXHD7XLJQ536NM5UNKQHTORNNT2J",
|
||||
type: 257,
|
||||
deadline: 76895615,
|
||||
version: (0x98 << 24),
|
||||
message: {},
|
||||
mosaics: [
|
||||
{
|
||||
mosaicId: {
|
||||
namespaceId: "nem",
|
||||
name: "xem",
|
||||
},
|
||||
quantity: 1000000,
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[NEMSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
data: string,
|
||||
signature: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,49 +0,0 @@
|
||||
## Push transaction
|
||||
|
||||
Broadcast the transaction to the selected network.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.pushTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[PushTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/pushTransaction.ts)
|
||||
|
||||
- `tx` - _required_ `string` serialized transaction,
|
||||
- `coin` - _required_ `string` Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.pushTransaction({
|
||||
tx: '010000000182488650ef25a58fef6788bd71b8212038d7f2bbe4750bc7bcb44701e85ef6d5000000006b4830450221009a0b7be0d4ed3146ee262b42202841834698bb3ee39c24e7437df208b8b7077102202b79ab1e7736219387dffe8d615bbdba87e11477104b867ef47afed1a5ede7810121023230848585885f63803a0a8aecdd6538792d5c539215c91698e315bf0253b43dffffffff0160cc0500000000001976a914de9b2a8da088824e8fe51debea566617d851537888ac00000000',
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[PushedTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/pushTransaction.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
txid: string, // transaction id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,98 +0,0 @@
|
||||
## Request login
|
||||
|
||||
Challenge-response authentication via Trezor. To protect against replay attacks
|
||||
you should use a server-side generated and randomized `challengeHidden` for every
|
||||
attempt. You can also provide a visual challenge that will be shown on the
|
||||
device.
|
||||
|
||||
Service backend needs to check whether the signature matches the generated
|
||||
`challengeHidden`, provided `challengeVisual` and stored `publicKey` fields.
|
||||
If that is the case, the backend either creates an account (if the `publicKey`
|
||||
identity is seen for the first time) or signs in the user (if the `publicKey`
|
||||
identity is already a known user).
|
||||
|
||||
To understand the full mechanics, please consult the Challenge-Response chapter
|
||||
of
|
||||
[SLIP-0013: Authentication using deterministic hierarchy](https://github.com/satoshilabs/slips/blob/master/slip-0013.md).
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.requestLogin(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
<br>
|
||||
Common parameter `useEmptyPassphrase` - is always set to `true` and it will be ignored by this method
|
||||
|
||||
#### Login using server-side async challenge
|
||||
|
||||
- `callback` — _required_ `function` which will be called from API to fetch `challengeHidden` and `challengeVisual` from server
|
||||
|
||||
#### Login without async challenge
|
||||
|
||||
- `challengeHidden` - _required_ `string` hexadecimal value
|
||||
- `challengeVisual` - _required_ `string` text displayed on Trezor
|
||||
|
||||
### Example
|
||||
|
||||
###### Login using server-side async challenge
|
||||
|
||||
```javascript
|
||||
TrezorConnect.requestLogin({
|
||||
callback: function () {
|
||||
// here should be a request to server to fetch "challengeHidden" and "challengeVisual"
|
||||
return {
|
||||
challengeHidden: '0123456789abcdef',
|
||||
challengeVisual: 'Login to',
|
||||
};
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
###### Login without async challenge
|
||||
|
||||
```javascript
|
||||
TrezorConnect.requestLogin({
|
||||
challengeHidden: '0123456789abcdef',
|
||||
challengeVisual: 'Login to',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Login type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/requestLogin.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
publicKey: string,
|
||||
signature: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Server side examples
|
||||
|
||||
Here is the reference implementation of the server-side signature verification
|
||||
written in various languages:
|
||||
|
||||
- [**C#**](server/server.cs)
|
||||
- [**Javascript**](server/server.js)
|
||||
- [**PHP**](server/server.php)
|
||||
- [**Python**](server/server.py)
|
||||
- [**Ruby**](server/server.rb)
|
||||
- [**Go**](server/server.go)
|
||||
@@ -1,51 +0,0 @@
|
||||
## Reset device
|
||||
|
||||
Perform device setup and generate new seed.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.resetDevice(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `strength` — _optional_ `number` Accepted values are [128|192|256]. Default is set to `256`
|
||||
- `label` — _optional_ `string`
|
||||
- `u2fCounter` — _optional_ `number`. Default value is set to current time stamp in seconds.
|
||||
- `pinProtection` — _optional_ `boolean`
|
||||
- `passphraseProtection` — _optional_ `boolean`
|
||||
- `skipBackup` — _optional_ `boolean`
|
||||
- `noBackup` — _optional_ `boolean` create a seedless device
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.resetDevice({
|
||||
label: 'My fancy Trezor',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Device successfully initialized'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,116 +0,0 @@
|
||||
## Ripple: get address
|
||||
|
||||
Display requested address on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.rippleGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `5`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display first address of second ripple account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.rippleGetAddress({
|
||||
path: "m/44'/144'/1'/0/0",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of ripple addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.rippleGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/144'/0'/0/0", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/144'/1'/0/1", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/144'/2'/0/2", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.rippleGetAddress({
|
||||
path: "m/44'/144'/0'/0/0",
|
||||
address: 'rNaqKtKrMSwpwZSzRckPf7S96DkimjkF4H',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 1, address 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 2, address 2
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 3, address 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,60 +0,0 @@
|
||||
## Ripple: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.rippleSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[RippleSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ripple/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `transaction` - _required_ `Object` type of [RippleTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ripple/index.ts)
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.rippleSignTransaction(
|
||||
path: "m/44'/144'/0'/0/0",
|
||||
transaction: {
|
||||
fee: '100000',
|
||||
flags: 0x80000000,
|
||||
sequence: 25,
|
||||
payment: {
|
||||
amount: '100000000',
|
||||
destination: 'rBKz5MC2iXdoS3XgnNSYmF69K1Yo4NS3Ws'
|
||||
}
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[RippleSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/ripple/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
serializedTx: string,
|
||||
signature: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,39 +0,0 @@
|
||||
## Set busy
|
||||
|
||||
Show a "Do not disconnect" dialog instead of the standard homescreen.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.setBusy(params);
|
||||
```
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.5.3 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `expiry_ms` — _optional_ `number`
|
||||
> The time in milliseconds after which the dialog will automatically disappear. Overrides any previously set expiry. If not set, then the dialog is hidden.
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Success',
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,45 +0,0 @@
|
||||
## Show device tutorial
|
||||
|
||||
Start the on device tutorial.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.showDeviceTutorial(params);
|
||||
```
|
||||
|
||||
> :note: **Not supported on T1B1 and T2T1**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
### Example:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.showDeviceTutorial({
|
||||
device,
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Tutorial shown'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,52 +0,0 @@
|
||||
## Sign message
|
||||
|
||||
Asks device to sign a message using the private key derived by given BIP32 path.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.signMessage(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[SignMessage type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/bitcoin/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `message` - _required_ `string`
|
||||
- `coin` - _optional_ `string` Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used. If `coin` is not set API will try to get network definition from `path`.
|
||||
- `hex` - _optional_ `boolean` convert message from hex
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.signMessage({
|
||||
path: "m/44'/0'/0'",
|
||||
message: 'example message',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[MessageSignature type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string, // signer address
|
||||
signature: string, // signature in base64 format
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,215 +0,0 @@
|
||||
## Sign transaction
|
||||
|
||||
Asks device to sign given
|
||||
inputs and outputs of pre-composed transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.signTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[SignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/bitcoin/index.ts)
|
||||
|
||||
- `coin` - _required_ `string`
|
||||
> Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file.
|
||||
> Coin `shortcut`, `name` or `label` can be used.
|
||||
> See [supported coins](../supported-coins.md)
|
||||
- `inputs` - _required_ `Array` of [PROTO.TxInputType](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts),
|
||||
- `outputs` - _required_ `Array` of [PROTO.TxOutputType](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts),
|
||||
- `paymentRequests` - _optional_ `Array` of [PROTO.TxAckPaymentRequest](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts). See [SLIP-24](https://github.com/satoshilabs/slips/blob/slip24/slip-0024.md)
|
||||
- `refTxs` - _optional_ `Array` of [RefTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/bitcoin/index.ts).
|
||||
> If you don't want to use build-in `blockbook` backend you can optionally provide those data from your own backend transformed to `Trezor` format.
|
||||
> Since Firmware 2.3.0/1.9.0 referenced transactions are required.
|
||||
> Zcash and Komodo refTxs should also contains `expiry`, `version_group_id` and `extra_data` fields.
|
||||
- `locktime` - _optional_ `number`,
|
||||
- `version` - _optional_ `number` transaction version,
|
||||
- `expiry` - _optional_ `number`, only for Decred and Zcash,
|
||||
- `versionGroupId` - _optional_ `number` only for Zcash, nVersionGroupId when overwintered is set,
|
||||
- `overwintered` - _optional_ `boolean` only for Zcash
|
||||
- `timestamp` - _optional_ `number` only for Capricoin, transaction timestamp,
|
||||
- `branchId` - _optional_ `number`, only for Zcash, BRANCH_ID when overwintered is set
|
||||
- `push` - _optional_ `boolean` Broadcast signed transaction to blockchain. Default is set to false
|
||||
- `amountUnit` — _optional_ `PROTO.AmountUnit`
|
||||
> show amounts in BTC, mBTC, uBTC, sat
|
||||
- `unlockPath` - _optional_ [PROTO.UnlockPath](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts), the result of [TrezorConnect.unlockPath](./unlockPath.md) method.
|
||||
- `serialize` - _optional_ `boolean`, default `true` serialize the full transaction, as opposed to only outputting the signatures
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Example
|
||||
|
||||
###### PAYTOADDRESS
|
||||
|
||||
```javascript
|
||||
TrezorConnect.signTransaction({
|
||||
inputs: [
|
||||
{
|
||||
address_n: [
|
||||
(44 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
0,
|
||||
],
|
||||
prev_index: 0,
|
||||
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac',
|
||||
amount: 3431747,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address_n: [
|
||||
(44 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
1,
|
||||
],
|
||||
amount: 3181747,
|
||||
script_type: 'PAYTOADDRESS',
|
||||
},
|
||||
{
|
||||
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
|
||||
amount: 200000,
|
||||
script_type: 'PAYTOADDRESS',
|
||||
},
|
||||
],
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
###### SPENDP2SHWITNESS
|
||||
|
||||
```javascript
|
||||
TrezorConnect.signTransaction({
|
||||
inputs: [
|
||||
{
|
||||
address_n: [
|
||||
(49 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
0,
|
||||
],
|
||||
prev_index: 0,
|
||||
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac',
|
||||
amount: 3431747,
|
||||
script_type: 'SPENDP2SHWITNESS',
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address_n: [
|
||||
(49 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
1,
|
||||
],
|
||||
amount: 3181747,
|
||||
script_type: 'PAYTOP2SHWITNESS',
|
||||
},
|
||||
{
|
||||
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
|
||||
amount: 200000,
|
||||
script_type: 'PAYTOADDRESS',
|
||||
},
|
||||
],
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
###### PAYTOADDRESS with refTxs (transaction data provided from custom backend)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.signTransaction({
|
||||
inputs: [
|
||||
{
|
||||
address_n: [
|
||||
(44 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
0,
|
||||
],
|
||||
prev_index: 0,
|
||||
prev_hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac',
|
||||
amount: 3431747,
|
||||
},
|
||||
],
|
||||
outputs: [
|
||||
{
|
||||
address_n: [
|
||||
(44 | 0x80000000) >>> 0,
|
||||
(0 | 0x80000000) >>> 0,
|
||||
(2 | 0x80000000) >>> 0,
|
||||
1,
|
||||
1,
|
||||
],
|
||||
amount: 3181747,
|
||||
script_type: 'PAYTOADDRESS',
|
||||
},
|
||||
{
|
||||
address: '18WL2iZKmpDYWk1oFavJapdLALxwSjcSk2',
|
||||
amount: 200000,
|
||||
script_type: 'PAYTOADDRESS',
|
||||
},
|
||||
],
|
||||
refTxs: [
|
||||
{
|
||||
hash: 'b035d89d4543ce5713c553d69431698116a822c57c03ddacf3f04b763d1999ac',
|
||||
inputs: [
|
||||
{
|
||||
prev_hash: '448946a44f1ef514601ccf9b22cc3e638c69ea3900b67b87517ea673eb0293dc',
|
||||
prev_index: 0,
|
||||
script_sig:
|
||||
'47304402202872cb8459eed053dcec0f353c7e293611fe77615862bfadb4d35a5d8807a4cf022015057aa0aaf72ab342b5f8939f86f193ad87b539931911a72e77148a1233e022012103f66bbe3c721f119bb4b8a1e6c1832b98f2cf625d9f59242008411dd92aab8d94',
|
||||
sequence: 4294967295,
|
||||
},
|
||||
],
|
||||
bin_outputs: [
|
||||
{
|
||||
amount: 3431747,
|
||||
script_pubkey: '76a91441352a84436847a7b660d5e76518f6ebb718dedc88ac',
|
||||
},
|
||||
{
|
||||
amount: 10000,
|
||||
script_pubkey: '76a9141403b451c79d34e6a7f6e36806683308085467ac88ac',
|
||||
},
|
||||
],
|
||||
lock_time: 0,
|
||||
version: 1,
|
||||
},
|
||||
],
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[SignedTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/bitcoin/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signatures: Array<string>, // Array of signer signatures
|
||||
serializedTx: string, // serialized transaction
|
||||
txid?: string, // broadcasted transaction id
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,101 +0,0 @@
|
||||
## Solana: get address
|
||||
|
||||
Display requested address derived by given [BIP44 path](../path.md) on device and return it to the caller. User is presented with a description of the requested address and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.solanaGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[GetAddress type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `2`. [read more](../path.md)
|
||||
- `address` — _required_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of first Solana account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaGetAddress({
|
||||
path: "m/44'/501'/0'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of Solana addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/501'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/501'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/501'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[SolanaGetAddress type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
address: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with a bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path: Array<number>, serializedPath: string, address: string }, // account 1
|
||||
{ path: Array<number>, serializedPath: string, address: string }, // account 2
|
||||
{ path: Array<number>, serializedPath: string, address: string } // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,85 +0,0 @@
|
||||
## Solana: get public key
|
||||
|
||||
Display requested public key derived by given [BIP44 path](../path.md) on device and return it to the caller. User is presented with a description of the requested public key and asked to confirm the export on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.solanaGetPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[GetPublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
#### Exporting single key
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `2`. [read more](../path.md)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if public key will be displayed on device. Default is set to `true`
|
||||
|
||||
#### Exporting bundle of public keys
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
### Example
|
||||
|
||||
Display public key of first Solana account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaGetPublicKey({
|
||||
path: "m/44'/501'/0'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of Solana public keys without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaGetPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/44'/501'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/501'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/501'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[SolanaPublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
path: Array<number>, // hardended path
|
||||
serializedPath: string,
|
||||
publicKey: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with a bundle of public keys
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string }, // account 1
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string }, // account 2
|
||||
{ path: Array<number>, serializedPath: string, publicKey: string } // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,78 +0,0 @@
|
||||
## Solana: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.solanaSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[SolanaSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `2`. [read more](../path.md)
|
||||
- `serializedTx` — _required_ `string`
|
||||
- `additionalInfo` - _optional_ [SolanaTxAdditionalInfo](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts#L18)
|
||||
- `tokenAccountsInfos` - _optional_ `Array` of [SolanaTxTokenAccountInfo](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts#L11)
|
||||
|
||||
### SolanaTxAdditionalInfo
|
||||
|
||||
The parameter is currently used only for sending `tokenAccountsInfos` to Trezor. `tokenAccountsInfos` are used when transferring tokens to associated token accounts. Using `tokenAccountsInfos` you can provide Trezor information about the recipient's base (system) account of the associated token account and Trezor can then safely display the base account address to the user instead of displaying the token account address which most users don't even know about.
|
||||
|
||||
_Displaying base address only works for transactions which transfer tokens or which create a token account and transfer tokens to that account._
|
||||
|
||||
### Examples
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaSignTransaction({
|
||||
path: "m/44'/501'/0'/0'",
|
||||
serializedTx:
|
||||
'0200030500d1699dcb1811b50bb0055f13044463128242e37a463b52f6c97a1f6eef88ad8c72b471e11674bdcd1e5f85421be42097d5d9c8642172ab73ccf6ff003a43f3000000000000000000000000000000000000000000000000000000000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000006a7d517192c5c51218cc94c3d4af17f58daee089ba1fd44e3dbd98a000000001aea57c9906a7cad656ff61b3893abda63f4b6b210c939855e7ab6e54049213d02020200013400000000002d310100000000e80300000000000006a1d8179137542a983437bdfe2a7ab2557f535c8a78722b68a49dc00000000003020104740000000000d1699dcb1811b50bb0055f13044463128242e37a463b52f6c97a1f6eef88ad00d1699dcb1811b50bb0055f13044463128242e37a463b52f6c97a1f6eef88ad000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
|
||||
});
|
||||
```
|
||||
|
||||
If you try the following request with the `all all ...` mnemonic you should see `BVRFH6vt5bNXub6WnnFRgaHFTcbkjBrf7x1troU1izGg` as the recipient although the tokens are really transferred to `J5rhFGUkeoHVnCvMyqWq1XPjfU1G1hsTh9tTQtST2out` (the associated token account of `BVRFH6vt5bNXub6WnnFRgaHFTcbkjBrf7x1troU1izGg`).
|
||||
|
||||
```javascript
|
||||
TrezorConnect.solanaSignTransaction({
|
||||
path: "m/44'/501'/0'/0'",
|
||||
serializedTx:
|
||||
'0100040700d1699dcb1811b50bb0055f13044463128242e37a463b52f6c97a1f6eef88ad9bdc8c11af6a471f7373e52c917aac6304c71796b97b47350d46cf4c54bae9d9fdd530a73d5e74613b17aaeb9346f9fc3c5fd6a7ad126b269e3e73454e2a0b1b000000000000000000000000000000000000000000000000000000000000000081432588d91c8e02d613baa94e05994e78467cf5a8821d8f4c2e373e8b9b56ef8c97258f4e2489f1bb3d1029148e0d830b5a1399daff1084048e7bd8dbe9f85906ddf6e1d765a193d9cbe146ceeb79ac1cb485ed5f5b37913a8cf5857eff00a91aea57c9906a7cad656ff61b3893abda63f4b6b210c939855e7ab6e54049213d020506000201040306000604010402000a0c0b0000000000000009',
|
||||
additionalInfo: {
|
||||
tokenAccountsInfos: [
|
||||
{
|
||||
baseAddress: 'BVRFH6vt5bNXub6WnnFRgaHFTcbkjBrf7x1troU1izGg',
|
||||
tokenProgram: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
|
||||
tokenMint: '9hayiPmEobVfiTbw5R91StWeQzw9EJGfswLH5o33UDAW',
|
||||
tokenAccount: 'J5rhFGUkeoHVnCvMyqWq1XPjfU1G1hsTh9tTQtST2out',
|
||||
},
|
||||
],
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[SolanaSignedTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/solana/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signature: string
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,116 +0,0 @@
|
||||
## Stellar: get address
|
||||
|
||||
Display requested address on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.stellarGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of first stellar account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.stellarGetAddress({
|
||||
path: "m/44'/148'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of stellar addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.stellarGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/148'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/148'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/148'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.stellarGetAddress({
|
||||
path: "m/44'/148'/0'/0/0",
|
||||
address: 'GAXSFOOGF4ELO5HT5PTN23T5XE6D5QWL3YBHSVQ2HWOFEJNYYMRJENBV',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 2
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,89 +0,0 @@
|
||||
## Stellar: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.stellarSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[StellarSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/stellar/index.ts)
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `networkPassphrase` - _required_ `string` network passphrase
|
||||
- `transaction` - _required_ `Object` type of [StellarTransaction](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/stellar/index.ts)
|
||||
|
||||
### Stellar SDK compatibility
|
||||
|
||||
`@stellar/stellar-sdk` is not a part of `trezor-connect` repository.
|
||||
To transform `StellarSDK.Transaction` object into `TrezorConnect.StellarTransaction`, install [@trezor/connect-plugin-stellar](https://github.com/trezor/trezor-suite/tree/develop/packages/connect-plugin-stellar) into your project.
|
||||
|
||||
```javascript
|
||||
import * as StellarSDK from '@stellar/stellar-sdk';
|
||||
import transformTrezorTransaction from '<path-to-plugin>/index.js';
|
||||
|
||||
const tx = new StellarSdk.TransactionBuilder(...);
|
||||
...
|
||||
tx.build();
|
||||
|
||||
const params = transformTrezorTransaction(tx);
|
||||
const result = TrezorConnect.stellarSignTransaction(params);
|
||||
|
||||
if (result.success) {
|
||||
tx.addSignature('account-public-key', result.payload.signature);
|
||||
}
|
||||
```
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.stellarSignTransaction(
|
||||
path: "m/44'/148'/0'",
|
||||
networkPassphrase: "Test SDF Network ; September 2015",
|
||||
transaction: {
|
||||
source: "GAXSFOOGF4ELO5HT5PTN23T5XE6D5QWL3YBHSVQ2HWOFEJNYYMRJENBV",
|
||||
fee: 100,
|
||||
sequence: 4294967296,
|
||||
memo: {
|
||||
type: 0,
|
||||
},
|
||||
operations: [
|
||||
{
|
||||
type: "payment",
|
||||
source: "GAXSFOOGF4ELO5HT5PTN23T5XE6D5QWL3YBHSVQ2HWOFEJNYYMRJENBV",
|
||||
destination: "GAXSFOOGF4ELO5HT5PTN23T5XE6D5QWL3YBHSVQ2HWOFEJNYYMRJENBV",
|
||||
amount: "10000"
|
||||
}
|
||||
]
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[StellarSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/stellar/index.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
publicKey: string,
|
||||
signature: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,116 +0,0 @@
|
||||
## Tezos: get address
|
||||
|
||||
Display requested address on device and returns it to caller. User is presented with a description of the requested key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.tezosGetAddress(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single address
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `address` — _optional_ `string` address for validation (read `Handle button request` section below)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if address will be displayed on device. Default is set to `true`
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of addresses
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
#### Handle button request
|
||||
|
||||
Since trezor-connect@6.0.4 there is a possibility to handle `UI.ADDRESS_VALIDATION` event which will be triggered once the address is displayed on the device.
|
||||
You can handle this event and display custom UI inside of your application.
|
||||
|
||||
If certain conditions are fulfilled popup will not be used at all:
|
||||
|
||||
- the user gave permissions to communicate with Trezor
|
||||
- device is authenticated by pin/passphrase
|
||||
- application has `TrezorConnect.on(UI.ADDRESS_VALIDATION, () => {});` listener registered
|
||||
- parameter `address` is set
|
||||
- parameter `showOnTrezor` is set to `true` (or not set at all)
|
||||
- application is requesting ONLY ONE(!) address
|
||||
|
||||
### Example
|
||||
|
||||
Display address of first tezos account:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosGetAddress({
|
||||
path: "m/44'/1729'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Return a bundle of tezos addresses without displaying them on device:
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosGetAddress({
|
||||
bundle: [
|
||||
{ path: "m/44'/1729'/0'", showOnTrezor: false }, // account 1
|
||||
{ path: "m/44'/1729'/1'", showOnTrezor: false }, // account 2
|
||||
{ path: "m/44'/1729'/2'", showOnTrezor: false }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
Validate address using custom UI inside of your application:
|
||||
|
||||
```javascript
|
||||
import TrezorConnect, { UI } from '@trezor/connect';
|
||||
|
||||
TrezorConnect.on(UI.ADDRESS_VALIDATION, data => {
|
||||
console.log('Handle button request', data.address, data.serializedPath);
|
||||
// here you can display custom UI inside of your app
|
||||
});
|
||||
|
||||
const result = await TrezorConnect.tezosGetAddress({
|
||||
path: "m/44'/1729'/0'",
|
||||
address: 'tz1Kef7BSg6fo75jk37WkKRYSnJDs69KVqt9',
|
||||
});
|
||||
// dont forget to hide your custom UI after you get the result!
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[Address type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one address
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address: string,
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of addresses
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 1
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 2
|
||||
{ address: string, path: Array<number>, serializedPath: string }, // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,85 +0,0 @@
|
||||
## Tezos: get public key
|
||||
|
||||
Display requested public key on device and returns it to caller.
|
||||
User is presented with a description of the requested public key and asked to confirm the export.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.tezosGetPublicKey(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
#### Exporting single public key
|
||||
|
||||
- `path` — _required_ `string | Array<number>` minimum length is `3`. [read more](../path.md)
|
||||
- `showOnTrezor` — _optional_ `boolean` determines if public key will be displayed on device.
|
||||
- `chunkify` — _optional_ `boolean` determines if address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
#### Exporting bundle of public keys
|
||||
|
||||
- `bundle` - `Array` of Objects with `path` and `showOnTrezor` fields
|
||||
|
||||
### Example
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosGetPublicKey({
|
||||
path: "m/49'/1729'/0'",
|
||||
});
|
||||
```
|
||||
|
||||
Result with bundle of public keys
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosGetPublicKey({
|
||||
bundle: [
|
||||
{ path: "m/49'/1729'/0'" }, // account 1
|
||||
{ path: "m/49'/1729'/1'" }, // account 2
|
||||
{ path: "m/49'/1729'/2'" }, // account 3
|
||||
],
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[PublicKey type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/params.ts)
|
||||
|
||||
Result with only one public key
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
publicKey: string,
|
||||
path: Array<number>,
|
||||
serializedPath: string,
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Result with bundle of public keys
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: [
|
||||
{ path, serializedPath, publicKey }, // account 1
|
||||
{ path, serializedPath, publicKey }, // account 2
|
||||
{ path, serializedPath, publicKey }, // account 3
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,235 +0,0 @@
|
||||
## Tezos: Sign transaction
|
||||
|
||||
Asks device to sign given transaction. User is asked to confirm all transaction
|
||||
details on Trezor.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.tezosSignTransaction(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[TezosSignTransaction type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/tezos/index.ts)
|
||||
|
||||
- `path` - _required_ `string | Array<number>`
|
||||
- `branch` - _required_ `string`
|
||||
- `operation` - _required_ `Object` type of [TezosOperation](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/tezos/index.ts)
|
||||
- `chunkify` — _optional_ `boolean` determines if recipient address will be displayed in chunks of 4 characters. Default is set to `false`
|
||||
|
||||
### Example
|
||||
|
||||
Sign transaction operation
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/10'",
|
||||
branch: 'BLGUkzwvguFu8ei8eLW3KgCbdtrMmv1UCqMvUpHHTGq1UPxypHS',
|
||||
operation: {
|
||||
transaction: {
|
||||
source: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
destination: 'tz1Kef7BSg6fo75jk37WkKRYSnJDs69KVqt9',
|
||||
counter: 297,
|
||||
amount: 200000,
|
||||
fee: 10000,
|
||||
gas_limit: 11000,
|
||||
storage_limit: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign the first transaction of the account with reveal operation
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/10'",
|
||||
branch: 'BLGUkzwvguFu8ei8eLW3KgCbdtrMmv1UCqMvUpHHTGq1UPxypHS',
|
||||
operation: {
|
||||
reveal: {
|
||||
source: 'tz1ekQapZCX4AXxTJhJZhroDKDYLHDHegvm1',
|
||||
counter: 575424,
|
||||
fee: 10000,
|
||||
gas_limit: 20000,
|
||||
storage_limit: 0,
|
||||
public_key: 'edpkuTPqWjcApwyD3VdJhviKM5C13zGk8c4m87crgFarQboF3Mp56f',
|
||||
},
|
||||
transaction: {
|
||||
source: 'tz1ekQapZCX4AXxTJhJZhroDKDYLHDHegvm1',
|
||||
destination: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
counter: 575425,
|
||||
amount: 100000,
|
||||
fee: 10000,
|
||||
gas_limit: 20000,
|
||||
storage_limit: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign origination operation
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BLHRTdZ5vUKSDbkp5vcG1m6ZTST4SRiHWUhGodysLTbvACwi77d',
|
||||
operation: {
|
||||
origination: {
|
||||
source: 'tz1ckrgqGGGBt4jGDmwFhtXc1LNpZJUnA9F2',
|
||||
manager_pubkey: 'tz1ckrgqGGGBt4jGDmwFhtXc1LNpZJUnA9F2',
|
||||
delegate: 'tz1boot1pK9h2BVGXdyvfQSv8kd1LQM6H889',
|
||||
balance: 100000000,
|
||||
fee: 10000,
|
||||
counter: 20450,
|
||||
gas_limit: 10100,
|
||||
storage_limit: 277,
|
||||
script: '0000001c02000000170500036805010368050202000000080316053d036d03420000000a010000000568656c6c6f',
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign delegation operation
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BMXAKyvzcH1sGQMqpvqXsZGskYU4GuY9Y14c9g3LcNzMRtfLzFa',
|
||||
operation: {
|
||||
delegation: {
|
||||
source: 'tz1Kef7BSg6fo75jk37WkKRYSnJDs69KVqt9',
|
||||
delegate: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
fee: 20000,
|
||||
counter: 564565,
|
||||
gas_limit: 20000,
|
||||
storage_limit: 0,
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign delegation from a KT account (smart contract with `manager.tz` script)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BMdPMLXNyMTDp4vR6g7y8mWPk7KZbjoXH3gyWD1Tze43UE3BaPm',
|
||||
operation: {
|
||||
transaction: {
|
||||
source: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
destination: 'KT1SBj7e8ZhV2VvJtoc73dNRDLRJ9P6VjuVN',
|
||||
counter: 292,
|
||||
amount: 0,
|
||||
fee: 10000,
|
||||
gas_limit: 36283,
|
||||
storage_limit: 0,
|
||||
parameters_manager: {
|
||||
set_delegate: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign cancel delegation from a KT account (smart contract with `manager.tz` script)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BL6oaFJeEjtYxafJqEL8hXvSCZmM5d4quyAqjzkBhXvrX97JbQs',
|
||||
operation: {
|
||||
transaction: {
|
||||
source: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
destination: 'KT1SBj7e8ZhV2VvJtoc73dNRDLRJ9P6VjuVN',
|
||||
counter: 293,
|
||||
amount: 0,
|
||||
fee: 10000,
|
||||
gas_limit: 36283,
|
||||
storage_limit: 0,
|
||||
parameters_manager: {
|
||||
cancel_delegate: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign transaction operation from a KT account (smart contract with `manager.tz` script) to a tz account (implicit account)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BMCKRpEsFYQTdZy8BSLuFqkHmxwXrnRpKncdoVMbeGoggLG3bND',
|
||||
operation: {
|
||||
transaction: {
|
||||
source: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
destination: 'KT1SBj7e8ZhV2VvJtoc73dNRDLRJ9P6VjuVN',
|
||||
counter: 294,
|
||||
amount: 0,
|
||||
fee: 10000,
|
||||
gas_limit: 36283,
|
||||
storage_limit: 0,
|
||||
parameters_manager: {
|
||||
transfer: {
|
||||
amount: 200,
|
||||
destination: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Sign transaction operation from a KT account (smart contract with `manager.tz` script) to another KT account (smart contract with `manager.tz` script)
|
||||
|
||||
```javascript
|
||||
TrezorConnect.tezosSignTransaction({
|
||||
path: "m/44'/1729'/0'",
|
||||
branch: 'BMCKRpEsFYQTdZy8BSLuFqkHmxwXrnRpKncdoVMbeGoggLG3bND',
|
||||
operation: {
|
||||
transaction: {
|
||||
source: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
destination: 'KT1SBj7e8ZhV2VvJtoc73dNRDLRJ9P6VjuVN',
|
||||
counter: 294,
|
||||
amount: 0,
|
||||
fee: 10000,
|
||||
gas_limit: 36283,
|
||||
storage_limit: 0,
|
||||
parameters_manager: {
|
||||
transfer: {
|
||||
amount: 200,
|
||||
destination: 'tz1UKmZhi8dhUX5a5QTfCrsH9pK4dt1dVfJo',
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
[TezosSignedTx type](https://github.com/trezor/trezor-suite/blob/develop/packages/protobuf/src/messages.ts)
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
signature: string,
|
||||
sig_op_contents: string,
|
||||
operation_hash: string,
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,44 +0,0 @@
|
||||
## Unlock path
|
||||
|
||||
Ask device to unlock a subtree of the keychain.
|
||||
|
||||
Result is used in `getPublicKey`, `getAddress` and `signTransaction` methods to access requested keychain which is not available by default.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.unlockPath(params);
|
||||
```
|
||||
|
||||
> :warning: **This feature is experimental! Do not use it in production!**
|
||||
|
||||
> :note: **Supported only by T2T1 with Firmware 2.5.3 or higher!**
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
- `path` — _required_ `string | Array<number>`
|
||||
> prefix of the BIP-32 path leading to the account (m / purpose')
|
||||
|
||||
### Result
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
address_n: Array<number>,
|
||||
mac: string,
|
||||
}
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,56 +0,0 @@
|
||||
## Verify message
|
||||
|
||||
Asks device to
|
||||
verify a message using the signer address and signature.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.verifyMessage(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
[VerifyMessage type](https://github.com/trezor/trezor-suite/blob/develop/packages/connect/src/types/api/bitcoin/index.ts)
|
||||
|
||||
- `address` - _required_ `string` signer address,
|
||||
- `message` - _required_ `string` signed message,
|
||||
- `signature` - _required_ `string` signature in base64 format,
|
||||
- `coin` - _required_ `string` Determines network definition specified in [coins.json](https://github.com/trezor/trezor-suite/blob/develop/packages/connect-common/files/coins.json) file. Coin `shortcut`, `name` or `label` can be used.
|
||||
- `hex` - _optional_ `boolean` convert message from hex
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.verifyMessage({
|
||||
address: '3BD8TL6iShVzizQzvo789SuynEKGpLTms9',
|
||||
message: 'example message',
|
||||
signature:
|
||||
'JO7vL3tOB1qQyfSeIVLvdEw9G1tCvL+lNj78XDAVM4t6UptADs3kXDTO2+2ZeEOLFL4/+wm+BBdSpo3kb3Cnsas=',
|
||||
coin: 'btc',
|
||||
});
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: "Message verified"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -1,44 +0,0 @@
|
||||
## Wipe device
|
||||
|
||||
Reset device to factory defaults and remove all private data.
|
||||
|
||||
```javascript
|
||||
const result = await TrezorConnect.wipeDevice(params);
|
||||
```
|
||||
|
||||
### Params
|
||||
|
||||
[Optional common params](commonParams.md)
|
||||
|
||||
Common parameter `useEmptyPassphrase` - is set to `true`
|
||||
Common parameter `allowSeedlessDevice` - is set to `true`
|
||||
|
||||
### Example
|
||||
|
||||
```javascript
|
||||
TrezorConnect.wipeDevice();
|
||||
```
|
||||
|
||||
### Result
|
||||
|
||||
Success type
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: true,
|
||||
payload: {
|
||||
message: 'Device wiped'
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Error
|
||||
|
||||
```javascript
|
||||
{
|
||||
success: false,
|
||||
payload: {
|
||||
error: string // error message
|
||||
}
|
||||
}
|
||||
```
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 171 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 178 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 65 KiB |
Reference in New Issue
Block a user