3

On my frontend, I am calling a function that requests users to sign into their metamask and retrieve the address of their account:

  const accounts = await window.ethereum.request({
    method: "eth_requestAccounts",
  });

However, it returns the address in all-lower-case form. I know that transactions will still pass but I want the address to be identical to the one in metamask. Is there any way to fetch it?

1 Answer 1

1

You can convert the address with ethersjs function

const currentAccount = await ethers.utils.getAddress(accounts[0])

it will return the right address identical with metamask see https://docs.ethers.io/v5/api/utils/address/#utils-getAddress

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.