Thanks for sharing the details, Daniel! You’re migrating from Web3Auth v9 to v10 using the Plug and Play (PnP) Web SDK and want to set a custom RPC, but are running into two main issues:
chainNamespace issue
initModal is not a valid function in Web3Auth v10
Here’s a breakdown of what’s happening and how you can address it:
1. chainNamespace Issue
In v10, the SDK has introduced some breaking changes in how you configure chains and RPCs.
The chains configuration is now passed as an array, and the structure has changed.
The chainNamespace key is still used, but the way you define the chain and custom RPC is different.
v10 Example for Solana with Custom RPC:
import { Web3Auth } from "@web3auth/modal";
import { CHAIN_NAMESPACES } from "@web3auth/base";
const web3auth = new Web3Auth({
clientId: vars.clientId,
web3AuthNetwork: "mainnet",
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.SOLANA,
chainId: "0x1", // Solana mainnet chainId in hex
rpcTarget: vars.rpcTarget, // Your custom RPC endpoint
},
});
Make sure to use the correct chainId for Solana. For Solana, you can use "0x1" as a placeholder, but it’s mostly the chainNamespace and rpcTarget that matter.
Double-check your chainConfig values, especially chainNamespace and rpcTarget.
If you run into any more errors, please share the specific error messages and your updated code snippet. If possible, a screenshot of your console error would also help!
Let me know if this helps or if you have any other questions!
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
const web3auth = new Web3Auth({
clientId: vars.clientId,
web3AuthNetwork: "mainnet",
chainConfig: {
chainNamespace: CHAIN_NAMESPACES.SOLANA,
chainId: "0x1", // Solana mainnet chainId in hex
rpcTarget: vars.rpcTarget, // Your custom RPC endpoint
},
});
But im getting this error: Property ‘privateKeyProvider’ is missing in type ‘{ clientId: string; web3AuthNetwork: “sapphire_devnet”; chainConfig: { chainNamespace: “solana”; chainId: string; rpcTarget: string; }; }’ but required in type 'Web3AuthOptions
Also, im trying to join the discord, but im getting invite invalid
Hey @danieljao
You don’t need to configure any RPC or chains in the code. All of it can be done via the dashboard.
Please join the office hours on Thursday, I can assist you well in setting this up.
Hi @maharshi thank you for answering my questions in the call yesterday.
updates:
I did the npm clear cache and the web3auth/modal did install and no errors in IDE → good sign
now when i start the app in dev mode via npm, this is where i got a new error, specifically:
ERROR
codecs_1.getBytesCodec is not a function
./node_modules/@solana/spl-token-metadata/lib/cjs/state.js@http://localhost:3000/static/js/bundle.js:192380:132
options.factory@http://localhost:3000/static/js/bundle.js:534527:30
__webpack_require__@http://localhost:3000/static/js/bundle.js:533877:32
fn@http://localhost:3000/static/js/bundle.js:534143:21
hotRequire@http://localhost:3000/static/js/bundle.js:534510:61
./node_modules/@solana/spl-token-metadata/lib/cjs/index.js@http://localhost:3000/static/js/bundle.js:192186:14
options.factory@http://localhost:3000/static/js/bundle.js:534527:30
__webpack_require__@http://localhost:3000/static/js/bundle.js:533877:32
fn@http://localhost:3000/static/js/bundle.js:534143:21