'Metamask Private Key Too Long
I pulled the private key from Metamask (a 64 character string), set it in the .env file, yet whenver I try to deploy, I get this error:
Invalid account: #0 for network: rinkeby - private key too long, expected 32 bytes
My hardhat.config.js file is pretty boring (AKA straight from OpenSea's example).
/**
* @type import('hardhat/config').HardhatUserConfig
*/
require("dotenv").config();
require("@nomiclabs/hardhat-ethers");
require("./scripts/deploy.js");
const { ALCHEMY_KEY, ACCOUNT_PRIVATE_KEY } = process.env;
module.exports = {
solidity: "0.8.1",
defaultNetwork: "rinkeby",
networks: {
hardhat: {},
rinkeby: {
url: `https://eth-rinkeby.alchemyapi.io/v2/${ALCHEMY_KEY}`,
accounts: [`0x${ACCOUNT_PRIVATE_KEY}`],
},
ethereum: {
chainId: 1,
url: `https://eth-mainnet.alchemyapi.io/v2/${ALCHEMY_KEY}`,
accounts: [`0x${ACCOUNT_PRIVATE_KEY}`],
},
},
};
I see a ton of folks out there with private keys that are too short, but I seem to be one of the few with this joyous error!
Yeah, yeah. I know MetaMask gives me 64 characters and the error clearly says 32. That’s the issue. Is there a conversion or something I need to do?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
