EthereumPrivateKeyProvider issue

Hey I’m using web3auth v 6.1.7 with Next.js 13.4 and I’m getting this error
TypeError: (0 , _toruslabs_openlogin_jrpc__WEBPACK_IMPORTED_MODULE_1__.providerFromEngine) is not a function

@roy Welcome Aboard!

For EVM chains use the EthereumPrivateKeyProvider from the @web3auth/ethereum-providerpackage. Please note thatEthereumPrivateKeyProviderrequireschainConfigas the config parameter at the time of initialization.

import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";

const chainConfig = {
  chainNamespace: CHAIN_NAMESPACES.EIP155,
  chainId: "0x1",
  rpcTarget: "https://rpc.ankr.com/eth",
  displayName: "Ethereum Mainnet",
  blockExplorer: "https://etherscan.io",
  ticker: "ETH",
  tickerName: "Ethereum",
};
const privateKeyProvider = new EthereumPrivateKeyProvider({ config: { chainConfig } });
const openloginAdapter = new OpenloginAdapter({
  privateKeyProvider,
});
web3authInstance.configureAdapter(openloginAdapter);

I still get the same error.
I’m using Safe’s AA SDK: Web3Auth - Developer Docs
This is my code:

  const privateKeyProvider = new EthereumPrivateKeyProvider({
    config: {
      chainConfig: {
        chainNamespace: CHAIN_NAMESPACES.EIP155,
        chainId: "0x5",
        // https://chainlist.org/
        rpcTarget: "https://rpc.ankr.com/eth_goerli",
        displayName: "Ethereum Goerli",
        blockExplorer: "https://goerli.etherscan.io",
        ticker: "ETH",
        tickerName: "Ethereum",
      },
    },
  });

  const openloginAdapter = new OpenloginAdapter({
    loginSettings: {
      mfaLevel: "mandatory",
    },
    adapterSettings: {
      uxMode: "popup",
      whiteLabel: {
        name: "Loya",
      },
    },
    privateKeyProvider,
  });

  const web3AuthModalPack = new Web3AuthModalPack(web3AuthConfig);

You can refer to this Safe example https://github.com/Web3Auth/web3auth-pnp-examples/tree/main/web-modal-sdk/account-abstraction/web3auth-safe-example

1 Like