Skip to content

Instantly share code, notes, and snippets.

@Schaeff
Created July 27, 2017 17:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Schaeff/5ad8f50ff4978e7fa09a8c11bd01e171 to your computer and use it in GitHub Desktop.
Save Schaeff/5ad8f50ff4978e7fa09a8c11bd01e171 to your computer and use it in GitHub Desktop.
var ZeroClientProvider = require('web3-provider-engine/zero.js')
var Web3 = require('web3')
var lightwallet = require('eth-lightwallet')
var interval = 4000
var keyStore = lightwallet.keystore
keyStore.createVault({
password: "abc",
seedPhrase: "method magic hair item student maple glide clown onion expire fuel sport", // Optionally provide a 12-word seed phrase
// salt: fixture.salt, // Optionally provide a salt.
// A unique salt will be generated otherwise.
// hdPathString: hdPath // Optional custom HD Path String
}, function(err, ks) {
console.log(err, ks)
// Some methods will require providing the `pwDerivedKey`,
// Allowing you to only decrypt private keys on an as-needed basis.
// You can generate that value with this convenient method:
ks.keyFromPassword("abc", function(err, pwDerivedKey) {
if (err) throw err;
// generate five new address/private key pairs
// the corresponding private keys are also encrypted
ks.generateNewAddress(pwDerivedKey, 5);
var addr = ks.getAddresses();
console.log(addr[0])
ks.passwordProvider = function(callback) {
callback(null, "abc");
};
var engines = [0, 1, 2, 3].map(i => new ZeroClientProvider({
getAccounts: (callback) => callback(null, ks.getAddresses().map(a => '0x' + a)),
signTransaction: (tx, callback) => {
return ks.signTransaction(tx, callback)
},
rpcUrl: 'http://localhost:8545'
}))
var web3 = engines.map(e => new Web3(e))
web3.forEach((w, i) => setTimeout(() => setInterval(() => w.eth.sendTransaction({
from: addr[0],
to: addr[1],
value: i
}, (err, h) => console.log(" ",i," ",(err || "none").toString().slice(0, 10), h)), 4*interval), interval * i))
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment