1.0.38 • Published 4 years ago

burner-provider v1.0.38

Weekly downloads
204
License
MIT
Repository
github
Last release
4 years ago

burner-provider

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

1.0.38

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.37

4 years ago

1.0.36

4 years ago

1.0.35

4 years ago

1.0.34

4 years ago

1.0.31

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.26

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

5 years ago

1.0.14

5 years ago

1.0.13

5 years ago

1.0.12

5 years ago

1.0.11

5 years ago

1.0.10

5 years ago

1.0.9

5 years ago

1.0.8

5 years ago

1.0.7

5 years ago

1.0.6

5 years ago

1.0.5

5 years ago

1.0.4

5 years ago

1.0.3

5 years ago

1.0.2

5 years ago

1.0.1

5 years ago