Hi Natalia — thanks for the clear report. I pulled the important bits and wrote a few concrete things to try so the support team can help faster.
Summary of what you provided
- SDK / integration: MetaMask Embedded Wallets (Web3Auth)
- Packages & versions reported: @web3auth/modal v10.5.4, @web3auth/ethereum-provider v9.7.0 (you also mentioned previously using @web3auth/no-modal 9.7.0)
- Platform / framework: Vue 2
- Init code snippet: included (initializing EthereumPrivateKeyProvider with config: { chainConfig } and passing privateKeyProvider in Web3Auth options)
- Exact error: WalletInitializationError: “Invalid params passed in, Please provide a valid chainId as hex string in chains for chain 31”
- Provided chainId value in code: ‘0x1f’ (for chain 31)
Likely causes
- Web3Auth v10 expects the chain configuration to be provided on the Web3Auth constructor (chainConfig) rather than only inside the provider. If Web3Auth doesn’t see a valid chain config it runs a chains validation and throws this WalletInitializationError.
- Version mismatch between @web3auth/modal (v10.x) and @web3auth/ethereum-provider (v9.7.0) can cause breaking behavior. It’s best to align major versions when migrating (use v10-compatible @web3auth packages).
- Chain id formatting — it must be a hex string with 0x prefix (you have ‘0x1f’, which should be valid), but Web3Auth needs that exact value present on the Web3Auth constructor.
Recommended quick fixes to try
- Move chainConfig into the Web3Auth constructor (and also pass it to the privateKey provider). Example pattern:
const chainConfig = {
chainNamespace: CHAIN_NAMESPACES.EIP155,
chainId: chainIdValue, // “0x1f”
rpcTarget,
displayName,
blockExplorer,
ticker,
tickerName,
};
const web3AuthInstance = new Web3Auth({
clientId,
web3AuthNetwork: WEB3AUTH_NETWORK.MAINNET,
chainConfig, // ← important for v10
// other modal options if needed
});
const privateKeyProvider = new EthereumPrivateKeyProvider({
config: { chainConfig },
});
await web3AuthInstance.init();
-
Align package versions: upgrade @web3auth/ethereum-provider to a v10-compatible release (or use a consistent set of @web3auth packages that are tested together). Mismatched majors between modal (v10) and provider (v9) can cause unexpected initialization errors.
-
Double-check the chainId value at runtime to confirm it’s a string and not accidentally a number: console.log(typeof chainConfig.chainId, chainConfig.chainId) should print “string” and “0x1f”.
If this doesn’t fix it
- Please confirm the exact versions of all @web3auth packages in your package.json (so support can check compatibility). If you can, paste the package.json deps or a small list.
- Share the full initialization code (you already gave a good snippet — if there are other places you pass chain info to Web3Auth or modal config please include that).
- A console screenshot or full browser console logs around the error would help (you already pasted the stack trace which is helpful).
References
- Follow the v10 migration pattern: ensure chainConfig is supplied to the Web3Auth constructor and keep packages on compatible major versions.
If you want, I can draft the exact minimal changes to your file (with your variable names) so you can paste and run it — would you like that? Also let me know your exact @web3auth/* versions from package.json and I’ll check for any known incompatibilities.
Note: This response was generated by an AI bot and may require further verification. The MetaMask Community 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. MetaMask Developer Office Hours