# \[Archive\] TypeError: Cannot read properties of undefined (reading 'init')

**URL:** <https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [September 14, 2023, 11:01am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785 "2023-09-14T11:01:19Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![limbachiyachintan500](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@limbachiyachintan500](https://builder.metamask.io/u/limbachiyachintan500)\
**Post date:** [September 14, 2023, 11:01am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785/1 "2023-09-14T11:01:19Z")

</div>

> **🏛 Archived Content from Web3Auth Community**
> 
> This topic was originally posted by **limbachiyachintan500** on 9/14/2023.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

How to solve this error  
 ![image](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/2X/0/010e3d8da2f8e5a128c20c8d79d7fb6012074334.png)

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [September 15, 2023, 3:27am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785/2 "2023-09-15T03:27:17Z")

</div>

@limbachiyachintan500 Thanks for your recent post.

Is this for React or Reactnative? Can you share the implmentation code and which example from our repository are you following for your code?

---

<div class="post-metadata">

**Author:** ![limbachiyachintan500](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@limbachiyachintan500](https://builder.metamask.io/u/limbachiyachintan500)\
**Post date:** [September 15, 2023, 8:31am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785/3 "2023-09-15T08:31:46Z")

</div>

```auto
import { useQuery } from "@tanstack/react-query"
import { ECDSAProvider, getRPCProviderOwner } from "@zerodevapp/sdk"
import { formatEther } from "viem"

import { useWeb3AuthSigner } from "~/context/web3-auth-signer"
import { env } from "~/env.mjs"
import { alchemy } from "~/utils/alchemy"

const WETH_TOKEN_ADDRESS = "0xF54e919cDB1Eb2C2df9F73555c6BbDB26F797fcf"

export default function useWallet() {
  const { web3AuthSigner, accountAddress, setAccountAddress } =
    useWeb3AuthSigner()

  const data = useQuery({
    queryKey: ["wallet"],
    queryFn: async () => {
      let address = accountAddress
      if (address === undefined) {
        const ecdsaProvider = await ECDSAProvider.init({
          projectId: env.NEXT_PUBLIC_ZERODEV_PROJECT_ID,
          owner: getRPCProviderOwner(web3AuthSigner),
        })

        address = await ecdsaProvider.getAddress()
        setAccountAddress(address)
        console.log("address-->", address)
      }

      // Get balances
      const [rawMaticBalance, tokenBalances] = await Promise.all([
        alchemy.core.getBalance(address),
        alchemy.core.getTokensForOwner(address, {
          contractAddresses: [WETH_TOKEN_ADDRESS],
        }),
      ])

      const rawWethBalance =
        tokenBalances.tokens.find(
          (token) => token.contractAddress === WETH_TOKEN_ADDRESS,
        )?.balance ?? "0"

      // Parsed balances
      const maticBalance = +formatEther(rawMaticBalance.toBigInt())
      const wethBalance = +rawWethBalance
      const totalBalance = maticBalance + wethBalance * 131.62

      return {
        address,
        maticBalance,
        wethBalance,
        totalBalance,
      }
    },
  })

  return data
}

```

---

<div class="post-metadata">

**Author:** ![limbachiyachintan500](https://avatars.discourse-cdn.com/v4/letter/l/ad7895/32.png) [@limbachiyachintan500](https://builder.metamask.io/u/limbachiyachintan500)\
**Post date:** [September 15, 2023, 9:42am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785/4 "2023-09-15T09:42:11Z")

</div>

@vjgee

i am remove @alchemy/aa-core and @zerodevapp/sdk dependency from my package.json .after i am removed node\_modules than install and than again install all packages solve the error but new error show

[![image](https://canada1.discourse-cdn.com/flex011/uploads/metamaskbuilderhub/original/2X/a/a3baf98e15e643a1b829ff54d5ddbd06b4fd94b6.jpeg)
image790×325 71.7 KB
](https://web3auth.io/community/uploads/default/original/2X/7/7c0e5869053ccb3b82448119fc913878c762d3fa.jpeg "image")

---

<div class="post-metadata">

**Author:** ![vjgee](https://avatars.discourse-cdn.com/v4/letter/v/b5e925/32.png) [@vjgee](https://builder.metamask.io/u/vjgee)\
**Post date:** [September 15, 2023, 11:02am UTC](https://builder.metamask.io/t/archive-typeerror-cannot-read-properties-of-undefined-reading-init/1785/5 "2023-09-15T11:02:33Z")

</div>

Our Dev team will have to review this and will get back with an update.
