This repository contains examples of how to deploy smart contracts and smart contract factories (contracts that can deploy other contracts) on Abstract using:
Get a copy of the contract-deployment
example directory from the Abstract Examples repository:
mkdir -p contract-deployment && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C contract-deployment examples-main/contract-deployment && cd contract-deployment
-
Change directory into the
hardhat
folder and install the dependencies.cd hardhat npm install
This is the setup instructions for the smart contracts of this repository.
-
Compiling the contracts.
npx hardhat compile
-
Create a new Hardhat configuration variable for your wallet private key.
When prompted, enter the private key of the wallet you want to use to deploy the contract. It is strongly recommended to use a new wallet for this purpose.
npx hardhat vars set WALLET_PRIVATE_KEY
-
Run the deploy script to deploy the smart contract account factory and create a smart account via the factory.
Note: The
defaultNetwork
inside hardhat.config.ts is set toabstractTestnet
. You will need testnet ETH from a faucet in your wallet to deploy the contract to Abstract.npx hardhat deploy-zksync --script deploy-mycontract.ts npx hardhat deploy-zksync --script deploy-account.ts
-
Change directory into the
clients
folder.cd clients # or if you were in the hardhat folder cd ../clients
-
Install the dependencies.
npm install
-
Set your private key inside an environment variable.
cp .env.example .env
Replace the
PRIVATE_KEY
value with your wallet private key. -
Run the scripts
npm run run-ethers npm run run-viem