Deploying a smart contract to the Goerli testnet using Hardhat
To deploy this smart contract to the Goerli testnet, we need to add a network entry to the hardhat.config.js
file as we did with Truffle.
We saved the Alchemy API key when we signed up for an account. To retrieve the Goerli private key, you will need to export your private key from MetaMask:
- Open MetaMask, and go to Account Details.
- Click on Export Private Key and it will give you your private key. Click to copy the private key.
- The
hardhat.config.js
file should look like the following code block when you fill out the details with theALCHEMY_API_KEY
andGOERLI_PRIVATE_KEY
values:require("@nomicfoundation/hardhat-toolbox");
/** @type import('hardhat/config').HardhatUserConfig */
const ALCHEMY_API_KEY = '4tSa5wvNrxAk2PAG8UGrqqziuKN__Hzb';
const GOERLI_PRIVATE_KEY = '<your private key>';
module.exports = {
solidity: "0.8.17",
networks: {
   ...