YouTube Tutorial: Get Started with Hardhat
Watch a step-by-step tutorial on how to get started with Hardhat.
1. Create a new project
Prerequisites
Prerequisites
Recommended Hardhat setup
Recommended Hardhat setup
We recommend selecting the following options when prompted by the Hardhat CLI:
2. Install the required dependencies
Abstract smart contracts use different bytecode than the Ethereum Virtual Machine (EVM). Install the required dependencies to compile, deploy and interact with smart contracts on Abstract:- @matterlabs/hardhat-zksync: A suite of Hardhat plugins for working with Abstract.
- zksync-ethers: Recommended package for writing Hardhat scripts to interact with your smart contracts.
3. Modify the Hardhat configuration
Update yourhardhat.config.ts
file to include the following options:
4. Write a smart contract
Rename the existingcontracts/Lock.sol
file to contracts/HelloAbstract.sol
:
contracts/HelloAbstract.sol
file, or use the example smart contract below:
5. Compile the smart contract
Clear any existing artifacts:artifacts-zk
directory.
6. Deploy the smart contract
Add the deployer account private key
Create a new configuration variable
called Enter the private key of a new wallet you created for this step.
DEPLOYER_PRIVATE_KEY
.Do NOT use a private key associated with real funds. Create a new wallet for this step.
2
Write the deployment script
Create a new Hardhat script located at Add the following code to the
/deploy/deploy.ts
:deploy.ts
file:Deploy your smart contract
Run the following command to deploy your smart contracts:If successful, your output should look similar to the following:
Verify your smart contract on the block explorer
Verifying your smart contract is helpful for others to view the code and
interact with it from a block explorer.
To verify your smart contract, run the following command:Note: Replace
YOUR_CONTRACT_ADDRESS
with the address of your deployed smart contract.