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:
;;var web3 = 'http://localhost:8545';
OR using old require()
method:
const BurnerProvider = ;const Web3 = ;var web3 = 'http://localhost:8545';
OR using ethers.js
:
const BurnerProvider = ;const ethers = ;let provider = 'http://localhost:8545';
You can get your address with:
let accounts = await web3eth
Now your transactions will automatically sign and send:
var tx = to: thisstateto from: thisstateaccounts0 value: thisstatevalue data: '0x00' web3eth;
You also can access the private key directly with:
localStorage
Optional Parameters:
var web3 = rpcUrl: 'http://localhost:8545' namespace: 'YourCoolUrl';
Websockets work too:
var web3 = 'wss://mainnet.infura.io/ws';
You can generate your wallet from a mnemonic and optional index too:
var web3 = rpcUrl: 'http://localhost:8545' mnemonic: 'the bear is sticky with honey';
Full CLI Example:
index.js
:
var Web3 = ;var BurnerProvider = // 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 = 'wss://mainnet.infura.io/ws'; consoleweb3eth;web3eth;
npm install web3 burner-providernode index.js