Hardhat - Deploying Contracts
Learn how to deploy smart contracts on Abstract using Hardhat.
Deploying Contract
Install zksync-ethers
The zksync-ethers package provides a modified version of the ethers library that is compatible with Abstract and the ZKsync VM. Install the package by running the following command:
Set 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.
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:
Providing constructor arguments
The second argument to the deploy
function is an array of constructor arguments.
To deploy your smart contract with constructor arguments, provide an array containing your constructor arguments as the second argument to the deploy
function.
Create2 & Smart Wallet Deployments
Specify different deployment types through using the third deploymentType
parameter:
- create: Standard contract deployment (default)
- create2: Deterministic deployment using CREATE2
- createAccount: Deploy a smart contract wallet.
- create2Account: Deterministic deployment of a smart contract wallet.
Additional Factory Dependencies
Factory smart contracts (contracts that can deploy other contracts) require the bytecode of the contracts they can deploy to be provided within the factory dependencies array.
Learn more about factory dependencies.
Was this page helpful?