As described in metamask github, one can bootstrap metamask like this:
window.addEventListener('load', function() {
// Checking if Web3 has been injected by the browser (Mist/MetaMask) if (typeof web3 !== 'undefined') {
// Use Mist/MetaMask's provider
window.web3 = new Web3(web3.currentProvider); } else {
console.log('No web3? You should consider trying MetaMask!')
// fallback - use your fallback strategy (local node / hosted node + in-dapp id mgmt / fail)
window.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545")); }
// Now you can start your app & access web3 freely: startApp()
})
How do I implement in angular 2 typescript, and where do I hookup this metamask web3 inject so that it will popup the metamask wallet whenever I trigger web3.eth.sendTransaction()