Olubisi Idris Ayinde
Olanetsoft's Blog | Idris Olubisi

Follow

Olanetsoft's Blog | Idris Olubisi

Follow
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's photo
Olubisi Idris Ayinde
·Apr 24, 2022·

1 min read

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