Private key issue for solana - react native integration

Hello , I was using RN-BARE-REACT-NATIVE example and i was able to get user account(public address) , user balance , sign the transaction .
But I am not able to get the private key string
Can You please tell me how to get this?

As You can see i am not even getting any function like getPrivatekey() .

Hi Himanshu,

Thanks for reaching out! It looks like you’re working with the Web3Auth PnP React Native SDK and are facing issues retrieving the private key string for your Solana integration.

In your case, you should be able to retrieve the private key using the getPrivateKey method provided by the Web3Auth SDK. Here’s a basic overview of how you might access the private key:

const privateKey = await web3authInstance.provider.request({
  method: "eth_private_key"
});
  1. Ensure you’re logged in: Before accessing the private key, make sure the user is logged in to the Web3Auth provider.

  2. Check for method availability: If getPrivateKey or similar methods are not directly visible, it’s possible they are accessed under a different method name or via a promise.

  3. Refer to Documentation and Examples: I recommend checking out the Web3Auth Documentation to ensure you are following the correct setup steps. There’s also an example on the Web3Auth Community Forum which might be helpful.

Since your screenshot and text seem to indicate there might be an issue with method visibility, ensure you’ve imported and initialized everything correctly. Try updating the SDK to its latest version to benefit from potential bug fixes and improvements.

If you’re still having trouble, could you please share any snippets of your initialization and login code? That might help in identifying any specific issues.

Let me know how it goes or if you need further assistance! :blush:

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

Hey @hmshekhar04,

The reason you’re not seeing getPrivateKey is likely because your current RPC implementation doesn’t include that method — and the RN-BARE-REACT-NATIVE example uses EthereumPrivateKeyProvider, which gives you an EVM-compatible private key, not Solana.

Since you’re working with Solana, I’d recommend trying out our React Native Solana example, which already uses SolanaPrivateKeyProvider.

If you’re writing your own RPC class or editing the existing one, make sure to add the following method:

getPrivateKey = async (): Promise<string> => {
  const privateKey = await this.provider.request({
    method: "solanaPrivateKey",
  });

  return privateKey as string;
};