- Open the terminal (command line), create two new folders called
donation-to-educator
andbackend
. Go into thebackend
folder.
mkdir Donation-using-ZkPolygon
cd donation-using-ZkPolygon
mkdir backend
cd backend
- Set up a Hardhat project. Install the necessary libraries, by typing in the terminal:
npm init --yes
npm install --save-dev --save-exact [email protected]
npm install dotenv
- This library might be necessary to install as well, especially if you're a Windows user.
npm install --save-dev @nomicfoundation/hardhat-toolbox@3
- Make sure you are still in the
backend
directory. Now, create a sample contract project by typing in the terminal:
npx hardhat
- Select
Create a Javascript Project
. Don't change anything in the Hardhat project root, just click enter. Yes, add a.gitignore
.
-
Open the
backend
folder and remove any present contracts inside thecontracts
folder. Insert yourDonation
contract. -
Now, inside the
scripts
folder, replace the contect of thedeploy.js
file with the [deploy.js code from this project] -
Create a
.env
file inside thebackend
folder. This will be used to store your wallet's private key.
- Add this line inside the
.env
file, and update the content inside the quotation marks:
PRIVATE_KEY="your-wallet-private-key-goes-here-inside-the-quotation-marks"
-
Open the
hardhat.config.js
file inside thebackend
folder and replace its content with the hardhat.config.js code from this project. -
Compile your Contract by going back to your terminal (ensure you are in the
backend
directory). And type:
npx hardhat compile
- Every time you modify your contract, you will have to repeat the above compile step.
- With your contract compiled, now we can deploy it to the zkEVM testnet. In your terminal type:
npx hardhat run scripts/deploy.js --network zkEVM
Save the contract address that was printed out. Go to https://testnet-zkevm.polygonscan.com/ and insert the contract address into the Explorer input field. Take some time to explore the transaction details of your contract.
- Save this address somewhere. Don't lose it!