Created
September 20, 2017 14:43
-
-
Save BennyM/3566b593f04b5ffa42d776d088965224 to your computer and use it in GitHub Desktop.
Use eth-lightwallet with Web3ProviderEngine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var keyStore = ...init as usual...; | |
var engine = new Web3ProviderEngine(); | |
var opts = { | |
getAccounts: (cb) => { | |
let addresses = keyStore.getAddresses(); | |
let prefixedAddresses = addresses.map(add => { | |
return '0x' + add; | |
}); | |
cb(null, prefixedAddresses); | |
}, | |
signTransaction: (tx, cb) => { | |
let signedTransactionCallback = (error, result) =>{ | |
cb(null, result); | |
}; | |
keyStore.signTransaction(tx, signedTransactionCallback); | |
} | |
}; | |
var hookedWalletProvider = new HookedWalletSubprovider(opts); | |
engine.addProvider(hookedWalletProvider); | |
engine.addProvider(new Web3Subprovider(new Web3.providers.HttpProvider('http://myblochain.io:8545'))); | |
engine.start(); | |
var web3 = new Web3(engine); |
What does your keyStore.signTransaction
method look like? I'm not sure where a password would be provided here to perform the sign.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you use
WebsocketProvider
instead ofHttpProvider
and you useWeb3 1.0.0
it currently does not work due to the lack of support of newer version of web3 (at current state : today is 03/22/2018)