Quick Access
Coin Methods
Cardano
Miscellaneous
Methods
Cardano
cardanoSignMessage

Cardano: Sign message

Asks device to sign given message. User is presented with the first few bytes of the message and the hash of the whole message. User is asked to confirm details on Trezor.

const result = await TrezorConnect.cardanoSignMessage(params);

Params

Including CommonParams

payload

String

Required

message bytes in hex

preferHexDisplay

Boolean

Optional

if true, device will always decode payload as hex bytes

networkId

Number

Optional

network identifier. Required if addressParameters are set

protocolMagic

Number

Optional

protocol magic. Required if addressParameters are set

addressParameters

Object

Optional

CardanoAddressParameters object. read more Used to derive address for message header. If not set then the key hash given by path will be used instead.

derivationType

Enum: LEDGER (0) | ICARUS (1) | ICARUS_TREZOR (2)

Optional

enum. determines used derivation type. Default is set to ICARUS_TREZOR=2

Displaying payload

By default, the payload is decoded as ASCII given the conditions below are satisfied. If they are not satisfied or preferHexDisplay is true, the payload is displayed as hex bytes. The ASCII conditions are:

  • The payload is a valid ASCII string.
  • It must be clear to the user what the contents of the payload are, specifically there is:
    • At least one character
    • No control characters
    • No leading, trailing nor multiple consecutive spaces

Example

Sign hash of "Hello Trezor!":

TrezorConnect.cardanoSignMessage({
    path: "m/1852'/1815'/0'/0/0",
    payload: '48656c6c6f205472657a6f7221', // "Hello Trezor!" in hex
    preferHexDisplay: false,
});

Sign hash of "Hello Trezor!" using address parameters for header:

TrezorConnect.cardanoSignMessage({
    path: "m/1852'/1815'/0'/0/0",
    payload: '48656c6c6f205472657a6f7221', // "Hello Trezor!" in hex
    preferHexDisplay: false,
    networkId: 1,
    protocolMagic: 764824073,
    addressParameters: {
        addressType: 0,
        path: "m/1852'/1815'/0'/0/0",
        stakingPath: "m/1852'/1815'/0'/2/0",
    },
});

Result

CardanoSignedMessage type

{
    success: true,
    payload: {
      payload: string, // your payload
      signature: string, // raw signature
      pubKey: string, // raw public key
      coseSignature: string, // COSE cbor encoded signature
      coseKey: string, // COSE cbor encoded public key
      headers: { // COSE headers
        protected: {
          1: -8, // EdDSA algorithm
          address: string,
        },
        unprotected: {
          hashed: boolean,
          version: number,
        }
      }
    }
}

Error

{
    success: false,
    payload: {
        error: string // error message
    }
}