0

Trying to pass the connected wallet address into one of my view functions, but cannot get the address from the JSON object is there something I am missing here? Using wagmi to get signer from the connected wallet and I see the correct wallet showing in JsonRpcSigner JSON format in the browser console. I cannot pass signer, or signer[_address], or signer.address, or signer[0,1] through to viewProfileStrings(signer) function:

import { useContractRead, useContract, useSigner } from "wagmi";
const { data: signer, isError, isLoading } = useSigner();
console.log("here is the ", signer);

(async () => {
    const function_return = await myContract.methods
   .viewProfileStrings(signer)
      .call();
    console.log("info 1 attempt", function_return[0]);
    setInfo(function_return[0]);
    return function_return;
  })();

correct wallet address console.log from the browser

1 Answer 1

0

This is how I solved it!

  const [finalAddress, setAddress] = useState("");

  const { data: signer, isError, isLoading } = useSigner();

  (async () => {
    const finaladdressusestate = await signer.getAddress();
    setAddress(finaladdressusestate);
  })();

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.