.env
file to store the secrets..env
. Here is where you will set up the environment variables for your Chainststack Polygon zkEVM endpoint and your wallet’s private key.
hardhat.config.js
in the root directory. This file is used to configure various settings for your Hardhat projects, such as the network you want to deploy your contracts on, the compilers you want to use, and the plugins you want to enable.
Delete the default code in the file and replace it with the following:
require("@nomicfoundation/hardhat-toolbox");
imports the Hardhat Toolbox plugin, which provides several useful tools and utilities for Hardhat projects.require("dotenv").config();
loads environment variables from a .env
file using the dotenv
package.module.exports = { ... }
exports a JavaScript object containing the configuration for the Hardhat project.solidity: "0.8.18",
sets the Solidity compiler version to 0.8.18.networks: { ... }
defines the network configurations for the Hardhat project.defaultNetwork: { ... }
defines the default network that Hardhat will use.zkEVM_testnet: { ... }
defines the configuration for the zkEVM
network.url: ${process.env.YOUR_CHAINSTACK_ENDPOINT},
sets the RPC URL for the zkEVM network.accounts: [process.env.YOUR_PRIVATE_KEY],
sets the accounts for the zkEVM
network using the YOUR_PRIVATE_KEY
environment variable. This will allow the Hardhat project to deploy contracts and interact with the zkEVM testnet using the specified private key.contracts
. Create a new file named SimpleVault.sol
, and paste the following code inside it:
scripts
directory inside the root of your project, you will find a file named deploy.js
. Replace its content with the following:
SimpleVault
smart contract to the zkEVM testnet, and returns the address of the newly deployed contract in the terminal. You can search for your contract on the Polygon zkEVM testnet explorer.
To run this script, execute the following command in the terminal:
interact.js
inside the scripts directory. Paste the following code inside it: