Search code examples
blockchainethereummetamaskganachedecentralized-applications

Why Metamask if web3.js can interact directly with ganache?


I am new to blockchain app development, I saw a project where ganache accounts are imported into Metamask, then web3.js is used to access and print those accounts and balances on Frontend (user interface).

If web3.js can directly access ganache blockchain accounts and balances, why do we need Metamask in between?


Solution

  • If web3.js can directly acccess ganache blockchain accounts and balances, why we need metamask in between?

    In this case, you don't need MetaMask to sign the transaction, as the node (Ganache) holds your private key.

    But in a public environment (testnets and mainnet), the node doesn't hold your private key, so you'd need to sign the transaction using MetaMask (or any other tool that holds the private key).