Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Smart Contract Accounts Demo

Build and deploy a smart contract wallet that can validate and execute transactions with arbitrary logic on Abstract.

Local Development

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

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

    yarn
  3. Use Hardhat to run yarn compile and compile the BasicAccount smart contract.

Deploy & Use the Smart Contract Wallet

To demo the code, deploy and submit a transaction from the smart contract wallet, by:

  1. Compiling the contracts.

    yarn 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. Deploy the BasicAccount contract.

    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.

    yarn deploy
  4. Take the outputted Contract address and paste it on line 8 of the interact.ts file:

    const CONTRACT_ADDRESS = "<your-deployed-contract-address-here>";
  5. Interact with the deployed contract.

    yarn interact

    This will submit a transaction that originates from your deployed smart contract account.

Using a local node with Docker

  1. Install the ZKsync CLI

    yarn global add 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 array available in the utils.ts file to access accounts loaded with funds on the local node.

Useful Links