> ## Documentation Index
> Fetch the complete documentation index at: https://docs.chainstack.com/llms.txt
> Use this file to discover all available pages before exploring further.

# zkSync Era tooling

> zkSync Era development tools guide. Use zksync-ethers SDK, Hardhat, MetaMask, ethers.js, and Remix IDE with Chainstack zkSync Era nodes.

Get started with a [reliable zkSync Era RPC endpoint](https://chainstack.com/build-better-with-zksync-era/) to use the tools below.

## Interaction tools

### MetaMask

On [node access details](https://docs.chainstack.com/docs/manage-your-node.md#view-node-access-and-credentials), click **Connect wallet**.

## Development tools

> [!NOTE]
>
> ZKsync Era runs standard EVM bytecode through its [EVM Bytecode Interpreter](https://docs.zksync.io/zksync-network/zksync-era/unique-features#evm-bytecode-interpreter), so for most new projects you can use standard Ethereum tooling — Hardhat, Foundry, ethers, or viem — pointed at your Chainstack ZKsync Era endpoint, exactly like any other EVM chain. The EraVM-native workflow below (the `hardhat-zksync` plugin suite with the `zksolc` compiler) remains for contracts that target EraVM directly.

### zksync-ethers SDK

See [zksync-ethers](https://github.com/zksync-sdk/zksync-ethers).

### Hardhat (EraVM-native)

To compile and deploy contracts that target EraVM natively, use the [hardhat-zksync](https://github.com/matter-labs/hardhat-zksync) plugin suite with Hardhat 2. ZKsync lists the suite as [legacy tooling](https://docs.zksync.io/zksync-network/zksync-era/custom-tooling). For standard EVM contracts, use a normal Hardhat setup pointed at your Chainstack endpoint instead (see the note above).

1. Install Hardhat 2, the plugin suite, and TypeScript 5:

   ```shell Shell theme={"system"}
   npm install --save-dev hardhat@^2.22.5 @matterlabs/hardhat-zksync@^1.6.1 zksync-ethers@^6.21.2 ethers@^6.17.0 typescript@^5.9.3 ts-node@^10.9.2 @types/node@^22 dotenv@^17
   ```

   Hardhat 3 does not load the `hardhat-zksync` plugins. Hardhat 2 loads `hardhat.config.ts` through `ts-node`, which does not work with TypeScript 7, and needs a `tsconfig.json` in the project root — see the [paymaster tutorial](https://docs.chainstack.com/docs/zksync-tutorial-develop-a-custom-paymaster-contract.md#setup-the-project-and-install-the-required-dependencies) for one.

2. Create a new environment in `hardhat.config.ts`. The config reads your Chainstack zkSync Era Sepolia endpoint from the `ZKSYNC_TESTNET_CHAINSTACK` variable in a `.env` file:

```typescript hardhat.config.ts theme={"system"}
import { HardhatUserConfig } from "hardhat/config";
import "@matterlabs/hardhat-zksync";
import "dotenv/config";

const config: HardhatUserConfig = {
  zksolc: {
    version: "1.5.18",
    settings: {
      codegen: "yul",
    },
  },
  defaultNetwork: "zkSyncSepolia",
  networks: {
    hardhat: {
      zksync: true,
    },
    zkSyncSepolia: {
      url: process.env.ZKSYNC_TESTNET_CHAINSTACK ?? "",
      ethNetwork: "sepolia",
      zksync: true,
      verifyURL:
        "https://explorer.sepolia.era.zksync.dev/contract_verification",
    },
  },
  solidity: {
    version: "0.8.28",
  },
};

export default config;
```

> [!NOTE]
>
> Follow the tutorial for a better understanding: [zkSync Era∎: Develop a custom paymaster contract](https://docs.chainstack.com/docs/zksync-tutorial-develop-a-custom-paymaster-contract.md)

### web3.py

Build DApps using [web3.py](https://github.com/ethereum/web3.py) and zkSync Era nodes deployed with Chainstack.

1. Install [web3.py](https://web3py.readthedocs.io/).

2. Connect over HTTP or WebSocket. See also [EVM node connection: HTTP vs WebSocket](https://support.chainstack.com/hc/en-us/articles/900002187586-Ethereum-node-connection-HTTP-vs-WebSocket).

#### HTTPS

Use `HTTPProvider` to connect to your node endpoint and get the latest block number.

```py Key Protected theme={"system"}
from web3 import Web3

web3 = Web3(Web3.HTTPProvider('YOUR_CHAINSTACK_ENDPOINT'))
print(web3.eth.block_number)
```

```py Password Protected theme={"system"}
from web3 import Web3

web3 = Web3(Web3.HTTPProvider('https://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME")))
print(web3.eth.block_number)
```

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node HTTPS endpoint protected either with the key or password
* HOSTNAME — your node HTTPS endpoint hostname
* USERNAME — your node access username (for password-protected endpoints)
* PASSWORD — your node access password (for password-protected endpoints)

#### WSS

Use `AsyncWeb3` with the `WebSocketProvider` object to connect to your node WSS endpoint and get the latest block number. The web3.py WebSocket provider is asynchronous, so the example runs in an `asyncio` event loop.

```py Key Protected theme={"system"}
import asyncio
from web3 import AsyncWeb3, WebSocketProvider

async def main():
    async with AsyncWeb3(WebSocketProvider('YOUR_CHAINSTACK_ENDPOINT')) as web3:
        print(await web3.eth.block_number)

asyncio.run(main())
```

```py Password Protected theme={"system"}
import asyncio
from web3 import AsyncWeb3, WebSocketProvider

async def main():
    async with AsyncWeb3(WebSocketProvider('wss://%s:%s@%s'% ("USERNAME", "PASSWORD", "HOSTNAME"))) as web3:
        print(await web3.eth.block_number)

asyncio.run(main())
```

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node WSS endpoint protected either with the key or password
* HOSTNAME — your node WSS endpoint hostname
* USERNAME — your node access username (for password-protected endpoints)
* PASSWORD — your node access password (for password-protected endpoints)

See also [WebSocket connection to an EVM node](https://support.chainstack.com/hc/en-us/articles/900001918763-WebSocket-connection-to-an-Ethereum-node).

### node.js

You can build a web app to query data using node.js and [axios](https://www.npmjs.com/package/axios):

```js Javascript theme={"system"}
const axios = require("axios");

const payload = {
    jsonrpc: "2.0",
    id: 0,
    method: "eth_blockNumber",
    params: []

};

(async () => {
    const response = await axios.post(`YOUR_CHAINSTACK_ENDPOINT`, payload)
    console.log(response.data)
})();
```

* YOUR\_CHAINSTACK\_ENDPOINT — your Chainstack node endpoint protected either with the key or password. See node access details.
* `query` — your JSON-RPC query. In this case, to get the latest block number.

### ethers.js

Build DApps using [ethers.js](https://github.com/ethers-io/ethers.js/) and zkSync Era nodes deployed with Chainstack.

1. Install [ethers.js](https://www.npmjs.com/package/ethers).

2. Connect over HTTPS or WebSocket. See also [EVM node connection: HTTP vs WebSocket](https://support.chainstack.com/hc/en-us/articles/900002187586-Ethereum-node-connection-HTTP-vs-WebSocket).

#### HTTPS

Use the `JsonRpcProvider` object to connect to your node endpoint and get the balance of any address:

```js Javascript theme={"system"}
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.JsonRpcProvider(NODE_URL, NETWORK_ID);
const eth_getBalance = async () => {
    const balance = await provider.getBalance("0x439356Ad40D2f2961c99FFED4453f482AEC453Af");
    console.log(balance);
  };
eth_getBalance()
```

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node HTTPS endpoint protected either with the key or password

* NETWORK\_ID — zkSync Era network ID:

  * Mainnet: `324`
  * Sepolia Testnet:`300`

#### WebSocket

Use the `WebSocketProvider` object to connect to your node WSS endpoint and get the latest block number:

```js Javascript theme={"system"}
const ethers = require('ethers');
const NODE_URL = "YOUR_CHAINSTACK_ENDPOINT";
const provider = new ethers.WebSocketProvider(NODE_URL, NETWORK_ID);
const eth_getBalance = async () => {
    const balance = await provider.getBalance("0x439356Ad40D2f2961c99FFED4453f482AEC453Af");
    console.log(balance);
  };
eth_getBalance()
```

where

* YOUR\_CHAINSTACK\_ENDPOINT — your node WSS endpoint protected either with the key or password

* NETWORK\_ID — zkSync Era network ID:

  * Mainnet: `324`
  * Sepolia Testnet:`300`

### Remix IDE

To make Remix IDE interact with the network through a zkSync Era node deployed with Chainstack:

1. Get [MetaMask](https://metamask.io/) and set it to interact through a Chainstack node. See [Interacting through MetaMask](#metamask).

2. In Remix IDE, navigate to the **Deploy** tab. Select **Injected Provider - MetaMask** in **Environment**.

This will engage MetaMask and make Remix IDE interact with the network through a Chainstack node.
