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
— required see description belowaddress
— optionalstring
address for validation (readHandle button request
section below)protocolMagic
- requiredInteger
764824073 for Mainnet, 42 for TestnetnetworkId
- requiredInteger
1 for Mainnet, 0 for TestnetshowOnTrezor
— optionalboolean
determines if address will be displayed on device. Default is set totrue
derivationType
— optionalCardanoDerivationType
enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
bundle
-Array
of Objects with single address fields
addressType
- requiredCardanoAddressType
/number
- you can use the flowCARDANO.ADDRESS_TYPE
object or typescriptCardanoAddressType
enum. Supports all address types.path
— requiredstring | Array<number>
minimum length is5
. read morestakingPath
— optionalstring | Array<number>
minimum length is5
. read more Used for base and reward address derivationstakingKeyHash
- optionalstring
hex string of staking key hash. Used for base address derivation (as an alternative tostakingPath
)certificatePointer
- optionalCardanoCertificatePointer
object. Must containnumber
sblockIndex
,txIndex
andcertificateIndex
. (flowtype) Used for pointer address derivation. read more about pointer addresspaymentScriptHash
- optionalstring
hex string of payment script hash.stakingScriptHash
- optionalstring
hex string of staking script hash.
Since [email protected] 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 totrue
(or not set at all) - application is requesting ONLY ONE(!) address
Display byron address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.BYRON,
path: "m/44'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display base address of first cardano account:
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:
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:
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:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.BASE_SCRIPT_SCRIPT,
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
},
protocolMagic: 764824073,
networkId: 1,
});
Display pointer address of first cardano account:
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:
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:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.ENTERPRISE,
path: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display enterprise script address:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.ENTERPRISE_SCRIPT,
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
},
protocolMagic: 764824073,
networkId: 1,
});
Display reward address of first cardano account:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.REWARD,
stakingPath: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display reward script address:
TrezorConnect.cardanoGetAddress({
addressParameters: {
addressType: CardanoAddressType.REWARD_SCRIPT,
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
},
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,
},
paymentScriptHash?: string,
stakingScriptHash?: string,
}
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,
},
paymentScriptHash?: string,
stakingScriptHash?: string,
}
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,
},
paymentScriptHash?: string,
stakingScriptHash?: string,
}
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,
},
paymentScriptHash?: string,
stakingScriptHash?: string,
}
serializedPath?: string,
serializedStakingPath?: string,
protocolMagic: number,
networkId: number,
address: string,
},
]
}
Error
{
success: false,
payload: {
error: string // error message
}
}