zksync-sdk / zksync2-js

MIT License
25 stars 29 forks source link

Incorrect Default Provider for zkSync Era SDK #41

Open samui68400 opened 7 months ago

samui68400 commented 7 months ago

Description:

The current default provider in the example code connects to the Goerli testnet, which gonna be deprecated. The zkSync Era is using the Sepolia network, and the example should reflect this change.

Steps to Reproduce:

Use the provided example code. Observe that it connects to the Goerli testnet instead of Sepolia.

Expected Behavior: The example code should connect to the Sepolia network, which is the zkSync Era testnet.

Actual Behavior: The code connects to the Goerli testnet.

Code Snippet:

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

async function getLatestBlockNumber() {
    try {
        const provider = Provider.getDefaultProvider(types.Network.Goerli); // Incorrect: connects to Goerli
        const ethProvider = ethers.getDefaultProvider("goerli"); // Incorrect: connects to Goerli

        // Get the latest block number
        const blockNumber = await provider.getBlockNumber();

        console.log("Latest block number:", blockNumber);
    } catch (error) {
        console.error("Error:", error.message);
    }
}

// Call the function
getLatestBlockNumber();

Proposed Solution: Update the default providers in the example code to connect to the Sepolia network.