To best utilize the features of Abstract, it is recommended to use zksync-ethers library alongside ethers.

1. Create a new project

Create a new directory and change directory into it.

mkdir my-abstract-app && cd my-abstract-app

Initialize a new Node.js project.

npm init -y

Install the zksync-ethers and ethers libraries.

npm install zksync-ethers@6 ethers@6

2. Connect to Abstract

import { Provider, Wallet } from "zksync-ethers";
import { ethers } from "ethers";

// Read data from a provider
const provider = new Provider("https://api.testnet.abs.xyz");
const blockNumber = await provider.getBlockNumber();

// Submit transactions from a wallet
const wallet = new Wallet(ethers.Wallet.createRandom().privateKey, provider);
const tx = await wallet.sendTransaction({
  to: wallet.getAddress(),
});

Learn more about the features of zksync-ethers in the official documentation: