Is it possible to get a metamask private key?

6.3k Views Asked by At

I'm beginner to blockchain development, and I have a question in the polygon documentation in order to make a deployment using hradhat, you need to pass account: process.env.PRIVATE_KEY, but how do I get the user's private key when logging in to the metamask on the site?

require('dotenv').config();
require("@nomiclabs/hardhat-ethers");
require("@nomiclabs/hardhat-etherscan");


    module.exports = {
      defaultNetwork: "matic",
      networks: {
        hardhat: {
        },
        matic: {
          url: "https://rpc-mumbai.maticvigil.com",
          accounts: [process.env.PRIVATE_KEY]
        }
      },
      etherscan: {
        apiKey: process.env.POLYGONSCAN_API_KEY
      },
      solidity: {
        version: "0.7.0",
        settings: {
          optimizer: {
            enabled: true,
            runs: 200
          }
        }
      },
    }

2

There are 2 best solutions below

0
On

In MetaMask's "Account details" there is an "export private key" option

0
On

Yes, you can get the MetaMask Private key through Google Chrome Extension.

  • Go to Account Details
  • Export Private Key
  • Enter your Password
  • Private Key Reveal to you

Make sure you do not share this with anyone this address have a all your assets stored.