I am trying to query the balance of an address of a contract I deployed to a localhost and keep running into this error. I know in Js once you declare a const variable you cannot re declare it but in this instance I was not able to define the variable balance so how would I go about getting to where I want i.e attempting to run const balance = await ethers.provider.getBalance(accounts[0].address) ?

Any help would be very appreciated :)

enter image description here

2 Answers 2


Well you are not passing a valid address, like said in the error! [0] is not an address.

invalid addressor ENS name 'argument="name, value=[0], code=INVALID_ARGUMENT ...

Maybe refer to an array that holds the address you're looking for ? Also with ether.js you can define addresses on the local network like this:

const [owner, acc1, acc2, acc3] = await ethers.getSigners();

try changing it to:

let balance = await ethers.provider.getBalance(acc1.address)
  • Thanks Torof. Do you have any advice on the Syntax error? Even once changed to let balance = await ethers.provider.getBalance(acc1.address) as you suggested it still throws Uncaught SyntaxError: Identifier 'balance' has already been declared
    – Wattlebird
    Commented Nov 21, 2022 at 15:48

Try this, it might work

await provider.send("eth_requestAccounts", []);
const signer = provider.getSigner()

let balance = await signer.getBalance();
balance = ethers.utils.formatEther(balance)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.