Migration to 10.x from 9.x

I used to have

{
    "@toruslabs/eccrypto": "^6.0.0",
    "@web3auth/auth-adapter": "^9.5.2",
    "@web3auth/base": "^9.5.2",
    "@web3auth/base-provider": "^9.5.2",
    "@web3auth/no-modal": "^9.5.2",
}

Now I have upgrading to

{
"@web3auth/modal": "^10.3.0",
}

I used to get appPubkey using @toruslabs/eccrypto like this in previous version

const privateKey = await provider.request({ method: "private_key" });
const appPubKey = getPublicCompressed(window.Buffer.from(privateKey.padStart(64, "0"), "hex")).toString("hex");

I want to know is there any changes to this in latest verson?

Also an issue, when I logout using disconnect I had to reload to login again, because MFA is not loading correctly if I don’t reload the page.

    const { disconnect } = useWeb3AuthDisconnect();

Here’s a summary of your migration scenario and guidance for getting the appPubKey/privateKey in Web3Auth v10:


User Context

  • Previous SDKs (v9.x):

    • @web3auth/auth-adapter v9.5.2
    • @web3auth/base v9.5.2
    • @web3auth/base-provider v9.5.2
    • @web3auth/no-modal v9.5.2
    • @toruslabs/eccrypto ^6.0.0
  • Current SDK (v10.x):

    • @web3auth/modal ^10.3.0
  • Platform: Web (assumed from SDKs)

  • Previous Method to Get appPubKey:

    const privateKey = await provider.request({ method: "private_key" });
    const appPubKey = getPublicCompressed(window.Buffer.from(privateKey.padStart(64, "0"), "hex")).toString("hex");
    
  • Key Question:
    Is there any change in how to obtain the appPubKey/privateKey with the latest v10 SDK?


Migration Details & Solution

1. Private Key Access in v10

  • In v9, you accessed the private key via the provider’s request({ method: "private_key" }).
  • In v10, the unified SDK (@web3auth/modal) manages providers internally, and the method to access the private key is slightly different.

To get the private key in v10:

const privateKey = await web3auth.provider?.request({ method: "private_key" });
  • The rest of your logic to derive the appPubKey from the private key remains the same.

2. Notes on v10 Changes

  • The provider is now accessed as web3auth.provider after a successful login.
  • You do not need to manually set up privateKeyProvider or chainConfig for standard EVM chains; these are managed via the Web3Auth Dashboard.
  • The method to get the private key is still available for EVM chains, but always ensure you’re using the correct provider object from the new SDK instance.

3. Documentation Reference

4. Example for v10

import { Web3Auth } from "@web3auth/modal";

// ...initialize and login with web3auth...

const privateKey = await web3auth.provider?.request({ method: "private_key" });
// Use your existing logic to get the compressed public key
const appPubKey = getPublicCompressed(window.Buffer.from(privateKey.padStart(64, "0"), "hex")).toString("hex");

Summary

  • The way to obtain the private key and derive the appPubKey is almost the same, but ensure you’re using web3auth.provider after login in v10.
  • No major change to your logic for generating the public key from the private key.

If you run into any issues with the provider or private key access, please share your initialization and login code snippet, and any error messages you receive.

Let us know if you need further clarification or run into any issues!

Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. Web3Auth Developer Office Hours

@w3abot

So I can use @toruslabs/eccrypto as it is?

Also an issue, when I logout using disconnect I had to reload to login again, because MFA is not loading correctly if I don’t reload the page.

    const { disconnect } = useWeb3AuthDisconnect();