0

i am new to the blockchain, ethereum. I am trying to include metamask in my nodejs application. How to do that?

Any help would be appreciated.

  • MetaMask is a browser extension, so it can't be used from Node.js. – user19510 Feb 13 '18 at 6:45
2

If your code is not browser client facing...then you cannot connect to Metamask.

If your code is browser client facing...then you just have to look for the exposed window.web3 variable. Most people do this by checking the typeof web3 to see if it exists.

Here is an example from this article:

if (typeof web3 != 'undefined') {
  console.log("Using web3 detected from external source like Metamask")
  this.web3 = new Web3(web3.currentProvider)
} else {
  this.web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"))
}

Most basic tutorials should show you how.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.