Web3JS

RPC Methods

Use the Web3.js plugin for ZKsync to interact with the JSON-RPC API for ZKsync Era

The Web3.js plugin for ZKsync implements the ZKsync Era JSON-RPC API.

RPC methods

The ZKsync Era JSON-RPC API is implemented by the RpcMethods class, which is exposed by the ZKsyncPlugin.rpc property.

import { Web3 } from "web3";
import { ZKsyncPlugin } from "web3-plugin-zksync";

async function main() {
  const web3: Web3 = new Web3(/* optional L1 provider */);
  web3.registerPlugin(new ZKsyncPlugin("https://sepolia.era.zksync.dev"));
  const zksync: ZKsyncPlugin = web3.ZKsync;

  console.log(
    "Testnet paymaster address:",
    await zksync.rpc.getTestnetPaymasterAddress(),
  );
}

main()
  .then(() => console.log("✅ Script executed successfully"))
  .catch((error) => console.error(`❌ Error executing script: ${error}`));

Made with ❤️ by the ZKsync Community