Skip to main content

Signing within a Lit Action using EIP-191

Overview

Lit Actions offer the ability to use EIP-191 to sign a message instead of a transaction or raw signature. This is done with the Lit Actions method ethPersonalSignMessageEcdsa.

It will prepend to your message: "\x19Ethereum Signed Message:\n" and the length of the message, then hash and sign it according to the EIP-191 standard.

Prerequisites

Complete Code Example

The complete code example is available in the Lit Developer Guides Code Repository. There you can find a Node.js and browser implementation of this example code.

Example Lit Action

The return value of ethPersonalSignMessageEcdsa (the sigShare variable in this example) is set to a boolean value of true if the signature was successfully generated, and false otherwise. The Lit Action will also return the complete signature as an object under the sigName key.

const _litActionCode = async () => {
try {
const sigShare = await LitActions.ethPersonalSignMessageEcdsa({
message: dataToSign,
publicKey,
sigName,
});
LitActions.setResponse({ response: sigShare });
} catch (error) {
LitActions.setResponse({ response: error.message });
}
};

export const litActionCode = `(${_litActionCode.toString()})();`;

Summary

This guide demonstrates how to sign an EIP-191 message using Lit Actions.

If you'd like to learn more about Lit Actions, check out the Lit Actions SDK, or our Advanced Topics section on Lit Actions.

info

Not finding the answer you're looking for? Share your feedback on these docs by creating an issue in our GitHub Issues and Reports repository or get support by visiting our Support page.