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

web3-local-signing-provider

v1.1.3

Published

The local provider works by intercepting calls to `eth_sendTransaction` and replaces them with calls to `sendSignedTransaction` after locally signing the transaction.

Downloads

15

Readme

Local WEB3.js provider

The local provider works by intercepting calls to eth_sendTransaction and replaces them with calls to sendSignedTransaction after locally signing the transaction.

Usage

The LocalProvider can be used wherever web3 can. It creates an object that wraps the regular web3 object.

To instantiate a LocalProvider you have to provide 2 parameters:

  • a string or array of strings containing Ethereum private keys
  • another provider (Http, WebSocket or IPS) which will be used to actually communicate with the node

Installation

npm install web3-local-signing-provider

example

const provider = new LocalProvider([
    'fdb2886b1ff5a0e60f9a4684e385aa7b77f064730304143f08ba96ca1a17effa',
    '8d8697970c933b856a02c5c2a9e1ead92b434d6cb724a0635219a1568a4cfd51'
  ],
  new Web3.providers.HttpProvider('http://localhost:8535'))
const web3 = provider.web3

The LocalProvider creates its own web3 object which can be used as in the example above. An alternative is to create another Web3 object and use the LocalProvider as its provider. Like so

const provider = new LocalProvider([
    'fdb2886b1ff5a0e60f9a4684e385aa7b77f064730304143f08ba96ca1a17effa',
    '8d8697970c933b856a02c5c2a9e1ead92b434d6cb724a0635219a1568a4cfd51'
  ],
  new Web3.providers.HttpProvider('http://localhost:8535'))
const web3 = new Web3(provider)

sending transactions

Once instantiated, the LocalProvider Web3 object can be used the same way you would use a web3 object connected to a node with an unlocked account.

const test = async () => {
    try {
      let receipt = await web3.eth.sendTransaction({
        from: '0x0f21f6fb13310ac0e17205840a91da93119efbec',
        to: '0x205161Cec3b55cA9a5997eeaf983B798D5Dc8408',
        gasPrice: 12,
        value: 1e17
      })
      console.log(receipt)
    } catch (err) {
      console.log(err)
    }
  }

Future development

Some features could be added which would be useful:

  • [] Disable the TIMEOUTBLOCK and wait forever for a transaction to be mined
  • [] Store pending transactions to LocalStorage and check their status on page reload
  • [] Make the varible TIMEOUTBLOCK configurable to tune the error message transaction not mined after 50 blocks
  • [] Enable subscribing to events using getPastEvents to allow getting events from Infura
  • [] Add Hardware Wallet (Ledger, Trezor) signing ability
  • [] Use EthGasStation to estimate gas https://ethgasstation.info/json/ethgasAPI.json