Modal not working with Tron

I am creating a webapp to interface with Ethereum and Tron. I am using the modal signin with next.js. The modal works fine with Ethereum, but when following the guide to integrating Tron (Integrate Web3Auth with the Tron Blockchain in JavaScript | Documentation | Web3Auth), I get the following error:

“WalletInitializationError: Invalid params passed in, privateKeyProvider is required”

when initializing Web3Auth:

const web3auth = new Web3Auth({
clientId,
chainConfig: {
chainNamespace: “other”,
chainId: “0x2b6653dc”,
displayName: “Tron Mainnet”,
ticker: “TRX”,
tickerName: “Tron”,
rpcTarget: “https://api.trongrid.io”,
}
});

I think the docs might be for an older version of Web3Auth. Any help on how to use web3auth with Tron would be greatly appreciated.

Hi admin@whiterock.fi!

Thank you for reaching out! It sounds like you’re encountering an issue with initializing Web3Auth for Tron integration. Let’s try to sort this out step by step.

Issue Analysis:

The error message WalletInitializationError: Invalid params passed in, privateKeyProvider is required suggests that there might be missing parameters or possibly outdated documentation.

Proposed Solution:

It looks like the key issue might be with the chainNamespace value you’re using, as Tron might have different requirements in the latest SDK versions. Here’s a possible updated snippet which adds the privateKeyProvider:

const web3auth = new Web3Auth({
  clientId,
  chainConfig: {
    chainNamespace: "non-evm", // This helps Web3Auth recognize Tron
    chainId: "0x2b6653dc",
    displayName: "Tron Mainnet",
    ticker: "TRX",
    tickerName: "Tron",
    rpcTarget: "https://api.trongrid.io",
    privateKeyProvider: /* Tron-specific provider */
  }
});

Questions/Checks:

  1. SDK Version: Could you verify the version of Web3Auth SDK you’re using? If not mentioned, the support team might need to know.
  2. Code Snippet: Ensure your initialization code is complete, including any Tron-specific settings.
  3. Documentation Link: You’ve mentioned following a particular guide. Note that some settings or parameters might have changed in newer versions.

Next Steps:

  • Double-check if privateKeyProvider is properly set up for Tron as per the new guidelines.
  • Make sure your SDK version correlates with the documented example.

Additional Help:

Could you please share:

  • The complete code snippet of your Web3Auth initialization and login logic?
  • Screenshot of your browser console where the error appears.

This will help us further diagnose and solve the issue.

This response was generated by the Web3Auth Bot. A person from the Web3Auth team will also review and provide a more detailed answer.

Looking forward to your reply!

Thanks for pointing that out, @whiterock. The privateKey provider was missing in the constructor for the Tron connect blockchain. I’ve corrected it and pushed the changes. You can check out the working no modal example here: Tron No Modal Example.

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.