How to Fix unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.6.4)

Photo by Elisa Ventur on Unsplash

How to Fix unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.6.4)

Olubisi Idris Ayinde
ยทApr 24, 2022ยท

1 min read

Subscribe to my newsletter and never miss my upcoming articles

Play this article

Table of contents

  • Problem
  • How to Fix it
  • Example
  • Conclusion

gm! It's a bug fix.

When I was trying to get records from the blockchain, I got an error, and I was worried that I wouldn't be able to read data from the chain into my decentralized app without connecting my wallet.

How did I resolve this problem? ๐Ÿ‘‡

Problem

I get this error unknown account #0 (operation="getAddress", code=UNSUPPORTED_OPERATION, version=providers/5.6.4) when i try to read data without connecting my wallet.

How to Fix it

After reaching out, Joshua Adesanya and I figured out an address is needed to make such a request as it can't be empty.

Adding a wallet address inside getSigner("any address") fixed it.

It can either be your wallet address or a random wallet address. You can get a random(fake) wallet address here.

Example

import ContractAbi from "./yourContract.json";
import { ethers } from "ethers";

const provider = new ethers.providers.Web3Provider(window.ethereum);

const signer = provider.getSigner("RANDOM_WALLET_ADDRESS"); // Add a random wallet address here

const contract = new ethers.Contract(
    "CONTRACT_ADDRESS_HERE",
    ContractAbi.abi,
    signer
  );

Conclusion

It takes a couple of hours to resolve this issue; I hope you will fix it in less than 5 minutes.

Kindly Like and share with others. ๐Ÿ˜Š

I'd love to connect with you at Twitter | LinkedIn | GitHub

See you in my next blog article. Take care!!!

ย 
Share this

Impressum

Thank you for taking the time to read my blog. Please consider sponsoring or buying me a coffee if you've read some of my articles and want to show your support.

I'd also love to connect with you at Twitter | LinkedIn | GitHub

Check out these other amazing blogs! ๐Ÿ”ฅ

Didi's Blog | Catalin's Tech | Daily Dev Tips | Greenroots Blog | Lo-Victoria | Marko Denic