signMessage.md

January 3, 2022 ยท View on GitHub

Sign message

Asks device to sign a message using the private key derived by given BIP32 path.

ES6

const result = await TrezorConnect.signMessage(params);

CommonJS

TrezorConnect.signMessage(params).then(function(result) {

});

Params

Optional common params

flowtype
  • path โ€” required string | Array<number> minimum length is 3. read more
  • message - required string
  • coin - optional string Determines network definition specified in coins.json file. Coin shortcut, name or label can be used. If coin is not set API will try to get network definition from path.
  • hex - optional boolean convert message from hex

Example

TrezorConnect.signMessage({
    path: "m/44'/0'/0'",
    message: "example message"
});

Result

flowtype
{
    success: true,
    payload: {
        address: string,   // signer address
        signature: string, // signature in base64 format
    }
}

Error

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

Migration from older version

version 4 and below

TrezorConnect.signMessage("m/44'/0'/0'", "example message", function(result) {
    ...
}, "bitcoin");

version 5

// params are key-value pairs inside Object
TrezorConnect.signMessage({ 
    path: "m/44'/0'/0'",
    message: "example message"
}).then(function(result) {
    ...
})