Skip to main content
This document outlines the end-to-end process of deploying a smart contract on Abstract using Hardhat. It’s the ideal guide if you’re building a new project from scratch.

YouTube Tutorial: Get Started with Hardhat

Watch a step-by-step tutorial on how to get started with Hardhat.

1. Create a new project

Ensure you have the following installed on your machine:
  • Node.js v18.0.0 or later.
  • If you are on Windows, we strongly recommend using WSL 2 to follow this guide.
Inside an empty directory, initialize a new Hardhat project using the Hardhat CLI: Create a new directory and navigate into it:
Initialize a new Hardhat project within the directory:
Select your preferences when prompted by the CLI, or use the recommended setup below.

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:

3. Modify the Hardhat configuration

Update your hardhat.config.ts file to include the following options:

4. Write a smart contract

Rename the existing contracts/Lock.sol file to contracts/HelloAbstract.sol:
Write a new smart contract in the contracts/HelloAbstract.sol file, or use the example smart contract below:

5. Compile the smart contract

Clear any existing artifacts:
Use the zksolc compiler (installed in the above steps) to compile smart contracts for Abstract:
You should now see the compiled smart contracts in the generated artifacts-zk directory.

6. Deploy the smart contract

Add the deployer account private key

Create a new configuration variable called DEPLOYER_PRIVATE_KEY.
Enter the private key of a new wallet you created for this step.
Do NOT use a private key associated with real funds. Create a new wallet for this step.
2

Get ETH in the deployer account

The deployer account requires ETH to deploy a smart contract.
  • Testnet: Claim ETH via a faucet, or bridge ETH from Sepolia.
  • Mainnet: Use a bridge to transfer ETH to Abstract mainnet.

Write the deployment script

Create a new Hardhat script located at /deploy/deploy.ts:
Add the following code to the 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.