Web3 Signature


Live demos require a web3 client. We recommend installing Metamask. Live demos require an unlocked web3 client. Please unlock your client.

  <or-web3-sign rawMessage="Hello world!"></or-web3-sign>
    <li>Signature: <span id="signature"></span>
    <li>Error: <span id="error"></span>

let signButton = demoDoc.querySelector("or-web3-sign");
signButton.addEventListener("sign", function(event) {
  demoDoc.querySelector("#error").innerHTML = event.detail.error;
  demoDoc.querySelector("#signature").innerHTML = event.detail.signature;


yarn add @openrelay/web3-sign-element


The <or-web3-sign> element provides a button users can click to sign a message. This will trigger the user’s web3 client to prompt for a signature of the message attribute of the <or-web3-sign> element.

Signature Format

The signature will be a byte string of the following data:

start length description
0 1 The v component of an ECDSA signature
1 32 The r component of an ECDSA signature
33 32 The s component of an ECDSA signature
66 1 The 0x signature type

The signature type will depend on the Web3 client. For clients that prefix signed messages with \x19Ethereum Signed Message:\n32, the signature type will be 03 for the EthSign signature type. For clients that do not prefix signed messages, the signature type will be 02 for the EIP712 signature type. Note that at this time the <or-web3-sign> does not use EIP712 to sign messages, but signing an EIP712 hash without a prefix produces the same output as using EIP712 to produce the signature.


HTML Attributes
  • message — A 32 byte, hex encoded message to be signed.
  • rawMessage (optional) — An arbitrary string that will be keccak256 hashed to fill in the message attribute.

Note that only one of message or rawMessage should be provided.

Outgoing Events
  • sign — Fired when the user successfully signs a message. The signature can be found at e.detail.signature. If the user rejects the signature, or signing otherwise fails, an error will be emitted at e.detail.error.