Display requested address derived by given BIP32 path on device and returns it to caller. User is asked to confirm the export on Trezor.
ES6
const result = await TrezorConnect.getAddress(params);CommonJS
TrezorConnect.getAddress(params).then(function(result) {
});path— obligatorystring | Array<number>minimum length is5. read moreaddress— optionalstringaddress for validation (readHandle button requestsection below)showOnTrezor— optionalbooleandetermines if address will be displayed on device. Default is set totruecoin- optionalstringdetermines network definition specified in coins.json file. Coinshortcut,nameorlabelcan be used. Ifcoinis not set API will try to get network definition frompath.crossChain— optionalbooleanAdvanced 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, redeem script information (multisig addresses only)scriptType- optional InputScriptType, address script type
bundle-Arrayof Objects withpath,showOnTrezor,coinandcrossChainfields
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
addressis set - parameter
showOnTrezoris set totrue(or not set at all) - application is requesting ONLY ONE(!) address
Display third address of first bitcoin account:
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:
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:
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 with only one address
{
success: true,
payload: {
address: string, // displayed address
path: Array<number>, // hardended path
serializedPath: string,
}
}Result with bundle of addresses
{
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
{
success: false,
payload: {
error: string // error message
}
}v4 and below:
TrezorConnect.getAddress("m/49'/0'/4'/0/0", function(result) {
// added "serializedPath" field
});should be
// params are key-value pairs inside Object
TrezorConnect.getAddress({
path: "m/49'/0'/4'/0/0"
}).then(function(result) {
...
})