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

empty-burner-provider

v0.0.1

Published

Ephemeral key pair web3 provider

Downloads

2

Readme

no-burner-provider

⚠️ NOTE: This package is for Next.js users who want to exclude burner-provider from their apps because they don't need it and it inflates their bundle size. If you are using burner wallets in your dApp, use https://github.com/austintgriffith/burner-provider.

To use in Next.js, include this property in the webpack part of your next.config.js:

module.exports = {
  webpack: (config) => {
    config.resolve.alias = {
      ...config.resolve.alias,
      'burner-provider': 'empty-burner-provider',
    }

    return config
  },
}

Ephemeral key pair web3 provider

Here is an example React app that uses the burner-provider!

npm install burner-provider

Pass BurnerProvider into Web() to initialize:

import BurnerProvider from 'burner-provider';
import Web3 from 'web3';
var web3 = new Web3(new BurnerProvider('http://localhost:8545'));

OR using old require() method:

const BurnerProvider = require('burner-provider');
const Web3 = require('web3');
var web3 = new Web3(new BurnerProvider('http://localhost:8545'));

OR using ethers.js:

const BurnerProvider = require('burner-provider');
const ethers = require('ethers');
let provider = new ethers.providers.Web3Provider(new BurnerProvider('http://localhost:8545'));

You can get your address with:

let accounts = await web3.eth.getAccounts()

Now your transactions will automatically sign and send:

var tx = {
  to: this.state.to,
  from: this.state.accounts[0],
  value: this.state.value,
  data: '0x00'
}

web3.eth.sendTransaction(tx).then((receipt)=>{
  console.log("receipt",receipt)
  this.setState({receipt:receipt})
});

You also can access the private key directly with:

localStorage.getItem('metaPrivateKey')

Optional Parameters:

var web3 = new Web3(new BurnerProvider({
  rpcUrl: 'http://localhost:8545',
  namespace: 'YourCoolUrl'
}));

Websockets work too:

var web3 = new Web3(new BurnerProvider('wss://mainnet.infura.io/ws'));

You can generate your wallet from a mnemonic and optional index too:

var web3 = new Web3(new BurnerProvider({
    rpcUrl: 'http://localhost:8545',
    mnemonic: 'the bear is sticky with honey'
}));

Full CLI Example: index.js:

var Web3 = require('web3');
var BurnerProvider = require('./index.js')

// you can pass in just the RPC endpoint:
//var web3 = new Web3(new BurnerProvider('http://localhost:8545'));
//
//or you can even pass in a pk:
//var web3 = new Web3(new BurnerProvider({
//    rpcUrl: 'wss://mainnet.infura.io/ws',
//    privateKey: '0xc0745ca88cdcb802a30ba467850e19019f8e7354eecc5ab674d78452e4feab84'
//}));
//or you can pass it a websocket:
var web3 = new Web3(new BurnerProvider('wss://mainnet.infura.io/ws'));


console.log(web3.version)
web3.eth.getBlockNumber().then(console.log);
web3.eth.getAccounts().then((accounts)=>{
    console.log("Accounts:",accounts)
    web3.eth.getBalance(accounts[0]).then((balance)=>{
        console.log("balance:",balance)
        web3.eth.sign(web3.utils.utf8ToHex("Hello world"),accounts[0]).then((sig)=>{
            console.log("SIG:",sig)
            web3.currentProvider.stop()
        });
    })
});
npm install web3 burner-provider
node index.js

image