npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@openrelay/web3-sign-element

v0.1.1

Published

A lit-element that signs messages

Downloads

8

Readme


layout: widget title: "Web3 Signature" date: 2018-09-26 08:15:00 -0500 categories: widgets code: html: |

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

js: |

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;
});

npm: "@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.

API

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.

Events
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.