Ledger

Torus Wagmi Connector

Wagmi Connector for Torus Wallet

About

@toruslabs/torus-wagmi-connector is a connector for the popular wagmi library built on top of the @toruslabs/torus-embed .

It can be used to initialize a wagmi client that will seemlessly manage the interaction of your DApp with Torus Wallet.

How to use

Here is an example of a wagmi client using both the TorusConnector and the default InjectedConnector respectively.

import { TorusConnector } from "@toruslabs/torus-wagmi-connector";
import { chain, configureChains, createClient } from 'wagmi';
import { InjectedConnector } from 'wagmi/connectors/injected';
import { publicProvider } from 'wagmi/providers/public';

const { chains, provider } = configureChains(
  [chain.mainnet, chain.polygon],
  [publicProvider()]
);

const wagmiClient = createClient({
  autoConnect: true,
  connectors: [
    new TorusConnector({ 
      chains: chains,
      options: {
        chainId: "0x1",
        host: "mainnet",
      },
    }),
    new InjectedConnector({ chains }),
  ],
  provider,
});

Documentation

Have a look at the wagmi repo and the wagmi doc to learn more on connectors and wagmi.