I am ready with my frontend design. I have only 3 files HTML, CSS, and JAVASCRIPT. So, I didn't create any project or DAPP to have other files. Now next step is to connect with metamask and smart contract for payment. I am not getting exactly what I need to do now. Do I need node js files? If yes, then how? or any other files? How to connect with metamask? I searched for many codes but didn't get anything. Can somebody explain to me?

  • In principal you can interact just with JavaScript (without using node.js). Please provide some more details what you like to archive. Is there already a deployed contract in a test network? If yes, the ABI will be needed to write a minimal example. Commented Mar 7, 2020 at 16:55

1 Answer 1


maybe this could help

window.addEventListener('load', function() {
    if (typeof web3 !== 'undefined') {
      window.web3 = new Web3(web3.currentProvider);
      console.log('Connected to Metamask!')
    } else {
      console.log('Injected web3 Not Found!!!')
      var provider = 'http://localhost:8545';
      window.web3 = new Web3(new Web3.providers.HttpProvider(provider));
      console.log('Connected without Metamask!')

    console.log("account: " +  web3.eth.coinbase);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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