Display requested address derived by given BIP32-Ed25519 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.
ES6
const result = await TrezorConnect.cardanoGetAddress(params);CommonJS
TrezorConnect.cardanoGetAddress(params).then(function(result) {
});addressParameters— obligatory see description belowaddress— optionalstringaddress for validation (readHandle button requestsection below)protocolMagic- obligatoryInteger764824073 for Mainnet, 42 for TestnetnetworkId- obligatoryInteger1 for Mainnet, 0 for TestnetshowOnTrezor— optionalbooleandetermines if address will be displayed on device. Default is set totrue
bundle-Arrayof Objects with single address fields
addressType- obligatoryCardanoAddressType/number- you can use the flowCARDANO.ADDRESS_TYPEobject or typescriptCardanoAddressTypeenum. Supports Base, Pointer, Enterprise, Byron and Reward address types.path— obligatorystring | Array<number>minimum length is5. read morestakingPath— optionalstring | Array<number>minimum length is5. read more Used for base address derivationstakingKeyHash- optionalstringhex string of staking key hash. Used for base address derivation (as an alternative tostakingPath)certificatePointer- optionalCardanoCertificatePointerobject. Must containnumbersblockIndex,txIndexandcertificateIndex. (flowtype) Used for pointer address derivation. read more about pointer address
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 byron address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: 8,
path: "m/44'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});Display base address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: 0,
path: "m/1852'/1815'/0'/0/0",
stakingPath: "m/1852'/1815'/0'/2/0",
},
protocolMagic: 764824073,
networkId: 1,
});Display pointer address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: 4,
path: "m/1852'/1815'/0'/0/0",
certificatePointer: {
blockIndex: 1,
txIndex: 2,
certificateIndex: 3,
},
},
protocolMagic: 764824073,
networkId: 1,
});Display enterprise address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: 6,
path: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});Display reward address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: 14,
path: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});Return a bundle of cardano addresses without displaying them on device:
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: 42,
networkId: 0,
showOnTrezor: false
},
]
});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.cardanoGetAddress({
addressParameters: {
addressType: 8,
path: "m/44'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 0,
address: "Ae2tdPwUPEZ5YUb8sM3eS8JqKgrRLzhiu71crfuH2MFtqaYr5ACNRdsswsZ",
});
// dont forget to hide your custom UI after you get the result!Result with only one address
{
success: true,
payload: {
addressParameters: {
addressType: number,
path: Array<number>, // hardend path
stakingPath?: Array<number>, // hardend path
stakingKeyHash?: string,
certificatePointer?: {
blockIndex: number,
txIndex: number,
certificatePointer: number,
}
}
serializedPath: string,
serializedStakingPath?: string,
protocolMagic: number,
networkId: number,
address: string,
}
}Result with bundle of addresses
{
success: true,
payload: [
{
addressParameters: {
addressType: number,
path: Array<number>, // hardend path
stakingPath?: Array<number>, // hardend path
stakingKeyHash?: string,
certificatePointer?: {
blockIndex: number,
txIndex: number,
certificatePointer: number,
}
}
serializedPath: string,
serializedStakingPath?: string,
protocolMagic: number,
networkId: number,
address: string,
},
{
addressParameters: {
addressType: number,
path: Array<number>, // hardend path
stakingPath?: Array<number>, // hardend path
stakingKeyHash?: string,
certificatePointer?: {
blockIndex: number,
txIndex: number,
certificatePointer: number,
}
}
serializedPath: string,
serializedStakingPath?: string,
protocolMagic: number,
networkId: number,
address: string,
},
{
addressParameters: {
addressType: number,
path: Array<number>, // hardend path
stakingPath?: Array<number>, // hardend path
stakingKeyHash?: string,
certificatePointer?: {
blockIndex: number,
txIndex: number,
certificatePointer: number,
}
}
serializedPath: string,
serializedStakingPath?: string,
protocolMagic: number,
networkId: number,
address: string,
},
]
}Error
{
success: false,
payload: {
error: string // error message
}
}