I'm following a private code tutorial for building a bsc dapp that calls import { useWallet } from '@binance-chain/bsc-use-wallet'. However my current project is going to be for the Polygon network. What is the equivalent module/library and functions I would call if I wish to use useWallet in Polygon?

Here is the code and the library https://github.com/binance-chain/bsc-use-wallet/blob/master/types/index.d.ts#L71

declare module '@binance-chain/bsc-use-wallet' {
  import { ReactNode } from 'react'

  type Connectors = Partial<{
    authereum: {}
    fortmatic: { apiKey: string }
    frame: {}
    injected: {}
    portis: { dAppId: string }
    squarelink: { clientId: string; options: object }
    provided: {}
    torus: {
      chainId?: number
      initOptions: object
      constructorOptions: object
    walletconnect: { rpcUrl: string }
    walletlink: { url: string; appName: string; appLogoUrl: string }
    bsc: {}

  export interface Wallet<T> {
    account: string | null
    balance: string
    chainId: number | null
    connect(connectorId: keyof Connectors): Promise<void>
    connector: keyof Connectors
    connectors: Connectors
      | UnsupportedChainError
      | UnsupportedChainError
      | RejectedActivationError
      | ConnectorConfigError
    ethereum: T
    networkName: string
    getBlockNumber(): number
    reset(): void
    status: string
    type: string | null

  interface UseWalletProviderProps {
    chainId: number
    children: ReactNode
    connectors?: Connectors
    pollBalanceInterval?: number
    pollBlockNumberInterval?: number

  interface UseWalletProps {
    pollBalanceInterval?: number
    pollBlockNumberInterval?: number

  export class ChainUnsupportedError extends Error {
    name: 'ChainUnsupportedError'

  export class ConnectorUnsupportedError extends Error {
    name: 'ConnectorUnsupportedError'

  export class ConnectionRejectedError extends Error {
    name: 'ConnectionRejectedError'

  export class ConnectorConfigError extends Error {
    name: 'ConnectorConfigError'

  export function useWallet<T>(props?: UseWalletProps): Wallet<T>

  export function UseWalletProvider(props: UseWalletProviderProps)

1 Answer 1


Simply use 137 for the chain id in your code and then @binance-chain/bsc-use-wallet will work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.