Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Smart Contract Account Factory

Build a smart contract wallet factory that deploys smart contract accounts with an EOA (Externally Owned Account) set as the signer for each smart contract account on Abstract.

This example consists of two components:

  1. contracts - Solidity smart contracts in a Hardhat environment that define the smart contract account and factory.
  2. frontend - A simple frontend using Next.js and Viem to interact with the contracts.

Local Development

  1. Get a copy of the smart-contract-account-factory example directory from the Abstract Examples repository:

    mkdir -p smart-contract-account-factory && curl -L https://codeload.github.com/Abstract-Foundation/examples/tar.gz/main | tar -xz --strip=2 -C smart-contract-account-factory examples-main/smart-contract-account-factory && cd smart-contract-account-factory

Contract Development

  1. Change directory to the contracts folder.

    cd contracts
  2. Install dependencies

npm install
  1. Compiling the contracts.

    npx hardhat compile
  2. 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
  3. 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 to abstractTestnet. You will need testnet ETH from a faucet in your wallet to deploy the contract to Abstract.

    npx hardhat deploy-zksync --script deploy.ts

Frontend Development

  1. Change directory to the frontend folder.

    # if you are in the contracts folder
    cd ../frontend
    # Or, if you are in the root folder
    cd frontend
  2. Install the dependencies.

    npm install
  3. Start the frontend.

    npm run dev
  4. Open http://localhost:3000 in your browser.

Using a local node with Docker

To deploy onto a local node (instead of the Abstract testnet), follow the instructions below.

  1. Install the ZKsync CLI

    npm install -g zksync-cli
  2. For local development, ensure Docker is installed and running.

    docker --version
    docker info
  3. For local development, run an "In Memory node".

    zksync-cli dev start
  4. Set the hardhat default network to inMemoryNode in hardhat.config.ts.

    defaultNetwork: "inMemoryNode",
  5. Use the rich wallets to access accounts loaded with funds on the local node.

Useful Links