Quick Access
Coin Methods
Ethereum
Miscellaneous
Methods
Ethereum
ethereumSignTypedData

Ethereum: Sign Typed Data

Asks device to sign an EIP-712 typed data message using the private key derived by given BIP32 path.

User is asked to confirm all signing details on T2T1.

const result = await TrezorConnect.ethereumSignTypedData(params);
⚠️
Supported only by T2T1 with Firmware 2.4.3 or higher!
⚠️

Blind signing is supported only on T1B1 with Firmware 1.10.5 or higher!

Params

Including CommonParams

EthereumSignTypedData

data

Object

Required

type of EthereumSignTypedDataMessage`. A JSON Schema definition can be found in the EIP-712 spec.

EthereumSignTypedHash

data

Object

Required

type of EthereumSignTypedDataMessage`. A JSON Schema definition can be found in the EIP-712 spec.

domain_separator_hash

String

Required

hex-encoded 32-byte hash of the EIP-712 domain.

message_hash

String

Optional

hex-encoded 32-byte hash of the EIP-712 message.

Example

const eip712Data = {
    types: {
        EIP712Domain: [
            {
                name: 'name',
                type: 'string',
            },
        ],
        Message: [
            {
                name: 'Best Wallet',
                type: 'string',
            },
            {
                name: 'Number',
                type: 'uint64',
            },
        ],
    },
    primaryType: 'Message',
    domain: {
        name: 'example.trezor.io',
    },
    message: {
        'Best Wallet': 'Trezor Model T',
        // be careful with JavaScript numbers: MAX_SAFE_INTEGER is quite low
        Number: `${2n ** 55n}`,
    },
};
 
// This functionality is separate from @trezor/connect, as it requires @metamask/eth-sig-utils,
// which is a large JavaScript dependency
const transformTypedDataPlugin = require('@trezor/connect-plugin-ethereum');
const { domain_separator_hash, message_hash } = transformTypedDataPlugin(eip712Data, true);
 
TrezorConnect.ethereumSignTypedData({
    path: "m/44'/60'/0'",
    data: eip712Data,
    metamask_v4_compat: true,
    // These are optional, but required for T1B1 compatibility
    domain_separator_hash,
    message_hash,
});

Result

EthereumMessageSignature type

{
    success: true,
    payload: {
        address: string,
        signature: string, // hexadecimal string with "0x" prefix
    }
}

Error

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