Metamask abi error when connecting ethereum provider

Hello, I always get an error after running my project. How can I fix it?

I think it’s a problem with EthereumPrivateKeyProvider, because if I use SolanaPrivateKeyProvider, I don’t get this error…

const chainConfig = {
          chainNamespace: CHAIN_NAMESPACES.EIP155,
          chainId: "0x89", 
          rpcTarget: mainnetRpcUrl,
          displayName: "Polygon Mainnet",
          blockExplorerUrl: "https://polygonscan.com",
          ticker: "MATIC",
          tickerName: "Matic",
          logo: "https://web3auth.io/images/web3authlog.png",
        };
        const privateKeyProvider = new EthereumPrivateKeyProvider({
          config: {
            chainConfig,
          },
        });
"@web3auth/base": "8.6.2",
    "@web3auth/ethereum-provider":  "8.6.2",
    "@web3auth/no-modal":  "8.6.2",
    "@web3auth/openlogin-adapter":  "8.6.2",
    "@web3auth/solana-provider":  "8.6.2",

Error:

Cannot read properties of undefined (reading 'type')
TypeError: Cannot read properties of undefined (reading 'type')
    at http://localhost:3000/static/js/bundle.js:493685:42
    at Array.map (<anonymous>)
    at union (http://localhost:3000/static/js/bundle.js:493685:31)
    at ./node_modules/@metamask/abi-utils/dist/parsers/function.js (http://localhost:3000/static/js/bundle.js:51462:29)
    at options.factory (http://localhost:3000/static/js/bundle.js:498142:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:497526:32)
    at fn (http://localhost:3000/static/js/bundle.js:497800:21)
    at ./node_modules/@metamask/abi-utils/dist/parsers/index.js (http://localhost:3000/static/js/bundle.js:51589:14)
    at options.factory (http://localhost:3000/static/js/bundle.js:498142:31)
    at __webpack_require__ (http://localhost:3000/static/js/bundle.js:497526:32)

Looks like metamask/abi-utils package is missing. Can you delete your node modules, and package-lock.json. Once you have deleted, you can do

npm install

In case if the issue persist, you can install the package separately and check if it solves the issue.

npm i @metamask/abi-utils

Thanks for the quick reply, but it didn’t help me.

I tried to install @metamask/abi-utils in my project, but I still see the error.
``“@metamask/abi-utils”: “2.0.2”`

Also @metamask/abi-utils has @web3auth/ethereum-provider installed, I checked it:

yarn why @metamask/abi-utils
Found "@metamask/abi-utils@2.0.2"
info Reasons why this module exists
   - "@web3auth#ethereum-provider#@metamask#eth-sig-util" depends on it
   - Retrieved from "@web3auth#ethereum-provider#@metamask#eth-sig-util#@metamask#abi-utils"

I’ll try to reproduce this on my end, can you share your package.json file?

Hopefully this will help reproduce the error

{
  "name": "project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@solana/web3.js": "1.93.0",
    "@toruslabs/openlogin-ed25519": "7.0.0",
    "@types/node": "^16.7.13",
    "@types/react": "^18.0.0",
    "@web3auth/base": "8.6.2",
    "@web3auth/ethereum-provider": "8.6.2",
    "@web3auth/no-modal": "8.6.2",
    "@web3auth/openlogin-adapter": "8.6.2",
    "@web3auth/solana-provider": "8.6.2",
    "browserify-zlib": "^0.2.0",
    "customize-cra": "^1.0.0",
    "ethers": "^5.7.2",
    "flat": "^5.0.2",
]    "loglevel": "^1.8.1",
    "react": "^18.2.0",
    "uuid": "^9.0.0",
    "vm-browserify": "^1.1.2",
  },
  "scripts": {
    "start": "react-app-rewired start",
    "build": "GENERATE_SOURCEMAP=false react-app-rewired build"
  },
  "devDependencies": {
    "assert": "^2.0.0",
    "buffer": "^6.0.3",
    "crypto-browserify": "^3.12.0",
    "https-browserify": "^1.0.0",
    "os-browserify": "^0.3.0",
    "process": "^0.11.10",
    "react-app-rewired": "^2.2.1",
    "react-scripts": "^5.0.1",
    "stream-browserify": "^3.0.0",
    "stream-http": "^3.2.0",
    "url": "^0.11.1"
  }
}

I’m able to reproduce the issue, I’ll debug and get back to you.

Do you have any update?

Our team did some digging, it’s an issue from metamask library. We are still looking for fix meanwhile. We’ll keep you posted.

You can track the metamask issue here.

1 Like