How to get wallet address after Login with Firebase custom authenticator

I am building on the MPC Core kit SDK. I have set up a custom authenticator and immediately after a successful login to the authenticator, I have taken the returned JWT Token, extracted some information from it and composed an object that implements interface IdTokenLoginParams. I have then passed this object to the loginWithJWT() method. The call to loginWithJWT() has been successful as I can see an increase in the number of login requests in my timeline. How can I now get a public address for the user’s Wallet that has been created on Web3Auth?

@bruno1 Welcome Aboard!

Your request has been forwarded to our team and we will get back with further updates.

This method is used to fetch the address of the connected account.

const getAccounts = async () => {
  if (!provider) {
    console.log("provider not initialized yet");
    return;
  }
  const web3 = new Web3(provider as any);
  const userAccounts = await web3.eth.getAccounts();
  console.log(userAccounts);
};

You can refer to the guide for Firebase:

Thanks for the response. I have tried your suggested approach like so:

export default function SignIn() {
  const [email, setEmail] = useState("");
  const [password, setPassword] = useState("");
  const [user, setUser] = useState({});
  const [provider, setProvider] = useState<SafeEventEmitterProvider | null>(
    null
  );
  const [coreKitStatus, setCoreKitStatus] = useState<COREKIT_STATUS>(
    COREKIT_STATUS.NOT_INITIALIZED
  );
  const [web3, setWeb3] = useState<any>(undefined);

  useEffect(() => {
    const init = async () => {
      await coreKitInstance.init();
      if (coreKitInstance.provider) {
        console.log("coreKitInstance Provider: ", coreKitInstance.provider);
        setProvider(coreKitInstance.provider);
      }
      setCoreKitStatus(coreKitInstance.status);
    };
    init();
  }, []);

  useEffect(() => {
    if (!provider) {
      alert("Provider not initilaized yet!");
    }
    const web3 = new Web3(provider as any);
    setWeb3(web3);
  }, [provider]);

However, when trying to use it, I get this error:-

Provider not available. Use `.setProvider` or `.provider=` to initialize the provider.
ProviderError: Provider not available. Use `.setProvider` or `.provider=` to initialize the provider.
    at Web3RequestManager.<anonymous> (http://localhost:3001/static/js/bundle.js:212749:15)
    at Generator.next (<anonymous>)
    at http://localhost:3001/static/js/bundle.js:212638:67
    at new Promise (<anonymous>)
    at __awaiter (http://localhost:3001/static/js/bundle.js:212620:10)
    at Web3RequestManager._sendRequest (http://localhost:3001/static/js/bundle.js:212744:12)
    at Web3RequestManager.<anonymous> (http://localhost:3001/static/js/bundle.js:212725:35)
    at Generator.next (<anonymous>)
    at http://localhost:3001/static/js/bundle.js:212638:67
    at new Promise (<anonymous>)

How can I resolve this error?

Your issue has been forwarded to our Dev team and we will get back with further updates.

hello @bruno1
can you let us know your mpc core kit sdk version?

Hello @pepper. I’m using @web3auth/mpc-core-kit version 1.1.2

thanks @bruno1
and can you also share your loginwithJWT implementation?
is loginwithJWT works to you?

Here’s my current loginWithJWT() implementation:

  async function handleSubmit(e: React.FormEvent) {
    e.preventDefault();
    const loggedInUser = await firebaseSerive.loginWithEmailAndPassword(
      email,
      password
    );
    const userIdToken = await loggedInUser.getIdToken(true);
    const parsedToken = parseToken(userIdToken);
    const idTokenLoginParams: IdTokenLoginParams = {
      verifier: "web3auth-firebase-demo-oyugo",
      verifierId: parsedToken.sub!,
      idToken: userIdToken,
    };
    coreKitInstance.loginWithJWT(idTokenLoginParams);
    const userInfo = coreKitInstance.getUserInfo();
    const userAccounts = await web3.eth.getAccounts();
  }

thanks. we will get back with the solution as soon as possible.

Hello @bruno1
I have tried to reproduce your bug, but was unable to reproduce it.
check our examples, which are working fine.