Build and deploy a smart contract wallet that can validate and execute transactions with arbitrary logic on Abstract.
-
Get a copy of the
smart-contract-accountsexample 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
-
Install dependencies.
yarn
-
Use Hardhat to run
yarn compileand compile theBasicAccountsmart contract.
To demo the code, deploy and submit a transaction from the smart contract wallet, by:
-
Compiling the contracts.
yarn 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 -
Deploy the
BasicAccountcontract.The
defaultNetworkinside hardhat.config.ts is set toabstractTestnet. You will need testnet ETH from a faucet in your wallet to deploy the contract to Abstract.yarn deploy
-
Take the outputted
Contract addressand paste it on line8of the interact.ts file:const CONTRACT_ADDRESS = "<your-deployed-contract-address-here>";
-
Interact with the deployed contract.
yarn interact
This will submit a transaction that originates from your deployed smart contract account.
-
Install the ZKsync CLI
yarn global add zksync-cli
-
For local development, ensure Docker is installed and running.
docker --version docker info
-
For local development, run an "In Memory node".
zksync-cli dev start
-
Set the hardhat default network to
inMemoryNodein hardhat.config.ts.defaultNetwork: "inMemoryNode",
-
Use the
RICH_WALLETSarray available in the utils.ts file to access accounts loaded with funds on the local node.