Method testing tool
Cardano: get native script hash
Display native script components on Trezor, display the calculated native script hash and return the hash to the caller.
const result = await TrezorConnect.cardanoGetNativeScriptHash(params);
Params
Including CommonParams
CardanoGetNativeScriptHash
script
T0
Required
see description below.
scripts
Array<This>
Optional
of nested CardanoNativeScript
s.
keyHash
String
Optional
hex string of key hash. Used for CardanoScriptType.PUB_KEY
.
keyPath
String | Array<Number>
Optional
minimum length is 3
. Used for CardanoScriptType.PUB_KEY
.
requiredSignaturesCount
Number
Optional
used for CardanoScriptType.N_OF_K
.
invalidBefore
String
Optional
used for CardanoScriptType.INVALID_BEFORE
.
invalidHereafter
String
Optional
used for CardanoScriptType.INVALID_HEREAFTER
.
derivationType
Enum: LEDGER (0) | ICARUS (1) | ICARUS_TREZOR (2)
Optional
enum. determines used derivation type. Default is set to ICARUS_TREZOR=2
Example
Get native script hash of a simple PUB_KEY script:
TrezorConnect.cardanoGetNativeScriptHash({
script: {
type: CardanoNativeScriptType.PUB_KEY,
keyHash: 'c4b9265645fde9536c0795adbcc5291767a0c61fd62448341d7e0386',
},
displayFormat: CardanoNativeScriptHashDisplayFormat.HIDE,
});
Get native script hash of a nested script:
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
{
success: true,
payload: {
scriptHash: 'b12ac304f89f4cd4d23f59a2b90d2b2697f7540b8f470d6aa05851b5',
}
}
Error
{
success: false,
payload: {
error: string // error message
}
}
Last updated on