Message Signing

Functions to sign messages and type data.

ledgereth.messages.sign_message(message: Union[str, bytes], sender_path: str = "44'/60'/0'/0/0", dongle: Optional[ledgerblue.Dongle.Dongle] = None) ledgereth.objects.SignedMessage[source]

Sign a simple text message. Message will be prefixed by the Ethereum app on the Ledger device according to EIP-191.

Parameters
  • message – (str|bytes) - A bit of text to sign

  • sender_path – (str) - HD derivation path for the account to sign with.

  • dongle – (ledgerblue.Dongle.Dongle) - The Web3 instance to use

Returns

ledgereth.objects.SignedMessage

ledgereth.messages.sign_typed_data_draft(domain_hash: Union[str, bytes], message_hash: Union[str, bytes], sender_path: str = "44'/60'/0'/0/0", dongle: Optional[ledgerblue.Dongle.Dongle] = None) ledgereth.objects.SignedTypedMessage[source]

Sign EIP-721 typed data.

Danger

EIP-712 is still in DRAFT status and APIs may change, including the Ledger app-ethereum implementation.

Parameters
  • domain_hash – (str) - Hash of the EIP-712 domain

  • message_hash – (str) - Hash of the message

  • sender_path – (str) - HD derivation path for the account to sign with. Defaults to first account in the derivation path.

  • dongle – (ledgerblue.Dongle.Dongle) - The Dongle instance to use to communicate with the Ledger device

Returns

ledgereth.objects.SignedTypedMessage Signed message object

For a real example of usage, see how this is used with eth_account in ledgereth’s unit tests.