Use requirement
Firmware version required
Cardano: get address
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 OneKey.
Copy const response = await HardwareSDK.cardanoGetAddress(connectId, deviceId, params)
Params
Optional common params
Exporting single address
addressParameters
— required see description below
protocolMagic
- required Integer
764824073 for Mainnet, 1 for Preprod Testnet, 2 for Preview Testnet
networkId
- required Integer
1 for Mainnet, 0 for Testnet
address
— optional string
address for validation (read Handle button request
section below)
showOnOneKey
— 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=1
isCheck
— optional boolean
checks only the base address
Exporting bundle of addresses
bundle
- Array
of Objects with single address fields
Address Parameters
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
.
stakingPath
— optional string | Array<number>
minimum length is 5
. 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 object. Must contain number
s blockIndex
, txIndex
and certificateIndex
. Used for pointer address derivation.
paymentScriptHash
- optional string
hex string of payment script hash.
stakingScriptHash
- optional string
hex string of staking script hash.
Example
Display byron address of first cardano account:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.BYRON,
path: "m/44'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display base address of first cardano account:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
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:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
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:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
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:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.BASE_SCRIPT_SCRIPT,
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
},
protocolMagic: 764824073,
networkId: 1,
});
Display pointer address of first cardano account:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
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:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
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:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.ENTERPRISE,
path: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display enterprise script address:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.ENTERPRISE_SCRIPT,
paymentScriptHash: '0d5acbf6a1dfb0c8724e60df314987315ccbf78bb6c0f9b6f3d568fe',
},
protocolMagic: 764824073,
networkId: 1,
});
Display reward address of first cardano account:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.REWARD,
stakingPath: "m/1852'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
});
Display reward script address:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
addressParameters: {
addressType: CardanoAddressType.REWARD_SCRIPT,
stakingScriptHash: '8d7bebc7a58f1c7b5fb7c9391071ecd3b51b032695522f8c555343a9',
},
protocolMagic: 764824073,
networkId: 1,
});
Return a bundle of cardano addresses without displaying them on device:
Copy HardwareSDK.cardanoGetAddress(connectId, deviceId, {
bundle: [
// byron address, account 1, address 1
{
addressParameters: {
addressType: 8,
path: "m/44'/1815'/0'/0/0",
},
protocolMagic: 764824073,
networkId: 1,
showOnOneKey: 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,
showOnOneKey: false,
},
// byron address, account 2, address 3, testnet
{
addressParameters: {
addressType: 8,
path: "m/44'/1815'/1'/0/2",
},
protocolMagic: 1,
networkId: 0,
showOnOneKey: false,
},
],
});
Result
Result with only one address
Copy {
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,
xpub: string,
stakeAddress: string, // If a base address is created, the stake address is created together
}
}
Result with bundle of addresses
Copy {
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
Copy {
success: false,
payload: {
error: string // error message
}
}