zksync-sdk / zksync2-js

MIT License
25 stars 29 forks source link

Error: an ENS name used for a contract target must be correctly configured (value="", code=UNCONFIGURED_NAME, version=6.8.1) #22

Closed herryho closed 10 months ago

herryho commented 10 months ago

🐛 Bug Report for zksync2-js JavaScript SDK

📝 Description

Provide a clear and concise description of the bug.

When I create a wallet, and try to get the balance of my zkwallet, it throws "Error: an ENS name used for a contract target must be correctly configured (value="", code=UNCONFIGURED_NAME, version=6.8.1)".

🔄 Reproduction Steps

import { ethers } from 'ethers';
import { Provider, Wallet } from 'zksync2-js';

const ethProvider = new ethers.JsonRpcProvider(ETH_ENDPOINT);
const zkProvider = new Provider('https://mainnet.era.zksync.io');

    const zkWallet = await new Wallet(
      privateKey,
      this.zksyncProvider,
      this.ethersProvider,
    );

// it is this line where the error was thrown.
await zkWallet.getBalance(utils.ETH_ADDRESS);

🤔 Expected Behavior

To get the ETH balance of my zkWallet

😯 Current Behavior

Throws Error: an ENS name used for a contract target must be correctly configured (value="", code=UNCONFIGURED_NAME, version=6.8.1)

🖥️ Environment

danijelTxFusion commented 10 months ago

I guess that problem is related to ETH_ENDPOINT and that's why throws the ENS error. I have just tested it on mainnet and works correctly.

const provider = Provider.getDefaultProvider(types.Network.Mainnet);
const ethProvider = ethers.getDefaultProvider("mainnet");
const PUBLIC_KEY = "0x082b1BB53fE43810f646dDd71AA2AB201b4C6b04"; 
const PRIVATE_KEY =  process.env.PRIVATE_KEY;

const wallet = new Wallet(PRIVATE_KEY, provider, ethProvider);
console.log(`Balance: ${await wallet.getBalance()}`);

Output:

Balance: 43927295500000000
herryho commented 9 months ago

Problem solved. Thanks a lot!